Skip to content
Merged
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
63 changes: 63 additions & 0 deletions tests/e2e-coverage-report.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -2146,3 +2146,66 @@ test('collectE2ECoverage reads original content from disk when the map omits sou
await rm(fixture.root, { recursive: true, force: true });
}
});

test('a tooling-error artifact still names the run the manifest records', async () => {
const fixture = await fixtureRun();
try {
await writeCoverageArtifact(fixture.runDir, 'worker-0-page-0', {
schemaVersion: 1,
kind: 'endusers.playwright.v8-coverage',
runId: 'run-1',
result: [],
});
await sealCoverageRun(fixture.runDir, 'passed');
const jsonPath = join(fixture.root, 'identified-error.json');
const textPath = join(fixture.root, 'identified-error.txt');

await assert.rejects(
() =>
main([
'--input',
fixture.runDir,
'--root',
fixture.root,
'--build',
fixture.buildDir,
'--json',
jsonPath,
'--text',
textPath,
]),
/No src\/\*\* coverage was attributable/,
);

const report = JSON.parse(await readFile(jsonPath, 'utf8'));
assert.equal(report.status, 'tooling-error');
assert.equal(report.runId, 'run-1');
assert.equal(report.runStatus, 'passed');
assert.match(
await readFile(textPath, 'utf8'),
/^E2E coverage: tooling-error \(run run-1; status passed\)$/mu,
);
} finally {
await rm(fixture.root, { recursive: true, force: true });
}
});

test('a tooling-error artifact reports no run when the manifest is unreadable', async () => {
const root = await mkdtemp(join(tmpdir(), 'endusers-e2e-report-'));
try {
const runDir = join(root, 'coverage');
await mkdir(runDir, { recursive: true });
const jsonPath = join(root, 'unreadable-error.json');

await assert.rejects(() =>
main(['--input', runDir, '--root', root, '--json', jsonPath]),
);

const report = JSON.parse(await readFile(jsonPath, 'utf8'));
assert.equal(report.status, 'tooling-error');
assert.equal(report.runId, null);
assert.equal(report.runStatus, null);
} finally {
await rm(root, { recursive: true, force: true });
}
});
8 changes: 6 additions & 2 deletions tests/tools/e2e-coverage-report.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -710,15 +710,19 @@ export async function main(argv = process.argv.slice(2)) {
});
if (!options.text) process.stdout.write(text);
} catch (error) {
// Only the run-status guards raise CoverageReportError; every later failure
// is a plain Error, so re-read the manifest rather than publish a report
// that cannot say whether the run passed or the tooling broke.
const run = await readCoverageRun(resolve(options.input)).catch(() => null);
const failure = {
schemaVersion: 2,
kind: ERROR_KIND,
status:
error.runStatus === 'failed' || error.runStatus === 'cancelled'
? error.runStatus
: 'tooling-error',
runId: error.runId ?? null,
runStatus: error.runStatus ?? null,
runId: error.runId ?? run?.runId ?? null,
runStatus: error.runStatus ?? run?.status ?? null,
scripts: { captured: 0, converted: 0, ignored: 0 },
sources: [],
summary: {
Expand Down
Loading