Skip to content

Commit 1fd53a5

Browse files
committed
test: improve Windows CI E2E path checks
1 parent ed700a1 commit 1fd53a5

File tree

2 files changed

+35
-6
lines changed

2 files changed

+35
-6
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

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

Lines changed: 34 additions & 5 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,29 +59,56 @@ export default async function () {
5959
const expectedMessage = new RegExp(`${totalTests} passed`);
6060
const coverageJsonPath = 'coverage/test-project/coverage-final.json';
6161

62+
// Check for raw v8 coverage info
63+
// await replaceInFile(
64+
// 'node_modules/@vitest/coverage-v8/dist/index.js',
65+
// `return { result };`,
66+
// `console.log(JSON.stringify(result, null, 2));return { result };`,
67+
// );
68+
69+
// await replaceInFile(
70+
// 'node_modules/@vitest/coverage-v8/dist/provider.js',
71+
// `if (this.isIncluded(fileURLToPath(result.url))) {`,
72+
// `console.log('CHECKING:', result.url);if (this.isIncluded(fileURLToPath(result.url))) {console.log('INCLUDED:', result.url);`,
73+
// );
74+
75+
// await replaceInFile(
76+
// 'node_modules/@vitest/coverage-v8/dist/provider.js',
77+
// `const exists = existsSync(filename);`,
78+
// `const exists = existsSync(filename);console.log('EXISTS:', filename, exists);`,
79+
// );
80+
81+
await replaceInFile(
82+
'node_modules/@vitest/coverage-v8/dist/provider.js',
83+
`let ast;`,
84+
`let ast;console.log('REMAPPING:', filename);`,
85+
);
86+
6287
// Run tests in default (JSDOM) mode with coverage
63-
const { stdout: jsdomStdout } = await ng('test', '--no-watch', '--coverage');
88+
const { stdout: jsdomStdout } = await noSilentNg('test', '--no-watch', '--coverage');
6489
assert.match(jsdomStdout, expectedMessage, `Expected ${totalTests} tests to pass in JSDOM mode.`);
6590

91+
const jsdomSummary = JSON.parse(await readFile(coverageJsonPath));
6692
// TODO: Investigate why coverage-final.json is empty on Windows in JSDOM mode.
6793
// For now, skip the coverage report check on Windows.
6894
if (process.platform !== 'win32') {
6995
// Assert that every generated file is in the coverage report by reading the JSON output.
70-
const jsdomSummary = JSON.parse(await readFile(coverageJsonPath));
96+
7197
const jsdomSummaryKeys = Object.keys(jsdomSummary);
7298
for (const file of generatedFiles) {
7399
const found = jsdomSummaryKeys.some((key) => key.endsWith(file));
74100
assert.ok(found, `Expected ${file} to be in the JSDOM coverage report.`);
75101
}
76102
}
103+
console.log(JSON.stringify(jsdomSummary, null, 2));
77104

78105
// Setup for browser mode
79106
await installPackage('playwright@1');
80107
await installPackage('@vitest/browser-playwright@4');
81108
await exec('npx', 'playwright', 'install', 'chromium', '--only-shell');
82109

83110
// Run tests in browser mode with coverage
84-
const { stdout: browserStdout } = await ng(
111+
const { stdout: browserStdout } = await noSilentNg(
85112
'test',
86113
'--no-watch',
87114
'--coverage',
@@ -101,4 +128,6 @@ export default async function () {
101128
const found = browserSummaryKeys.some((key) => key.endsWith(file));
102129
assert.ok(found, `Expected ${file} to be in the browser coverage report.`);
103130
}
131+
132+
console.log(JSON.stringify(browserSummaryKeys, null, 2));
104133
}

0 commit comments

Comments
 (0)