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‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@ function replaceWindowsPaths(str){
2020
returnstr.replaceAll(path.win32.sep,path.posix.sep);
2121
}
2222

23+
functionreplaceFullPaths(str){
24+
returnstr.replaceAll(process.cwd(),'');
25+
}
26+
2327
functiontransform(...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‎

Lines changed: 1 addition & 1 deletion
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‎

Lines changed: 12 additions & 4 deletions
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-
constdefaultTransform=snapshot
28-
.transform(snapshot.replaceWindowsLineEndings,snapshot.replaceStackTrace,replaceTestDuration);
29-
constspecTransform=snapshot
30-
.transform(replaceSpecDuration,snapshot.replaceWindowsLineEndings,snapshot.replaceStackTrace);
27+
constdefaultTransform=snapshot.transform(
28+
snapshot.replaceWindowsLineEndings,
29+
snapshot.replaceStackTrace,
30+
replaceTestDuration,
31+
snapshot.replaceFullPaths
32+
);
33+
constspecTransform=snapshot.transform(
34+
replaceSpecDuration,
35+
snapshot.replaceWindowsLineEndings,
36+
snapshot.replaceStackTrace,
37+
snapshot.replaceFullPaths
38+
);
3139

3240

3341
consttests=[

0 commit comments

Comments
(0)