Skip to content

Commit

Permalink
test: fix snapshot tests when cwd contains spaces or backslashes
Browse files Browse the repository at this point in the history
Both are valid characters for file names on non-Windows systems.

PR-URL: #48959
Reviewed-By: Moshe Atlow <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
  • Loading branch information
aduh95 authored and RafaelGSS committed Aug 17, 2023
1 parent 114e088 commit b4ca4a6
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions test/common/assertSnapshot.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const test = require('node:test');
const fs = require('node:fs/promises');
const assert = require('node:assert/strict');

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

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

function replaceWindowsPaths(str) {
return str.replaceAll(path.win32.sep, path.posix.sep);
return common.isWindows ? str.replaceAll(path.win32.sep, path.posix.sep) : str;
}

function transform(...args) {
Expand Down

0 comments on commit b4ca4a6

Please sign in to comment.