Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ jobs:
test_target_name: e2e.esbuild_node22
env:
E2E_SHARD_TOTAL: 1
TESTBRIDGE_TEST_ONLY: tests/basic/{build,rebuild}.ts
TESTBRIDGE_TEST_ONLY: tests/vitest/larger-project-coverage.ts

e2e-package-managers:
needs: build
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import { readFile } from 'node:fs/promises';
import { createRequire } from 'node:module';
import path from 'node:path';
import { platform } from 'node:os';

Check failure on line 13 in packages/angular/build/src/builders/unit-test/runners/vitest/plugins.ts

View workflow job for this annotation

GitHub Actions / lint

`node:os` import should occur before import of `node:path`
import type {
BrowserConfigOptions,
InlineConfig,
Expand Down Expand Up @@ -171,6 +172,10 @@
name: 'angular:test-in-memory-provider',
enforce: 'pre',
resolveId: (id, importer) => {
if (id[0] === '/' && platform() === 'win32' && path.isAbsolute(id.slice(1))) {
return id.slice(1);
}

if (importer && (id[0] === '.' || id[0] === '/')) {
let fullPath;
if (testFileToEntryPoint.has(importer)) {
Expand Down
30 changes: 16 additions & 14 deletions tests/legacy-cli/e2e/tests/vitest/larger-project-coverage.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { ng } from '../../utils/process';
import { ng, noSilentNg } from '../../utils/process';
import { applyVitestBuilder } from '../../utils/vitest';
import assert from 'node:assert';
import { installPackage } from '../../utils/packages';
import { exec } from '../../utils/process';
import { updateJsonFile } from '../../utils/project';
import { readFile } from '../../utils/fs';
import { readFile, replaceInFile } from '../../utils/fs';

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

// await replaceInFile(
// 'node_modules/@vitest/coverage-v8/dist/provider.js',
// `removeStartsWith(url, FILE_PROTOCOL)`,
// `fileURLToPath(url)`,
// );

// Run tests in default (JSDOM) mode with coverage
const { stdout: jsdomStdout } = await ng('test', '--no-watch', '--coverage');
const { stdout: jsdomStdout } = await noSilentNg('test', '--no-watch', '--coverage');
assert.match(jsdomStdout, expectedMessage, `Expected ${totalTests} tests to pass in JSDOM mode.`);

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

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

// Run tests in browser mode with coverage
const { stdout: browserStdout } = await ng(
const { stdout: browserStdout } = await noSilentNg(
'test',
'--no-watch',
'--coverage',
Expand Down
Loading