Skip to content

Commit a6957a1

Browse files
committed
fixup! test: unify assertSnapshot stacktrace transform
1 parent c2dc969 commit a6957a1

1 file changed

Lines changed: 6 additions & 6 deletions

File tree

test/common/assertSnapshot.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,12 @@ function replaceWindowsLineEndings(str) {
7474
// Replaces all Windows path separators with posix separators for unified snapshots
7575
// across platforms.
7676
function replaceWindowsPaths(str) {
77-
return common.isWindows ? str.replaceAll(path.win32.sep, path.posix.sep) : str;
77+
if (!common.isWindows) {
78+
return str;
79+
}
80+
// Only replace `\` and `\\` with a leading letter, colon, or a `.`.
81+
// Avoid replacing escaping patterns like ` \#`, `\ `, or `\\`.
82+
return str.replaceAll(/(?<=(\w:|\.|\w+)(?:\S|\\ )*)\\\\?/g, '/');
7883
}
7984

8085
// Removes line trailing white spaces.
@@ -224,10 +229,6 @@ function replaceJunitDuration(str) {
224229
.replaceAll(/file="[^"]*"/g, 'file="*"');
225230
}
226231

227-
function removeWindowsPathEscaping(str) {
228-
return common.isWindows ? str.replaceAll(/\\\\/g, '\\') : str;
229-
}
230-
231232
// The Node test coverage returns results for all files called by the test. This
232233
// will make the output file change if files like test/common/index.js change.
233234
// This transform picks only the first line and then the lines from the test
@@ -254,7 +255,6 @@ function pickTestFileFromLcov(str) {
254255
const basicTransform = transform(
255256
replaceWindowsLineEndings,
256257
replaceTrailingSpaces,
257-
removeWindowsPathEscaping,
258258
replaceWindowsPaths,
259259
replaceNodeVersion,
260260
generalizeExeName,

0 commit comments

Comments
 (0)