Skip to content
5 changes: 2 additions & 3 deletions lib/concordance-options.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import {inspect} from 'node:util';
import {inspect, stripVTControlCharacters} from 'node:util';

import ansiStyles from 'ansi-styles';
import {Chalk} from 'chalk'; // eslint-disable-line unicorn/import-style
import stripAnsi from 'strip-ansi';

import {chalk} from './chalk.js';

Expand Down Expand Up @@ -85,7 +84,7 @@ const colorTheme = {
undefined: ansiStyles.yellow,
};

const plainTheme = JSON.parse(JSON.stringify(colorTheme), (_name, value) => typeof value === 'string' ? stripAnsi(value) : value);
const plainTheme = JSON.parse(JSON.stringify(colorTheme), (_name, value) => typeof value === 'string' ? stripVTControlCharacters(value) : value);

const theme = chalk.level > 0 ? colorTheme : plainTheme;

Expand Down
10 changes: 5 additions & 5 deletions lib/reporters/tap.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import os from 'node:os';
import path from 'node:path';
import {stripVTControlCharacters} from 'node:util';

import indentString from 'indent-string';
import plur from 'plur';
import stripAnsi from 'strip-ansi';
import * as supertap from 'supertap';

import prefixTitle from './prefix-title.js';
Expand All @@ -20,7 +20,7 @@ function dumpError({
if (type === 'unknown') {
return {
message: 'Non-native error',
formatted: stripAnsi(formattedError),
formatted: stripVTControlCharacters(formattedError),
};
}

Expand All @@ -33,8 +33,8 @@ function dumpError({

if (formattedDetails.length > 0) {
originalError.details = Object.fromEntries(formattedDetails.map(({label, formatted}) => [
stripAnsi(label),
stripAnsi(formatted),
stripVTControlCharacters(label),
stripVTControlCharacters(formatted),
]));
}
}
Expand Down Expand Up @@ -119,7 +119,7 @@ export default class TapReporter {
}

writeComment(evt, {title = this.prefixTitle(evt.testFile, evt.title)}) {
this.reportStream.write(`# ${stripAnsi(title)}${os.EOL}`);
this.reportStream.write(`# ${stripVTControlCharacters(title)}${os.EOL}`);
if (evt.logs) {
for (const log of evt.logs) {
const logLines = indentString(log, 4).replaceAll(/^ {4}/gm, '# ');
Expand Down
1 change: 0 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 2 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,6 @@
"pretty-ms": "^9.2.0",
"resolve-cwd": "^3.0.0",
"stack-utils": "^2.0.6",
"strip-ansi": "^7.1.0",
"supertap": "^3.0.1",
"temp-dir": "^3.0.0",
"write-file-atomic": "^6.0.0",
Expand Down Expand Up @@ -153,7 +152,7 @@
}
},
"volta": {
"node": "22.16.0",
"npm": "11.4.1"
"node": "22.21.1",
"npm": "11.6.2"
}
}
6 changes: 3 additions & 3 deletions test-tap/assert.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import path from 'node:path';
import {fileURLToPath} from 'node:url';
import {stripVTControlCharacters} from 'node:util';

import stripAnsi from 'strip-ansi';
import {test} from 'tap';

import * as assert from '../lib/assert.js';
Expand Down Expand Up @@ -70,8 +70,8 @@ function assertFailure(t, subset) {
if (subset.formattedDetails) {
t.equal(lastFailure.formattedDetails.length, subset.formattedDetails.length);
for (const [i, s] of lastFailure.formattedDetails.entries()) {
t.equal(stripAnsi(s.label), subset.formattedDetails[i].label);
t.match(stripAnsi(s.formatted), subset.formattedDetails[i].formatted);
t.equal(stripVTControlCharacters(s.label), subset.formattedDetails[i].label);
t.match(stripVTControlCharacters(s.formatted), subset.formattedDetails[i].formatted);
}
} else {
t.same(lastFailure.formattedDetails, []);
Expand Down
6 changes: 3 additions & 3 deletions test-tap/integration/assorted.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import childProcess from 'node:child_process';
import fs from 'node:fs';
import path from 'node:path';
import {fileURLToPath} from 'node:url';
import {stripVTControlCharacters} from 'node:util';

import ciInfo from 'ci-info';
import stripAnsi from 'strip-ansi';
import {test} from 'tap';

import {execCli} from '../helper/cli.js';
Expand Down Expand Up @@ -82,15 +82,15 @@ test('tests without assertions do not fail if failWithoutAssertions option is se
test('--no-color disables formatting colors', t => {
execCli(['--no-color', 'formatting-color.cjs'], (error, stdout) => {
t.ok(error);
t.equal(stripAnsi(stdout), stdout);
t.equal(stripVTControlCharacters(stdout), stdout);
t.end();
});
});

test('--color enables formatting colors', t => {
execCli(['--color', 'formatting-color.cjs'], (error, stdout) => {
t.ok(error);
t.not(stripAnsi(stdout), stdout);
t.not(stripVTControlCharacters(stdout), stdout);
t.end();
});
});
Expand Down
18 changes: 4 additions & 14 deletions test/external-assertions/snapshots/test.js.md
Original file line number Diff line number Diff line change
Expand Up @@ -298,14 +298,9 @@ Generated by [AVA](https://avajs.dev).
Assertion failed: ␊
The expression evaluated to a falsy value:␊
assert.ok(false)␊
AssertionError [ERR_ASSERTION]: The expression evaluated to a falsy value:␊
assert.ok(false)␊
false == true␊
AssertionError [ERR_ASSERTION]: false == true␊
at ---␊
at ---␊
at ---␊
Expand Down Expand Up @@ -395,14 +390,9 @@ Generated by [AVA](https://avajs.dev).
Assertion failed: ␊
The expression evaluated to a falsy value:␊
assert.ok(false)␊
AssertionError [ERR_ASSERTION]: The expression evaluated to a falsy value:␊
assert.ok(false)␊
false == true␊
AssertionError [ERR_ASSERTION]: false == true␊
at ---␊
at ---␊
at ---␊
Expand Down
Binary file modified test/external-assertions/snapshots/test.js.snap
Binary file not shown.