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: nodejs#48959
Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
  • Loading branch information
aduh95 authored and pluris committed Aug 7, 2023
1 parent ab07873 commit ced6601
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 ced6601

Please sign in to comment.