From dc7d3337301fda102f2d06930d9c8a371bd3139f Mon Sep 17 00:00:00 2001 From: Raz Luvaton <16746759+rluvaton@users.noreply.github.com> Date: Wed, 26 Jul 2023 01:13:07 +0300 Subject: [PATCH] fix test --- test/common/assertSnapshot.js | 5 +++++ .../global_after_should_fail_the_test.snapshot | 2 +- test/parallel/test-runner-output.mjs | 16 ++++++++++++---- 3 files changed, 18 insertions(+), 5 deletions(-) diff --git a/test/common/assertSnapshot.js b/test/common/assertSnapshot.js index c403751ac3ef5e..d43c54eff55f32 100644 --- a/test/common/assertSnapshot.js +++ b/test/common/assertSnapshot.js @@ -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); } @@ -69,6 +73,7 @@ async function spawnAndAssert(filename, transform = (x) => x, { tty = false, ... module.exports = { assertSnapshot, getSnapshotPath, + replaceFullPaths, replaceStackTrace, replaceWindowsLineEndings, replaceWindowsPaths, diff --git a/test/fixtures/test-runner/output/global_after_should_fail_the_test.snapshot b/test/fixtures/test-runner/output/global_after_should_fail_the_test.snapshot index 16e92b0e2b80c5..db513691f4b781 100644 --- a/test/fixtures/test-runner/output/global_after_should_fail_the_test.snapshot +++ b/test/fixtures/test-runner/output/global_after_should_fail_the_test.snapshot @@ -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' diff --git a/test/parallel/test-runner-output.mjs b/test/parallel/test-runner-output.mjs index bbffa4d794099a..8bd88efb3265f7 100644 --- a/test/parallel/test-runner-output.mjs +++ b/test/parallel/test-runner-output.mjs @@ -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 = [