Skip to content

Commit ec64a52

Browse files
fix: Vitest 4 max workers config
1 parent caf3cf1 commit ec64a52

File tree

2 files changed

+11
-9
lines changed

2 files changed

+11
-9
lines changed

src/config.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,11 +58,14 @@ export async function defineConfig(userConfig: ViteUserConfig = {}): Promise<Vit
5858

5959
const overrides = defineVitestConfig({
6060
test: {
61+
isolate: false,
62+
maxWorkers: 1,
63+
// @ts-expect-error: Vitest v3 compatibility
6164
poolOptions: {
6265
forks: {
6366
// Disabling isolation improves performance in Node environments
67+
maxWorkers: 1,
6468
isolate: false,
65-
singleFork: true,
6669
},
6770
},
6871
forceRerunTriggers: [
@@ -88,7 +91,6 @@ export async function defineConfig(userConfig: ViteUserConfig = {}): Promise<Vit
8891
join(currentDir, 'setup.js'),
8992
]
9093
: undefined,
91-
// @ts-expect-error: Append Nitro for global setup file
9294
nitro: resolvedNitroConfig,
9395
},
9496
}) as ViteUserConfig

src/setup.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,29 @@
1-
import type { GlobalSetupContext } from 'vitest/node'
1+
import type { TestProject } from 'vitest/node'
22
import type { NitroInlineConfig } from './config'
33
import { createTestContext } from './context'
44
import { startServer, stopServer } from './server'
55

6-
type GlobalSetupContextWithNitro = GlobalSetupContext & {
6+
type GlobalSetupContextWithNitro = TestProject & {
77
config: { nitro: NitroInlineConfig }
88
}
99

1010
// Setup shared Nitro instance
1111
// See https://vitest.dev/config/#globalsetup
12-
async function setup({ config, provide }: GlobalSetupContextWithNitro): Promise<(() => Promise<void>) | undefined> {
13-
if (!config.nitro.global)
12+
async function setup(project: GlobalSetupContextWithNitro): Promise<(() => Promise<void>) | undefined> {
13+
if (!project.config.nitro.global)
1414
return
1515

1616
await createTestContext({
17-
rootDir: config.nitro.global.rootDir || config.root,
18-
mode: config.nitro.global.mode,
17+
rootDir: project.config.nitro.global.rootDir || project.config.root,
18+
mode: project.config.nitro.global.mode,
1919
isGlobal: true,
2020
})
2121

2222
const ctx = await startServer()
2323

2424
// Global setup is run in a different global scope, so tests don't have access
2525
// to variables defined here. We need to expose the server URL for tests.
26-
provide('server', { url: ctx.server!.url })
26+
project.provide('server', { url: ctx.server!.url })
2727

2828
return async function () {
2929
await stopServer()

0 commit comments

Comments
 (0)