Skip to content

Commit

Permalink
test: fix output tests when path includes node version
Browse files Browse the repository at this point in the history
PR-URL: nodejs#47843
Reviewed-By: Michaël Zasso <[email protected]>
Reviewed-By: Benjamin Gruenbaum <[email protected]>
  • Loading branch information
MoLow committed Jul 6, 2023
1 parent e2553b1 commit 1b84e85
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 12 deletions.
9 changes: 3 additions & 6 deletions test/parallel/test-node-output-console.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,14 @@ import * as fixtures from '../common/fixtures.mjs';
import * as snapshot from '../common/assertSnapshot.js';
import { describe, it } from 'node:test';

function replaceNodeVersion(str) {
return str.replaceAll(process.version, '*');
}

function replaceStackTrace(str) {
return snapshot.replaceStackTrace(str, '$1at *$7\n');
}

describe('console output', { concurrency: true }, () => {
function stackTrace(str) {
return str.replaceAll(snapshot.replaceWindowsPaths(process.cwd()), '').replaceAll('/', '*').replaceAll(/\d+/g, '*');
function normalize(str) {
return str.replaceAll(snapshot.replaceWindowsPaths(process.cwd()), '').replaceAll('/', '*').replaceAll(process.version, '*').replaceAll(/\d+/g, '*');
}
const tests = [
{ name: 'console/2100bytes.js' },
Expand All @@ -23,7 +20,7 @@ describe('console output', { concurrency: true }, () => {
{
name: 'console/stack_overflow.js',
transform: snapshot
.transform(snapshot.replaceWindowsLineEndings, snapshot.replaceWindowsPaths, replaceNodeVersion, stackTrace)
.transform(snapshot.replaceWindowsLineEndings, snapshot.replaceWindowsPaths, normalize)
},
];
const defaultTransform = snapshot
Expand Down
8 changes: 4 additions & 4 deletions test/parallel/test-node-output-errors.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ describe('errors output', { concurrency: true }, () => {
return normalize(str).replaceAll(/\d+:\d+/g, '*:*').replaceAll(/:\d+/g, ':*').replaceAll('*fixtures*message*', '*');
}
const common = snapshot
.transform(snapshot.replaceWindowsLineEndings, snapshot.replaceWindowsPaths, replaceNodeVersion);
const defaultTransform = snapshot.transform(common, normalize);
const errTransform = snapshot.transform(common, normalizeNoNumbers);
const promiseTransform = snapshot.transform(common, replaceStackTrace, normalizeNoNumbers);
.transform(snapshot.replaceWindowsLineEndings, snapshot.replaceWindowsPaths);
const defaultTransform = snapshot.transform(common, normalize, replaceNodeVersion);
const errTransform = snapshot.transform(common, normalizeNoNumbers, replaceNodeVersion);
const promiseTransform = snapshot.transform(common, replaceStackTrace, normalizeNoNumbers, replaceNodeVersion);

const tests = [
{ name: 'errors/async_error_eval_cjs.js' },
Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-node-output-sourcemaps.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ describe('sourcemaps output', { concurrency: true }, () => {
return result;
}
const defaultTransform = snapshot
.transform(snapshot.replaceWindowsLineEndings, snapshot.replaceWindowsPaths, replaceNodeVersion, normalize);
.transform(snapshot.replaceWindowsLineEndings, snapshot.replaceWindowsPaths, normalize, replaceNodeVersion);

const tests = [
{ name: 'source-map/output/source_map_disabled_by_api.js' },
Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-node-output-vm.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ describe('vm output', { concurrency: true }, () => {
}

const defaultTransform = snapshot
.transform(snapshot.replaceWindowsLineEndings, snapshot.replaceWindowsPaths, replaceNodeVersion, normalize);
.transform(snapshot.replaceWindowsLineEndings, snapshot.replaceWindowsPaths, normalize, replaceNodeVersion);

const tests = [
{ name: 'vm/vm_caught_custom_runtime_error.js' },
Expand Down

0 comments on commit 1b84e85

Please sign in to comment.