test_runner: fix global after not failing the tests

PR-URL: https://github.com/nodejs/node/pull/48913
Backport-PR-URL: https://github.com/nodejs/node/pull/49225
Fixes: https://github.com/nodejs/node/issues/48867
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
Reviewed-By: Chemi Atlow <chemi@atlow.co.il>
This commit is contained in:
Raz Luvaton authored and Ulises Gascón committed 2023-09-10 18:03:28 +00:00
1 parent 08738b2664
commit 4bc0a8fe99
6 files changed
+103 -34

No files matched your search

+22 -4
View File
@@ -24,10 +24,27 @@ 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);
function removeWindowsPathEscaping(str) {
return common.isWindows ? str.replaceAll(/\\\\/g, '\\') : str;
}
const defaultTransform = snapshot.transform(
snapshot.replaceWindowsLineEndings,
snapshot.replaceStackTrace,
replaceTestDuration,
);
const specTransform = snapshot.transform(
replaceSpecDuration,
snapshot.replaceWindowsLineEndings,
snapshot.replaceStackTrace,
);
const withFileNameTransform = snapshot.transform(
defaultTransform,
removeWindowsPathEscaping,
snapshot.replaceFullPaths,
snapshot.replaceWindowsPaths,
);
const tests = [
@@ -41,6 +58,7 @@ const tests = [
{ name: 'test-runner/output/hooks-with-no-global-test.js' },
{ name: 'test-runner/output/before-and-after-each-too-many-listeners.js' },
{ name: 'test-runner/output/before-and-after-each-with-timeout-too-many-listeners.js' },
{ name: 'test-runner/output/global_after_should_fail_the_test.js', transform: withFileNameTransform },
{ name: 'test-runner/output/no_refs.js' },
{ name: 'test-runner/output/no_tests.js' },
{ name: 'test-runner/output/only_tests.js' },