Skip to content

Commit

Permalink
fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
rluvaton committed Jul 25, 2023
1 parent 9b00ad0 commit dc7d333
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 5 deletions.
5 changes: 5 additions & 0 deletions test/common/assertSnapshot.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ function replaceWindowsPaths(str) {
return str.replaceAll(path.win32.sep, path.posix.sep);
}

function replaceFullPaths(str) {
return str.replaceAll(process.cwd(), '');
}

function transform(...args) {
return (str) => args.reduce((acc, fn) => fn(acc), str);
}
Expand Down Expand Up @@ -69,6 +73,7 @@ async function spawnAndAssert(filename, transform = (x) => x, { tty = false, ...
module.exports = {
assertSnapshot,
getSnapshotPath,
replaceFullPaths,
replaceStackTrace,
replaceWindowsLineEndings,
replaceWindowsPaths,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ ok 1 - this is a test
---
duration_ms: *
...
not ok 2 - /Users/rluvaton/dev/open-source/node/node-fork/test/fixtures/test-runner/output/global_after_should_fail_the_test.js
not ok 2 - /test/fixtures/test-runner/output/global_after_should_fail_the_test.js
---
duration_ms: *
failureType: 'hookFailed'
Expand Down
16 changes: 12 additions & 4 deletions test/parallel/test-runner-output.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,18 @@ function replaceSpecDuration(str) {
.replaceAll(/duration_ms [0-9.]+/g, 'duration_ms *')
.replace(stackTraceBasePath, '$3');
}
const defaultTransform = snapshot
.transform(snapshot.replaceWindowsLineEndings, snapshot.replaceStackTrace, replaceTestDuration);
const specTransform = snapshot
.transform(replaceSpecDuration, snapshot.replaceWindowsLineEndings, snapshot.replaceStackTrace);
const defaultTransform = snapshot.transform(
snapshot.replaceWindowsLineEndings,
snapshot.replaceStackTrace,
replaceTestDuration,
snapshot.replaceFullPaths
);
const specTransform = snapshot.transform(
replaceSpecDuration,
snapshot.replaceWindowsLineEndings,
snapshot.replaceStackTrace,
snapshot.replaceFullPaths
);


const tests = [
Expand Down

0 comments on commit dc7d333

Please sign in to comment.