| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 27827b2 commit 89d1be9
3 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -126,7 +126,7 @@ export async function normalizeOptions( | |||
| 126 | 126 | watch, | |
| 127 | 127 | debug: options.debug ?? false, | |
| 128 | 128 | ui: process.env['CI'] ? false : ui, | |
| 129 | - isolate: isolate ?? false, | ||
| 129 | + isolate, | ||
| 130 | 130 | quiet: options.quiet ?? (process.env['CI'] ? false : true), | |
| 131 | 131 | providersFile: options.providersFile && path.join(workspaceRoot, options.providersFile), | |
| 132 | 132 | setupFiles: options.setupFiles | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -54,7 +54,7 @@ interface VitestConfigPluginOptions { | |||
| 54 | 54 | include: string[]; | |
| 55 | 55 | optimizeDepsInclude: string[]; | |
| 56 | 56 | watch: boolean; | |
| 57 | - isolate: boolean; | ||
| 57 | + isolate: boolean | undefined; | ||
| 58 | 58 | } | |
| 59 | 59 | ||
| 60 | 60 | async function findTestEnvironment( | |
@@ -268,8 +268,8 @@ export async function createVitestConfigPlugin( | |||
| 268 | 268 | include, | |
| 269 | 269 | // CLI provider browser options override, if present | |
| 270 | 270 | ...(browser ? { browser } : {}), | |
| 271 | - // Only override if the user explicitly enabled it via CLI | ||
| 272 | - ...(options.isolate ? { isolate: true } : {}), | ||
| 271 | + // Only override if the user explicitly set it via CLI | ||
| 272 | + ...(options.isolate !== undefined ? { isolate: options.isolate } : {}), | ||
| 273 | 273 | // If the user has not specified an environment, use a smart default. | |
| 274 | 274 | ...(!testConfig?.environment | |
| 275 | 275 | ? { environment: await findTestEnvironment(projectResolver) } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -54,5 +54,59 @@ describeBuilder(execute, UNIT_TEST_BUILDER_INFO, (harness) => { | |||
| 54 | 54 | const { result } = await harness.executeOnce(); | |
| 55 | 55 | expect(result?.success).toBeTrue(); | |
| 56 | 56 | }); | |
| 57 | + | ||
| 58 | + it('should override isolate from the Vitest config file when set to false', async () => { | ||
| 59 | + harness.writeFile( | ||
| 60 | + 'vitest-base.config.ts', | ||
| 61 | + ` | ||
| 62 | + import { defineConfig } from 'vitest/config'; | ||
| 63 | + | ||
| 64 | + export default defineConfig({ | ||
| 65 | + test: { | ||
| 66 | + fileParallelism: false, | ||
| 67 | + isolate: true, | ||
| 68 | + setupFiles: ['./src/setup.ts'], | ||
| 69 | + }, | ||
| 70 | + }); | ||
| 71 | + `, | ||
| 72 | + ); | ||
| 73 | + | ||
| 74 | + harness.writeFile( | ||
| 75 | + 'src/setup.ts', | ||
| 76 | + ` | ||
| 77 | + const global = globalThis as typeof globalThis & { setupCount?: number }; | ||
| 78 | + global.setupCount = (global.setupCount ?? 0) + 1; | ||
| 79 | + `, | ||
| 80 | + ); | ||
| 81 | + | ||
| 82 | + harness.writeFile( | ||
| 83 | + 'src/app/first.spec.ts', | ||
| 84 | + ` | ||
| 85 | + it('runs first', () => { | ||
| 86 | + expect(true).toBe(true); | ||
| 87 | + }); | ||
| 88 | + `, | ||
| 89 | + ); | ||
| 90 | + | ||
| 91 | + harness.writeFile( | ||
| 92 | + 'src/app/second.spec.ts', | ||
| 93 | + ` | ||
| 94 | + it('shares the test environment with the first spec file', () => { | ||
| 95 | + const global = globalThis as typeof globalThis & { setupCount?: number }; | ||
| 96 | + expect(global.setupCount).toBeGreaterThan(1); | ||
| 97 | + }); | ||
| 98 | + `, | ||
| 99 | + ); | ||
| 100 | + | ||
| 101 | + harness.useTarget('test', { | ||
| 102 | + ...BASE_OPTIONS, | ||
| 103 | + runner: 'vitest' as any, | ||
| 104 | + runnerConfig: true, | ||
| 105 | + isolate: false, | ||
| 106 | + }); | ||
| 107 | + | ||
| 108 | + const { result } = await harness.executeOnce(); | ||
| 109 | + expect(result?.success).toBeTrue(); | ||
| 110 | + }); | ||
| 57 | 111 | }); | |
| 58 | 112 | }); | |
| Back | FazBrowse Home | New Git URL |
0 commit comments