Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: fix output tests when path includes node version #47843

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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