Skip to content

Commit b881e88

Browse files
authored
fix: remove browser.fileParallelism (#5790)
1 parent d6700bb commit b881e88

File tree

7 files changed

+25
-71
lines changed

7 files changed

+25
-71
lines changed

Diff for: docs/config/index.md

-14
Original file line numberDiff line numberDiff line change
@@ -1536,20 +1536,6 @@ Run the browser in a `headless` mode. If you are running Vitest in CI, it will b
15361536

15371537
Run every test in a separate iframe.
15381538

1539-
### browser.fileParallelism {#browser-fileparallelism}
1540-
1541-
- **Type:** `boolean`
1542-
- **Default:** the same as [`fileParallelism`](#fileparallelism)
1543-
- **CLI:** `--browser.fileParallelism=false`
1544-
1545-
Create all test iframes at the same time so they are running in parallel.
1546-
1547-
This makes it impossible to use interactive APIs (like clicking or hovering) because there are several iframes on the screen at the same time, but if your tests don't rely on those APIs, it might be much faster to just run all of them at the same time.
1548-
1549-
::: tip
1550-
If you disabled isolation via [`browser.isolate=false`](#browser-isolate), your test files will still run one after another because of the nature of the test runner.
1551-
:::
1552-
15531539
#### browser.api
15541540

15551541
- **Type:** `number | { port?, strictPort?, host? }`

Diff for: docs/guide/cli-table.md

-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@
5757
| `--browser.providerOptions <options>` | Options that are passed down to a browser provider. Visit [`browser.providerOptions`](https://vitest.dev/config/#browser-provideroptions) for more information |
5858
| `--browser.slowHijackESM` | Let Vitest use its own module resolution on the browser to enable APIs such as vi.mock and vi.spyOn. Visit [`browser.slowHijackESM`](https://vitest.dev/config/#browser-slowhijackesm) for more information (default: `false`) |
5959
| `--browser.isolate` | Run every browser test file in isolation. To disable isolation, use `--browser.isolate=false` (default: `true`) |
60-
| `--browser.fileParallelism` | Should all test files run in parallel. Use `--browser.file-parallelism=false` to disable (default: same as `--file-parallelism`) |
6160
| `--pool <pool>` | Specify pool, if not running in the browser (default: `threads`) |
6261
| `--poolOptions.threads.isolate` | Isolate tests in threads pool (default: `true`) |
6362
| `--poolOptions.threads.singleThread` | Run tests inside a single thread (default: `false`) |

Diff for: packages/browser/src/client/main.ts

+15-28
Original file line numberDiff line numberDiff line change
@@ -100,42 +100,29 @@ client.ws.addEventListener('open', async () => {
100100
}
101101
})
102102

103-
const fileParallelism = config.browser.fileParallelism ?? config.fileParallelism
104-
105103
if (config.isolate === false) {
106104
createIframe(
107105
container,
108106
ID_ALL,
109107
)
110108
}
111109
else {
112-
// if fileParallelism is enabled, we can create all iframes at once
113-
if (fileParallelism) {
114-
for (const file of testFiles) {
115-
createIframe(
116-
container,
117-
file,
118-
)
119-
}
120-
}
121-
else {
122-
// otherwise, we need to wait for each iframe to finish before creating the next one
123-
// this is the most stable way to run tests in the browser
124-
for (const file of testFiles) {
125-
createIframe(
126-
container,
127-
file,
128-
)
129-
await new Promise<void>((resolve) => {
130-
channel.addEventListener('message', function handler(e: MessageEvent<IframeChannelEvent>) {
131-
// done and error can only be triggered by the previous iframe
132-
if (e.data.type === 'done' || e.data.type === 'error') {
133-
channel.removeEventListener('message', handler)
134-
resolve()
135-
}
136-
})
110+
// otherwise, we need to wait for each iframe to finish before creating the next one
111+
// this is the most stable way to run tests in the browser
112+
for (const file of testFiles) {
113+
createIframe(
114+
container,
115+
file,
116+
)
117+
await new Promise<void>((resolve) => {
118+
channel.addEventListener('message', function handler(e: MessageEvent<IframeChannelEvent>) {
119+
// done and error can only be triggered by the previous iframe
120+
if (e.data.type === 'done' || e.data.type === 'error') {
121+
channel.removeEventListener('message', handler)
122+
resolve()
123+
}
137124
})
138-
}
125+
})
139126
}
140127
}
141128
})

Diff for: packages/vitest/src/node/cli/cli-config.ts

-3
Original file line numberDiff line numberDiff line change
@@ -350,9 +350,6 @@ export const cliOptionsConfig: VitestCLIOptions = {
350350
ui: {
351351
description: 'Show Vitest UI when running tests',
352352
},
353-
fileParallelism: {
354-
description: 'Should all test files run in parallel. Use `--browser.file-parallelism=false` to disable (default: same as `--file-parallelism`)',
355-
},
356353
indexScripts: null,
357354
testerScripts: null,
358355
commands: null,

Diff for: packages/vitest/src/node/config.ts

-1
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,6 @@ export function resolveConfig(
149149
resolved.minWorkers = Number(resolved.minWorkers)
150150

151151
resolved.browser ??= {} as any
152-
resolved.browser.fileParallelism ??= resolved.fileParallelism ?? false
153152

154153
// run benchmark sequentially by default
155154
resolved.fileParallelism ??= mode !== 'benchmark'

Diff for: packages/vitest/src/types/browser.ts

-7
Original file line numberDiff line numberDiff line change
@@ -94,13 +94,6 @@ export interface BrowserConfigOptions {
9494
*/
9595
ui?: boolean
9696

97-
/**
98-
* Run test files in parallel. Fallbacks to `test.fileParallelism`.
99-
*
100-
* @default test.fileParallelism
101-
*/
102-
fileParallelism?: boolean
103-
10497
/**
10598
* Scripts injected into the tester iframe.
10699
*/

Diff for: test/browser/specs/runner.test.ts

+10-17
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
import { beforeAll, describe, expect, onTestFailed, test } from 'vitest'
22
import { runBrowserTests } from './utils'
33

4-
describe.each([
5-
['non parallel', false],
6-
['parallel', true],
7-
])('[%s] running browser tests', async (description, fileParallelism) => {
4+
describe('running browser tests', async () => {
85
let stderr: string
96
let stdout: string
107
let browserResultJson: any
@@ -18,14 +15,10 @@ describe.each([
1815
browserResultJson,
1916
passedTests,
2017
failedTests,
21-
} = await runBrowserTests({
22-
browser: {
23-
fileParallelism,
24-
},
25-
}))
18+
} = await runBrowserTests())
2619
})
2720

28-
test(`[${description}] tests are actually running`, () => {
21+
test('tests are actually running', () => {
2922
onTestFailed(() => {
3023
console.error(stderr)
3124
})
@@ -38,14 +31,14 @@ describe.each([
3831
expect(stderr).not.toContain('Unhandled Error')
3932
})
4033

41-
test(`[${description}] correctly prints error`, () => {
34+
test('correctly prints error', () => {
4235
expect(stderr).toContain('expected 1 to be 2')
4336
expect(stderr).toMatch(/- 2\s+\+ 1/)
4437
expect(stderr).toContain('Expected to be')
4538
expect(stderr).toContain('But got')
4639
})
4740

48-
test(`[${description}] logs are redirected to stdout`, () => {
41+
test('logs are redirected to stdout', () => {
4942
expect(stdout).toContain('stdout | test/logs.test.ts > logging to stdout')
5043
expect(stdout).toContain('hello from console.log')
5144
expect(stdout).toContain('hello from console.info')
@@ -65,26 +58,26 @@ describe.each([
6558
expect(stdout).toMatch(/time: [\d.]+ ms/)
6659
})
6760

68-
test(`[${description}] logs are redirected to stderr`, () => {
61+
test('logs are redirected to stderr', () => {
6962
expect(stderr).toContain('stderr | test/logs.test.ts > logging to stderr')
7063
expect(stderr).toContain('hello from console.error')
7164
expect(stderr).toContain('hello from console.warn')
7265
expect(stderr).toContain('Timer "invalid timeLog" does not exist')
7366
expect(stderr).toContain('Timer "invalid timeEnd" does not exist')
7467
})
7568

76-
test(`[${description}] stack trace points to correct file in every browser`, () => {
77-
// dependeing on the browser it references either `.toBe()` or `expect()`
69+
test('stack trace points to correct file in every browser', () => {
70+
// dependeing on the browser it references either '.toBe()' or 'expect()'
7871
expect(stderr).toMatch(/test\/failing.test.ts:4:(12|17)/)
7972
})
8073

81-
test(`[${description}] popup apis should log a warning`, () => {
74+
test('popup apis should log a warning', () => {
8275
expect(stderr).toContain('Vitest encountered a `alert("test")`')
8376
expect(stderr).toContain('Vitest encountered a `confirm("test")`')
8477
expect(stderr).toContain('Vitest encountered a `prompt("test")`')
8578
})
8679

87-
test(`[${description}] snapshot inaccessible file debuggability`, () => {
80+
test('snapshot inaccessible file debuggability', () => {
8881
expect(stderr).toContain('Access denied to "/inaccesible/path".')
8982
})
9083
})

0 commit comments

Comments
 (0)