Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
forked fromnodejs/node

Commitfc6fe0f

Browse files
GeoffreyBoothcodebytere
authored andcommitted
test: fix edge snapshot stack traces
PR-URL:nodejs#49659Reviewed-By: James M Snell <jasnell@gmail.com>Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
1 parenta0e60c1 commitfc6fe0f

File tree

4 files changed

+31
-20
lines changed

4 files changed

+31
-20
lines changed

‎test/common/assertSnapshot.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ const assert = require('node:assert/strict');
88
conststackFramesRegexp=/(\s+)((.+?)\s+\()?(?:\(?(.+?):(\d+)(?::(\d+))?)\)?(\s+\{)?(\[\d+m)?(\n|$)/g;
99
constwindowNewlineRegexp=/\r/g;
1010

11+
functionreplaceNodeVersion(str){
12+
returnstr.replaceAll(process.version,'*');
13+
}
14+
1115
functionreplaceStackTrace(str,replacement='$1*$7$8\n'){
1216
returnstr.replace(stackFramesRegexp,replacement);
1317
}
@@ -69,6 +73,7 @@ async function spawnAndAssert(filename, transform = (x) => x, { tty = false, ...
6973
module.exports={
7074
assertSnapshot,
7175
getSnapshotPath,
76+
replaceNodeVersion,
7277
replaceStackTrace,
7378
replaceWindowsLineEndings,
7479
replaceWindowsPaths,

‎test/fixtures/errors/force_colors.snapshot

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@ throw new Error('Should include grayed stack trace')
44

55
Error: Should include grayed stack trace
66
at Object.<anonymous> (/test*force_colors.js:1:7)
7-
 atModule._compile (node:internal*modules*cjs*loader:1256:14)
8-
 atModule._extensions..js (node:internal*modules*cjs*loader:1310:10)
9-
 atModule.load (node:internal*modules*cjs*loader:1119:32)
10-
 atModule._load (node:internal*modules*cjs*loader:960:12)
11-
 atFunction.executeUserEntryPoint [as runMain] (node:internal*modules*run_main:86:12)
12-
 atnode:internal*main*run_main_module:23:47
7+
 at*
8+
 at*
9+
 at*
10+
 at*
11+
 at*
12+
 at*
1313

1414
Node.js *

‎test/parallel/test-node-output-errors.mjs

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,15 @@ const skipForceColors =
1010
(common.isWindows&&(Number(os.release().split('.')[0])!==10||Number(os.release().split('.')[2])<14393));// See https://github.com/nodejs/node/pull/33132
1111

1212

13-
functionreplaceNodeVersion(str){
14-
returnstr.replaceAll(process.version,'*');
15-
}
16-
1713
functionreplaceStackTrace(str){
1814
returnsnapshot.replaceStackTrace(str,'$1at *$7\n');
1915
}
2016

17+
functionreplaceForceColorsStackTrace(str){
18+
// eslint-disable-next-line no-control-regex
19+
returnstr.replaceAll(/(\[90m\W+)at.*node:.*/g,'$1at *');
20+
}
21+
2122
describe('errors output',{concurrency:true},()=>{
2223
functionnormalize(str){
2324
returnstr.replaceAll(snapshot.replaceWindowsPaths(process.cwd()),'').replaceAll('//','*').replaceAll(/\/(\w)/g,'*$1').replaceAll('*test*','*').replaceAll('*fixtures*errors*','*').replaceAll('file:**','file:*/');
@@ -28,9 +29,12 @@ describe('errors output', { concurrency: true }, () => {
2829
}
2930
constcommon=snapshot
3031
.transform(snapshot.replaceWindowsLineEndings,snapshot.replaceWindowsPaths);
31-
constdefaultTransform=snapshot.transform(common,normalize,replaceNodeVersion);
32-
consterrTransform=snapshot.transform(common,normalizeNoNumbers,replaceNodeVersion);
33-
constpromiseTransform=snapshot.transform(common,replaceStackTrace,normalizeNoNumbers,replaceNodeVersion);
32+
constdefaultTransform=snapshot.transform(common,normalize,snapshot.replaceNodeVersion);
33+
consterrTransform=snapshot.transform(common,normalizeNoNumbers,snapshot.replaceNodeVersion);
34+
constpromiseTransform=snapshot.transform(common,replaceStackTrace,
35+
normalizeNoNumbers,snapshot.replaceNodeVersion);
36+
constforceColorsTransform=snapshot.transform(common,normalize,
37+
replaceForceColorsStackTrace,snapshot.replaceNodeVersion);
3438

3539
consttests=[
3640
{name:'errors/async_error_eval_cjs.js'},
@@ -50,7 +54,11 @@ describe('errors output', { concurrency: true }, () => {
5054
{name:'errors/throw_in_line_with_tabs.js',transform:errTransform},
5155
{name:'errors/throw_non_error.js',transform:errTransform},
5256
{name:'errors/promise_always_throw_unhandled.js',transform:promiseTransform},
53-
!skipForceColors ?{name:'errors/force_colors.js',env:{FORCE_COLOR:1}} :null,
57+
!skipForceColors ?{
58+
name:'errors/force_colors.js',
59+
transform:forceColorsTransform,
60+
env:{FORCE_COLOR:1}
61+
} :null,
5462
].filter(Boolean);
5563
for(const{ name, transform, env}oftests){
5664
it(name,async()=>{

‎test/parallel/test-node-output-sourcemaps.mjs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,6 @@ import * as snapshot from '../common/assertSnapshot.js';
44
import*aspathfrom'node:path';
55
import{describe,it}from'node:test';
66

7-
functionreplaceNodeVersion(str){
8-
returnstr.replaceAll(process.version,'*');
9-
}
10-
117
describe('sourcemaps output',{concurrency:true},()=>{
128
functionnormalize(str){
139
constresult=str
@@ -16,7 +12,8 @@ describe('sourcemaps output', { concurrency: true }, () => {
1612
.replaceAll('/Users/bencoe/oss/coffee-script-test','')
1713
.replaceAll(/\/(\w)/g,'*$1')
1814
.replaceAll('*test*','*')
19-
.replaceAll('*fixtures*source-map*','*');
15+
.replaceAll('*fixtures*source-map*','*')
16+
.replaceAll(/(\W+).*node:internal\*modules.*/g,'$1*');
2017
if(common.isWindows){
2118
constcurrentDeviceLetter=path.parse(process.cwd()).root.substring(0,1).toLowerCase();
2219
constregex=newRegExp(`${currentDeviceLetter}:/?`,'gi');
@@ -25,7 +22,8 @@ describe('sourcemaps output', { concurrency: true }, () => {
2522
returnresult;
2623
}
2724
constdefaultTransform=snapshot
28-
.transform(snapshot.replaceWindowsLineEndings,snapshot.replaceWindowsPaths,normalize,replaceNodeVersion);
25+
.transform(snapshot.replaceWindowsLineEndings,snapshot.replaceWindowsPaths,
26+
normalize,snapshot.replaceNodeVersion);
2927

3028
consttests=[
3129
{name:'source-map/output/source_map_disabled_by_api.js'},

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp