Skip to content

Commit 31f2059

Browse files
committed
test: improve Windows CI E2E path checks
1 parent 8bd7f28 commit 31f2059

File tree

3 files changed

+22
-15
lines changed

3 files changed

+22
-15
lines changed

.github/workflows/pr.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ jobs:
171171
test_target_name: e2e.esbuild_node22
172172
env:
173173
E2E_SHARD_TOTAL: 1
174-
TESTBRIDGE_TEST_ONLY: tests/basic/{build,rebuild}.ts
174+
TESTBRIDGE_TEST_ONLY: tests/vitest/larger-project-coverage.ts
175175

176176
e2e-package-managers:
177177
needs: build

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import assert from 'node:assert';
1010
import { readFile } from 'node:fs/promises';
1111
import { createRequire } from 'node:module';
1212
import path from 'node:path';
13+
import { platform } from 'node:os';
1314
import type {
1415
BrowserConfigOptions,
1516
InlineConfig,
@@ -171,6 +172,10 @@ export function createVitestPlugins(pluginOptions: PluginOptions): VitestPlugins
171172
name: 'angular:test-in-memory-provider',
172173
enforce: 'pre',
173174
resolveId: (id, importer) => {
175+
if (id[0] === '/' && platform() === 'win32' && path.isAbsolute(id.slice(1))) {
176+
return id.slice(1);
177+
}
178+
174179
if (importer && (id[0] === '.' || id[0] === '/')) {
175180
let fullPath;
176181
if (testFileToEntryPoint.has(importer)) {

tests/legacy-cli/e2e/tests/vitest/larger-project-coverage.ts

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
import { ng } from '../../utils/process';
1+
import { ng, noSilentNg } from '../../utils/process';
22
import { applyVitestBuilder } from '../../utils/vitest';
33
import assert from 'node:assert';
44
import { installPackage } from '../../utils/packages';
55
import { exec } from '../../utils/process';
66
import { updateJsonFile } from '../../utils/project';
7-
import { readFile } from '../../utils/fs';
7+
import { readFile, replaceInFile } from '../../utils/fs';
88

99
export default async function () {
1010
await applyVitestBuilder();
@@ -59,20 +59,22 @@ export default async function () {
5959
const expectedMessage = new RegExp(`${totalTests} passed`);
6060
const coverageJsonPath = 'coverage/test-project/coverage-final.json';
6161

62+
// await replaceInFile(
63+
// 'node_modules/@vitest/coverage-v8/dist/provider.js',
64+
// `removeStartsWith(url, FILE_PROTOCOL)`,
65+
// `fileURLToPath(url)`,
66+
// );
67+
6268
// Run tests in default (JSDOM) mode with coverage
63-
const { stdout: jsdomStdout } = await ng('test', '--no-watch', '--coverage');
69+
const { stdout: jsdomStdout } = await noSilentNg('test', '--no-watch', '--coverage');
6470
assert.match(jsdomStdout, expectedMessage, `Expected ${totalTests} tests to pass in JSDOM mode.`);
6571

66-
// TODO: Investigate why coverage-final.json is empty on Windows in JSDOM mode.
67-
// For now, skip the coverage report check on Windows.
68-
if (process.platform !== 'win32') {
69-
// Assert that every generated file is in the coverage report by reading the JSON output.
70-
const jsdomSummary = JSON.parse(await readFile(coverageJsonPath));
71-
const jsdomSummaryKeys = Object.keys(jsdomSummary);
72-
for (const file of generatedFiles) {
73-
const found = jsdomSummaryKeys.some((key) => key.endsWith(file));
74-
assert.ok(found, `Expected ${file} to be in the JSDOM coverage report.`);
75-
}
72+
// Assert that every generated file is in the coverage report by reading the JSON output.
73+
const jsdomSummary = JSON.parse(await readFile(coverageJsonPath));
74+
const jsdomSummaryKeys = Object.keys(jsdomSummary);
75+
for (const file of generatedFiles) {
76+
const found = jsdomSummaryKeys.some((key) => key.endsWith(file));
77+
assert.ok(found, `Expected ${file} to be in the JSDOM coverage report.`);
7678
}
7779

7880
// Setup for browser mode
@@ -81,7 +83,7 @@ export default async function () {
8183
await exec('npx', 'playwright', 'install', 'chromium', '--only-shell');
8284

8385
// Run tests in browser mode with coverage
84-
const { stdout: browserStdout } = await ng(
86+
const { stdout: browserStdout } = await noSilentNg(
8587
'test',
8688
'--no-watch',
8789
'--coverage',

0 commit comments

Comments
 (0)