Skip to content

Commit 2f1b561

Browse files
committed
test: avoid hardcoded path in lcov diagnostic
1 parent ec54349 commit 2f1b561

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

test/common/assertSnapshot.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -234,14 +234,15 @@ function replaceJunitDuration(str) {
234234
// This transform picks only the first line and then the lines from the test
235235
// file.
236236
function pickTestFileFromLcov(str) {
237+
const expectedFile = 'output.js';
237238
const lines = str.split(/\n/);
238239
const firstLineOfTestFile = lines.findIndex(
239-
(line) => line.startsWith('SF:') && line.trim().endsWith('output.js'),
240+
(line) => line.startsWith('SF:') && line.trim().endsWith(expectedFile),
240241
);
241242

242243
if (firstLineOfTestFile === -1) {
243244
assert.fail(
244-
'Could not find coverage for test/fixtures/test-runner/output/output.js ' +
245+
`Could not find LCOV source record ending with ${expectedFile} ` +
245246
`in LCOV output:\n${str || '<empty>'}`,
246247
);
247248
}
@@ -252,7 +253,7 @@ function pickTestFileFromLcov(str) {
252253

253254
if (lastLineOfTestFile === -1) {
254255
assert.fail(
255-
'Could not find end_of_record for test/fixtures/test-runner/output/output.js ' +
256+
`Could not find end_of_record for LCOV source record ending with ${expectedFile} ` +
256257
`in LCOV output:\n${str}`,
257258
);
258259
}

0 commit comments

Comments
 (0)