Skip to content

Commit

Permalink
test: standardising internal test (#5600)
Browse files Browse the repository at this point in the history
  • Loading branch information
sheremet-va committed Apr 26, 2024
1 parent d7fa5cd commit 7c993e9
Show file tree
Hide file tree
Showing 424 changed files with 1,340 additions and 2,749 deletions.
31 changes: 6 additions & 25 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,22 +32,6 @@ jobs:
- name: Lint
run: pnpm run lint

typecheck:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- uses: ./.github/actions/setup-and-cache

- name: Install
run: pnpm i

- name: Build
run: pnpm run build

- name: Typecheck
run: pnpm run typecheck

test:
runs-on: ${{ matrix.os }}

Expand Down Expand Up @@ -85,11 +69,8 @@ jobs:
- name: Test
run: pnpm run test:ci

- name: Test No Threads
run: pnpm run test:ci:no-threads

- name: Test Vm Threads
run: pnpm run test:ci:vm-threads
- name: Test Examples
run: pnpm run test:examples

test-ui:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -147,8 +128,6 @@ jobs:

timeout-minutes: 30

env:
BROWSER: ${{ matrix.browser[0] }}
steps:
- uses: actions/checkout@v4

Expand All @@ -170,6 +149,8 @@ jobs:

- name: Test Browser (webdriverio)
run: pnpm run test:browser:webdriverio
env:
BROWSER: ${{ matrix.browser[0] }}

- name: Test Browser (playwright)
run: pnpm run test:browser:playwright
Expand All @@ -185,8 +166,6 @@ jobs:

timeout-minutes: 30

env:
BROWSER: ${{ matrix.browser[0] }}
steps:
- uses: actions/checkout@v4

Expand All @@ -208,6 +187,8 @@ jobs:

- name: Test Browser (webdriverio)
run: pnpm run test:browser:webdriverio
env:
BROWSER: ${{ matrix.browser[0] }}

- name: Test Browser (playwright)
run: pnpm run test:browser:playwright
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,4 @@ docs/public/user-avatars
docs/public/sponsors
.eslintcache
docs/.vitepress/cache/
!test/cwd/**/.cache
!test/cli/fixtures/dotted-files/**/.cache
4 changes: 2 additions & 2 deletions eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export default antfu(
'**/*.timestamp-*',
'test/core/src/self',
'test/cache/cache/.vitest-base/results.json',
'test/wasm-modules/src/wasm-bindgen-no-cyclic',
'test/core/src/wasm/wasm-bindgen-no-cyclic',
'test/workspaces/results.json',
'test/workspaces-browser/results.json',
'test/reporters/fixtures/with-syntax-error.test.js',
Expand Down Expand Up @@ -100,7 +100,7 @@ export default antfu(
files: [
`docs/${GLOB_SRC}`,
`packages/web-worker/${GLOB_SRC}`,
`test/web-worker/${GLOB_SRC}`,
`test/core/${GLOB_SRC}`,
],
rules: {
'no-restricted-globals': 'off',
Expand Down
9 changes: 3 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,9 @@
"lint:fix": "nr lint --fix",
"publish-ci": "tsx scripts/publish-ci.ts",
"release": "bumpp package.json packages/*/package.json --commit --push --tag && git update-ref refs/heads/release refs/heads/main && git push origin release",
"test": "vitest --api -r test/core",
"test:run": "vitest run -r test/core",
"test:all": "CI=true pnpm -r --stream run test --allowOnly",
"test:ci": "CI=true pnpm -r --reporter-hide-prefix --stream --filter !test-browser --filter !test-esm --filter !test-browser run test --allowOnly",
"test:ci:vm-threads": "CI=true pnpm -r --reporter-hide-prefix --stream --filter !test-coverage --filter !test-single-thread --filter !test-browser --filter !test-esm --filter !test-network-imports --filter !test-browser --filter !example-react-testing-lib-msw run test --allowOnly --pool vmThreads",
"test:ci:no-threads": "CI=true pnpm -r --reporter-hide-prefix --stream --filter !test-vm-threads --filter !test-coverage --filter !test-watch --filter !test-bail --filter !test-esm --filter !test-browser run test --allowOnly --pool forks",
"test": "pnpm --filter test-core test:threads",
"test:ci": "CI=true pnpm -r --reporter-hide-prefix --stream --filter '@vitest/test-*' --filter !test-browser run test",
"test:examples": "CI=true pnpm -r --reporter-hide-prefix --stream --filter '@vitest/example-*' run test",
"typecheck": "tsc -p tsconfig.check.json --noEmit",
"typecheck:why": "tsc -p tsconfig.check.json --noEmit --explainFiles > explainTypes.txt",
"ui:build": "vite build packages/ui",
Expand Down
7 changes: 7 additions & 0 deletions packages/vitest/src/node/pool.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import mm from 'micromatch'
import type { Awaitable } from '@vitest/utils'
import type { BuiltinPool, Pool } from '../types/pool-options'
import { isWindows } from '../utils/env'
import type { Vitest } from './core'
import { createForksPool } from './pools/forks'
import { createThreadsPool } from './pools/threads'
Expand Down Expand Up @@ -91,6 +92,12 @@ export function createPool(ctx: Vitest): ProcessPool {
},
}

// env are case-insensitive on Windows, but spawned processes don't support it
if (isWindows) {
for (const name in options.env)
options.env[name.toUpperCase()] = options.env[name]
}

const customPools = new Map<string, ProcessPool>()
async function resolveCustomPool(filepath: string) {
if (customPools.has(filepath))
Expand Down
2 changes: 1 addition & 1 deletion packages/vitest/src/suite.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
export { getCurrentSuite, createTaskCollector, getFn, setFn, getHooks, setHooks } from '@vitest/runner'
export { getCurrentSuite, getCurrentTest, createTaskCollector, getFn, setFn, getHooks, setHooks } from '@vitest/runner'
export { createChainable } from '@vitest/runner/utils'
export { getBenchFn, getBenchOptions } from './runtime/benchmark'
1 change: 1 addition & 0 deletions packages/vitest/src/utils/env.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export const isNode: boolean = typeof process < 'u' && typeof process.stdout < 'u' && !process.versions?.deno && !globalThis.window
export const isWindows = isNode && process.platform === 'win32'
export const isBrowser: boolean = typeof window !== 'undefined'
export { isCI, provider as stdProvider } from 'std-env'
3 changes: 1 addition & 2 deletions packages/vitest/src/utils/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { relative } from 'pathe'
import { getWorkerState } from '../utils'
import { isNode } from './env'

export * from './graph'
export * from './tasks'
Expand All @@ -10,8 +9,8 @@ export * from './timers'
export * from './env'
export * from './modules'
export * from './serialization'
export { isWindows } from './env'

export const isWindows = isNode && process.platform === 'win32'
export function getRunMode() {
return getWorkerState().config.mode
}
Expand Down
Loading

0 comments on commit 7c993e9

Please sign in to comment.