Skip to content

Commit 7c993e9

Browse files
authored
test: standardising internal test (#5600)
1 parent d7fa5cd commit 7c993e9

File tree

424 files changed

+1340
-2749
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

424 files changed

+1340
-2749
lines changed

.github/workflows/ci.yml

+6-25
Original file line numberDiff line numberDiff line change
@@ -32,22 +32,6 @@ jobs:
3232
- name: Lint
3333
run: pnpm run lint
3434

35-
typecheck:
36-
runs-on: ubuntu-latest
37-
steps:
38-
- uses: actions/checkout@v4
39-
40-
- uses: ./.github/actions/setup-and-cache
41-
42-
- name: Install
43-
run: pnpm i
44-
45-
- name: Build
46-
run: pnpm run build
47-
48-
- name: Typecheck
49-
run: pnpm run typecheck
50-
5135
test:
5236
runs-on: ${{ matrix.os }}
5337

@@ -85,11 +69,8 @@ jobs:
8569
- name: Test
8670
run: pnpm run test:ci
8771

88-
- name: Test No Threads
89-
run: pnpm run test:ci:no-threads
90-
91-
- name: Test Vm Threads
92-
run: pnpm run test:ci:vm-threads
72+
- name: Test Examples
73+
run: pnpm run test:examples
9374

9475
test-ui:
9576
runs-on: ubuntu-latest
@@ -147,8 +128,6 @@ jobs:
147128

148129
timeout-minutes: 30
149130

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

@@ -170,6 +149,8 @@ jobs:
170149

171150
- name: Test Browser (webdriverio)
172151
run: pnpm run test:browser:webdriverio
152+
env:
153+
BROWSER: ${{ matrix.browser[0] }}
173154

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

186167
timeout-minutes: 30
187168

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

@@ -208,6 +187,8 @@ jobs:
208187

209188
- name: Test Browser (webdriverio)
210189
run: pnpm run test:browser:webdriverio
190+
env:
191+
BROWSER: ${{ matrix.browser[0] }}
211192

212193
- name: Test Browser (playwright)
213194
run: pnpm run test:browser:playwright

.gitignore

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,4 @@ docs/public/user-avatars
2727
docs/public/sponsors
2828
.eslintcache
2929
docs/.vitepress/cache/
30-
!test/cwd/**/.cache
30+
!test/cli/fixtures/dotted-files/**/.cache

eslint.config.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ export default antfu(
1414
'**/*.timestamp-*',
1515
'test/core/src/self',
1616
'test/cache/cache/.vitest-base/results.json',
17-
'test/wasm-modules/src/wasm-bindgen-no-cyclic',
17+
'test/core/src/wasm/wasm-bindgen-no-cyclic',
1818
'test/workspaces/results.json',
1919
'test/workspaces-browser/results.json',
2020
'test/reporters/fixtures/with-syntax-error.test.js',
@@ -100,7 +100,7 @@ export default antfu(
100100
files: [
101101
`docs/${GLOB_SRC}`,
102102
`packages/web-worker/${GLOB_SRC}`,
103-
`test/web-worker/${GLOB_SRC}`,
103+
`test/core/${GLOB_SRC}`,
104104
],
105105
rules: {
106106
'no-restricted-globals': 'off',

package.json

+3-6
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,9 @@
2424
"lint:fix": "nr lint --fix",
2525
"publish-ci": "tsx scripts/publish-ci.ts",
2626
"release": "bumpp package.json packages/*/package.json --commit --push --tag && git update-ref refs/heads/release refs/heads/main && git push origin release",
27-
"test": "vitest --api -r test/core",
28-
"test:run": "vitest run -r test/core",
29-
"test:all": "CI=true pnpm -r --stream run test --allowOnly",
30-
"test:ci": "CI=true pnpm -r --reporter-hide-prefix --stream --filter !test-browser --filter !test-esm --filter !test-browser run test --allowOnly",
31-
"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",
32-
"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",
27+
"test": "pnpm --filter test-core test:threads",
28+
"test:ci": "CI=true pnpm -r --reporter-hide-prefix --stream --filter '@vitest/test-*' --filter !test-browser run test",
29+
"test:examples": "CI=true pnpm -r --reporter-hide-prefix --stream --filter '@vitest/example-*' run test",
3330
"typecheck": "tsc -p tsconfig.check.json --noEmit",
3431
"typecheck:why": "tsc -p tsconfig.check.json --noEmit --explainFiles > explainTypes.txt",
3532
"ui:build": "vite build packages/ui",

packages/vitest/src/node/pool.ts

+7
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import mm from 'micromatch'
22
import type { Awaitable } from '@vitest/utils'
33
import type { BuiltinPool, Pool } from '../types/pool-options'
4+
import { isWindows } from '../utils/env'
45
import type { Vitest } from './core'
56
import { createForksPool } from './pools/forks'
67
import { createThreadsPool } from './pools/threads'
@@ -91,6 +92,12 @@ export function createPool(ctx: Vitest): ProcessPool {
9192
},
9293
}
9394

95+
// env are case-insensitive on Windows, but spawned processes don't support it
96+
if (isWindows) {
97+
for (const name in options.env)
98+
options.env[name.toUpperCase()] = options.env[name]
99+
}
100+
94101
const customPools = new Map<string, ProcessPool>()
95102
async function resolveCustomPool(filepath: string) {
96103
if (customPools.has(filepath))

packages/vitest/src/suite.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
export { getCurrentSuite, createTaskCollector, getFn, setFn, getHooks, setHooks } from '@vitest/runner'
1+
export { getCurrentSuite, getCurrentTest, createTaskCollector, getFn, setFn, getHooks, setHooks } from '@vitest/runner'
22
export { createChainable } from '@vitest/runner/utils'
33
export { getBenchFn, getBenchOptions } from './runtime/benchmark'

packages/vitest/src/utils/env.ts

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
export const isNode: boolean = typeof process < 'u' && typeof process.stdout < 'u' && !process.versions?.deno && !globalThis.window
2+
export const isWindows = isNode && process.platform === 'win32'
23
export const isBrowser: boolean = typeof window !== 'undefined'
34
export { isCI, provider as stdProvider } from 'std-env'

packages/vitest/src/utils/index.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import { relative } from 'pathe'
22
import { getWorkerState } from '../utils'
3-
import { isNode } from './env'
43

54
export * from './graph'
65
export * from './tasks'
@@ -10,8 +9,8 @@ export * from './timers'
109
export * from './env'
1110
export * from './modules'
1211
export * from './serialization'
12+
export { isWindows } from './env'
1313

14-
export const isWindows = isNode && process.platform === 'win32'
1514
export function getRunMode() {
1615
return getWorkerState().config.mode
1716
}

0 commit comments

Comments
 (0)