Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
penalosa committed Feb 16, 2024
1 parent 86931c5 commit 2587ec6
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
17 changes: 10 additions & 7 deletions packages/vitest/src/node/plugins/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,6 @@ export async function VitestPlugin(options: UserConfig = {}, ctx = new Vitest('t
)
testConfig.api = resolveApiServerConfig(testConfig)

testConfig.poolOptions ??= {}
testConfig.poolOptions.threads ??= {}
testConfig.poolOptions.forks ??= {}
// prefer --poolOptions.{name}.isolate CLI arguments over --isolate, but still respect config value
testConfig.poolOptions.threads.isolate = options.poolOptions?.threads?.isolate ?? options.isolate ?? testConfig.poolOptions.threads.isolate ?? viteConfig.test?.isolate
testConfig.poolOptions.forks.isolate = options.poolOptions?.forks?.isolate ?? options.isolate ?? testConfig.poolOptions.forks.isolate ?? viteConfig.test?.isolate

// store defines for globalThis to make them
// reassignable when running in worker in src/runtime/setup.ts
const defines: Record<string, any> = deleteDefineConfig(viteConfig)
Expand Down Expand Up @@ -97,6 +90,16 @@ export async function VitestPlugin(options: UserConfig = {}, ctx = new Vitest('t
allow: resolveFsAllow(getRoot(), testConfig.config),
},
},
test: {
poolOptions: {
threads: {
isolate: options.poolOptions?.threads?.isolate ?? options.isolate ?? testConfig.poolOptions?.threads?.isolate ?? viteConfig.test?.isolate,
},
forks: {
isolate: options.poolOptions?.threads?.isolate ?? options.isolate ?? testConfig.poolOptions?.threads?.isolate ?? viteConfig.test?.isolate,
},
},
},
}

// we want inline dependencies to be resolved by analyser plugin so module graph is populated correctly
Expand Down
2 changes: 1 addition & 1 deletion test/config/test/resolution.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ async function config(cliOptions: UserConfig, configValue: UserConfig = {}, vite
}

describe('correctly defines isolated flags', async () => {
it('does not merge poolOptions with itself', async () => {
it('does not merge user-defined poolOptions with itself', async () => {
const c = await config({}, {
poolOptions: {
array: [1, 2, 3],
Expand Down

0 comments on commit 2587ec6

Please sign in to comment.