-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
fc4514c
commit a60a140
Showing
4 changed files
with
107 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { expect, test } from 'vitest' | ||
import type { UserConfig } from 'vitest/config' | ||
|
||
const pool = process.env.TESTED_POOL as "forks" | "threads"; | ||
|
||
test('is isolated', () => { | ||
// @ts-expect-error -- internal | ||
const config: NonNullable<UserConfig['test']> = globalThis.__vitest_worker__.config | ||
|
||
if (pool === 'forks') { | ||
expect(config.poolOptions?.forks?.isolate).toBe(true) | ||
} | ||
else { | ||
expect(pool).toBe('threads') | ||
expect(config.poolOptions?.threads?.isolate).toBe(true) | ||
} | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { expect, test } from 'vitest' | ||
import type { UserConfig } from 'vitest/config' | ||
|
||
const pool = process.env.TESTED_POOL as "forks" | "threads"; | ||
|
||
test('is isolated', () => { | ||
// @ts-expect-error -- internal | ||
const config: NonNullable<UserConfig['test']> = globalThis.__vitest_worker__.config | ||
|
||
if (pool === 'forks') { | ||
expect(config.poolOptions?.forks?.isolate).toBe(false) | ||
} | ||
else { | ||
expect(pool).toBe('threads') | ||
expect(config.poolOptions?.threads?.isolate).toBe(false) | ||
} | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
import { describe, expect, test } from 'vitest' | ||
import { runVitest } from '../../test-utils' | ||
|
||
describe.each(['forks', 'threads'] as const)('%s', async (pool) => { | ||
test('is isolated', async () => { | ||
const { stderr, exitCode } = await runVitest({ | ||
root: './fixtures/pool-isolation', | ||
include: ['isolated.test.ts'], | ||
pool, | ||
poolOptions: { | ||
// Use default value on the tested pool and disable on the other one | ||
[invertPool(pool)]: { isolate: false }, | ||
}, | ||
env: { TESTED_POOL: pool }, | ||
}) | ||
|
||
expect(stderr).toBe('') | ||
expect(exitCode).toBe(0) | ||
}) | ||
|
||
test('is isolated + poolMatchGlobs', async () => { | ||
const { stderr, exitCode } = await runVitest({ | ||
root: './fixtures/pool-isolation', | ||
include: ['isolated.test.ts'], | ||
pool, | ||
poolMatchGlobs: [['**', pool]], | ||
poolOptions: { | ||
// Use default value on the tested pool and disable on the other one | ||
[invertPool(pool)]: { isolate: false }, | ||
}, | ||
env: { TESTED_POOL: pool }, | ||
}) | ||
|
||
expect(stderr).toBe('') | ||
expect(exitCode).toBe(0) | ||
}) | ||
|
||
test('is not isolated', async () => { | ||
const { stderr, exitCode } = await runVitest({ | ||
root: './fixtures/pool-isolation', | ||
include: ['non-isolated.test.ts'], | ||
pool, | ||
poolOptions: { | ||
[pool]: { isolate: false }, | ||
}, | ||
env: { TESTED_POOL: pool }, | ||
}) | ||
|
||
expect(stderr).toBe('') | ||
expect(exitCode).toBe(0) | ||
}) | ||
|
||
test('is not isolated + poolMatchGlobs', async () => { | ||
const { stderr, exitCode } = await runVitest({ | ||
root: './fixtures/pool-isolation', | ||
include: ['non-isolated.test.ts'], | ||
pool: invertPool(pool), | ||
poolMatchGlobs: [['**/**.test.ts', pool]], | ||
poolOptions: { | ||
[pool]: { isolate: false }, | ||
}, | ||
env: { TESTED_POOL: pool }, | ||
}) | ||
|
||
expect(stderr).toBe('') | ||
expect(exitCode).toBe(0) | ||
}) | ||
}) | ||
|
||
function invertPool(pool: 'threads' | 'forks') { | ||
return pool === 'threads' ? 'forks' : 'threads' | ||
} |