Skip to content

Commit 6608e17

Browse files
committed
fix(@angular/build): enable test isolation by default in browser mode
This commit enables test isolation by default when running tests in a browser. Disabling test isolation in browser mode has been found to cause non-deterministic test failures. To improve reliability, this change conditionally enables the `isolate` option when a browser provider is active. Isolation remains disabled for DOM emulation environments to maintain alignment with the traditional Karma/Jasmine experience. Further investigation is needed to determine if isolation can be safely disabled for browser mode in the future.
1 parent 6f2d4a9 commit 6608e17

File tree

1 file changed

+3
-2
lines changed
  • packages/angular/build/src/builders/unit-test/runners/vitest

1 file changed

+3
-2
lines changed

packages/angular/build/src/builders/unit-test/runners/vitest/plugins.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,8 +117,9 @@ export async function createVitestConfigPlugin(
117117
test: {
118118
setupFiles,
119119
globals: true,
120-
// Default to `false` to align with the Karma/Jasmine experience.
121-
isolate: false,
120+
// Default to `false` to align with the Karma/Jasmine experience when using DOM emulation
121+
// TODO: Investigate how this can be the default for browser mode as well
122+
isolate: !!browser?.enabled,
122123
sequence: { setupFiles: 'list' },
123124
},
124125
optimizeDeps: {

0 commit comments

Comments
 (0)