Skip to content

Commit dc7d333

Browse files
committed
fix test
1 parent 9b00ad0 commit dc7d333

File tree

3 files changed

+18
-5
lines changed

3 files changed

+18
-5
lines changed

test/common/assertSnapshot.js

+5
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@ function replaceWindowsPaths(str) {
2020
return str.replaceAll(path.win32.sep, path.posix.sep);
2121
}
2222

23+
function replaceFullPaths(str) {
24+
return str.replaceAll(process.cwd(), '');
25+
}
26+
2327
function transform(...args) {
2428
return (str) => args.reduce((acc, fn) => fn(acc), str);
2529
}
@@ -69,6 +73,7 @@ async function spawnAndAssert(filename, transform = (x) => x, { tty = false, ...
6973
module.exports = {
7074
assertSnapshot,
7175
getSnapshotPath,
76+
replaceFullPaths,
7277
replaceStackTrace,
7378
replaceWindowsLineEndings,
7479
replaceWindowsPaths,

test/fixtures/test-runner/output/global_after_should_fail_the_test.snapshot

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ ok 1 - this is a test
55
---
66
duration_ms: *
77
...
8-
not ok 2 - /Users/rluvaton/dev/open-source/node/node-fork/test/fixtures/test-runner/output/global_after_should_fail_the_test.js
8+
not ok 2 - /test/fixtures/test-runner/output/global_after_should_fail_the_test.js
99
---
1010
duration_ms: *
1111
failureType: 'hookFailed'

test/parallel/test-runner-output.mjs

+12-4
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,18 @@ function replaceSpecDuration(str) {
2424
.replaceAll(/duration_ms [0-9.]+/g, 'duration_ms *')
2525
.replace(stackTraceBasePath, '$3');
2626
}
27-
const defaultTransform = snapshot
28-
.transform(snapshot.replaceWindowsLineEndings, snapshot.replaceStackTrace, replaceTestDuration);
29-
const specTransform = snapshot
30-
.transform(replaceSpecDuration, snapshot.replaceWindowsLineEndings, snapshot.replaceStackTrace);
27+
const defaultTransform = snapshot.transform(
28+
snapshot.replaceWindowsLineEndings,
29+
snapshot.replaceStackTrace,
30+
replaceTestDuration,
31+
snapshot.replaceFullPaths
32+
);
33+
const specTransform = snapshot.transform(
34+
replaceSpecDuration,
35+
snapshot.replaceWindowsLineEndings,
36+
snapshot.replaceStackTrace,
37+
snapshot.replaceFullPaths
38+
);
3139

3240

3341
const tests = [

0 commit comments

Comments
 (0)