Skip to content

Commit 0effc83

Browse files
committed
test(@angular/build): add E2E test for Vitest browser mode with coverage
This test ensures that stack traces map correctly to source files and that coverage reports are generated when running Vitest in browser mode with coverage enabled. This provides validation for the current implementation and will help verify future refactors removing the source-map-support dependency.
1 parent 5adc925 commit 0effc83

1 file changed

Lines changed: 27 additions & 0 deletions

File tree

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import assert from 'node:assert/strict';
2+
import { applyVitestBuilder } from '../../utils/vitest';
3+
import { ng } from '../../utils/process';
4+
import { installPackage } from '../../utils/packages';
5+
import { expectFileToExist, readFile } from '../../utils/fs';
6+
7+
export default async function (): Promise<void> {
8+
await applyVitestBuilder();
9+
await installPackage('playwright@1');
10+
await installPackage('@vitest/browser-playwright@4');
11+
await installPackage('@vitest/coverage-v8@4');
12+
13+
// Run tests with coverage in browser mode.
14+
// We use the default passing tests generated for the project.
15+
const { stdout } = await ng('test', '--no-watch', '--browsers', 'chromiumHeadless', '--coverage');
16+
17+
// Verify that tests passed
18+
assert.match(stdout, /pass/, 'Expected tests to run successfully.');
19+
20+
// Verify that coverage files are generated
21+
const coverageJsonPath = 'coverage/test-project/coverage-final.json';
22+
await expectFileToExist(coverageJsonPath);
23+
24+
const coverageContent = await readFile(coverageJsonPath);
25+
assert.match(coverageContent, /app\.ts/, 'Expected coverage report to contain app.ts.');
26+
assert.doesNotMatch(coverageContent, /\.spec\.ts/, 'Expected coverage report to not contain .spec.ts files.');
27+
}

0 commit comments

Comments
 (0)