Skip to content

Commit b4ca4a6

Browse files
aduh95RafaelGSS
authored andcommitted
test: fix snapshot tests when cwd contains spaces or backslashes
Both are valid characters for file names on non-Windows systems. PR-URL: #48959 Reviewed-By: Moshe Atlow <moshe@atlow.co.il> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
1 parent 114e088 commit b4ca4a6

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

test/common/assertSnapshot.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ const test = require('node:test');
55
const fs = require('node:fs/promises');
66
const assert = require('node:assert/strict');
77

8-
const stackFramesRegexp = /(\s+)((.+?)\s+\()?(?:\(?(.+?):(\d+)(?::(\d+))?)\)?(\s+\{)?(\[\d+m)?(\n|$)/g;
8+
const stackFramesRegexp = /(?<=\n)(\s+)((.+?)\s+\()?(?:\(?(.+?):(\d+)(?::(\d+))?)\)?(\s+\{)?(\[\d+m)?(\n|$)/g;
99
const windowNewlineRegexp = /\r/g;
1010

1111
function replaceStackTrace(str, replacement = '$1*$7$8\n') {
@@ -17,7 +17,7 @@ function replaceWindowsLineEndings(str) {
1717
}
1818

1919
function replaceWindowsPaths(str) {
20-
return str.replaceAll(path.win32.sep, path.posix.sep);
20+
return common.isWindows ? str.replaceAll(path.win32.sep, path.posix.sep) : str;
2121
}
2222

2323
function transform(...args) {

0 commit comments

Comments
 (0)