Skip to content

Commit

Permalink
fixup! test: do not assume cwd in snapshot tests
Browse files Browse the repository at this point in the history
  • Loading branch information
aduh95 committed May 25, 2024
1 parent fa11503 commit e0ca0aa
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions test/parallel/test-runner-output.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import * as fixtures from '../common/fixtures.mjs';
import * as snapshot from '../common/assertSnapshot.js';
import { describe, it } from 'node:test';
import { hostname } from 'node:os';
import { chdir } from 'node:process';
import { chdir, cwd } from 'node:process';
import { fileURLToPath } from 'node:url';

const skipForceColors =
Expand All @@ -16,7 +16,7 @@ function replaceTestDuration(str) {
.replaceAll(/duration_ms [0-9.]+/g, 'duration_ms *');
}

const root = fileURLToPath(new URL('../..', import.meta.url));
const root = fileURLToPath(new URL('../..', import.meta.url)).slice(0, -1);

const color = '(\\[\\d+m)';
const stackTraceBasePath = new RegExp(`${color}\\(${root.replaceAll(/[\\^$*+?.()|[\]{}]/g, '\\$&')}/?${color}(.*)${color}\\)`, 'g');
Expand Down Expand Up @@ -155,7 +155,9 @@ const tests = [
}),
}));

chdir(root);
if (cwd() !== root) {
chdir(root);
}
describe('test runner output', { concurrency: true }, () => {
for (const { name, fn } of tests) {
it(name, fn);
Expand Down

0 comments on commit e0ca0aa

Please sign in to comment.