Skip to content

Commit aea3ed8

Browse files
committed
fix(@angular/build): exclude @vitest/browser/context from esbuild bundling
Bundling this module causes unit tests to fail with `@vitest/browser/context can be imported only inside the Browser Mode. Your test is running in browser pool. Make sure your regular tests are excluded from the "test.include" glob pattern.`, This is because `@vitest/browser/context` is a virtual mode in vite and the package on NPM is dummy that is used for static analysis. Closes: #30677 (cherry picked from commit 9e292f1)
1 parent 2784883 commit aea3ed8

File tree

1 file changed

+5
-1
lines changed
  • packages/angular/build/src/builders/unit-test

1 file changed

+5
-1
lines changed

packages/angular/build/src/builders/unit-test/builder.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,11 @@ export async function* execute(
138138
optimization: false,
139139
tsConfig: normalizedOptions.tsConfig,
140140
entryPoints,
141-
externalDependencies: ['vitest', ...(buildTargetOptions.externalDependencies ?? [])],
141+
externalDependencies: [
142+
'vitest',
143+
'@vitest/browser/context',
144+
...(buildTargetOptions.externalDependencies ?? []),
145+
],
142146
};
143147
extensions ??= {};
144148
extensions.codePlugins ??= [];

0 commit comments

Comments
 (0)