Skip to content

Commit c475e54

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 4e021e2 commit c475e54

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
@@ -134,7 +134,11 @@ export async function* execute(
134134
optimization: false,
135135
tsConfig: normalizedOptions.tsConfig,
136136
entryPoints,
137-
externalDependencies: ['vitest', ...(buildTargetOptions.externalDependencies ?? [])],
137+
externalDependencies: [
138+
'vitest',
139+
'@vitest/browser/context',
140+
...(buildTargetOptions.externalDependencies ?? []),
141+
],
138142
};
139143
extensions ??= {};
140144
extensions.codePlugins ??= [];

0 commit comments

Comments
 (0)