Skip to content

Commit 5b175ce

Browse files
committed
fix windows
1 parent fba29c9 commit 5b175ce

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

test/common/assertSnapshot.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,16 @@ const assert = require('node:assert/strict');
66

77

88
const stackFramesRegexp = /(\s+)((.+?)\s+\()?(?:\(?(.+?):(\d+)(?::(\d+))?)\)?(\s+\{)?(\n|$)/g;
9+
const windowNewlineRegexp = /\r\n/g;
910

1011
function replaceStackTrace(str) {
1112
return str.replace(stackFramesRegexp, '$1*$7\n');
1213
}
1314

15+
function replaceWindowsLineEndings(str) {
16+
return str.replace(windowNewlineRegexp, '\n');
17+
}
18+
1419
function transform(...args) {
1520
return (str) => args.reduce((acc, fn) => fn(acc), str);
1621
}
@@ -42,6 +47,7 @@ module.exports = {
4247
assertSnapshot,
4348
getSnapshotPath,
4449
replaceStackTrace,
50+
replaceWindowsLineEndings,
4551
spawnAndAssert,
4652
transform,
4753
};

test/parallel/test-runner-output.mjs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ function replaceSpecDuration(str) {
1616
.replaceAll(/[0-9.]+ms/g, '*ms')
1717
.replaceAll(/duration_ms [0-9.]+/g, 'duration_ms *');
1818
}
19-
const defaultTransform = snapshot.transform(snapshot.replaceStackTrace, replaceTestDuration);
19+
const defaultTransform = snapshot
20+
.transform(snapshot.replaceWindowsLineEndings, snapshot.replaceStackTrace, replaceTestDuration);
2021

2122

2223
const tests = [
@@ -31,11 +32,11 @@ const tests = [
3132
{ name: 'test-runner/output/dot_reporter.js' },
3233
{
3334
name: 'test-runner/output/spec_reporter_successful.js',
34-
transform: snapshot.transform(snapshot.replaceStackTrace, replaceSpecDuration)
35+
transform: snapshot.transform(snapshot.replaceWindowsLineEndings, snapshot.replaceStackTrace, replaceSpecDuration)
3536
},
3637
{
3738
name: 'test-runner/output/spec_reporter.js',
38-
transform: snapshot.transform(snapshot.replaceStackTrace, replaceSpecDuration)
39+
transform: snapshot.transform(snapshot.replaceWindowsLineEndings, snapshot.replaceStackTrace, replaceSpecDuration)
3940
},
4041
{ name: 'test-runner/output/output.js' },
4142
{ name: 'test-runner/output/output_cli.js' },

0 commit comments

Comments
 (0)