diff --git a/lib/concordance-options.js b/lib/concordance-options.js index 3e5fbf4be..141cba7f8 100644 --- a/lib/concordance-options.js +++ b/lib/concordance-options.js @@ -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'; @@ -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; diff --git a/lib/reporters/tap.js b/lib/reporters/tap.js index 258c927fc..21878d6d6 100644 --- a/lib/reporters/tap.js +++ b/lib/reporters/tap.js @@ -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'; @@ -20,7 +20,7 @@ function dumpError({ if (type === 'unknown') { return { message: 'Non-native error', - formatted: stripAnsi(formattedError), + formatted: stripVTControlCharacters(formattedError), }; } @@ -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), ])); } } @@ -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, '# '); diff --git a/package-lock.json b/package-lock.json index fe4112682..e735c84df 100644 --- a/package-lock.json +++ b/package-lock.json @@ -44,7 +44,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", diff --git a/package.json b/package.json index dfa0b63e1..1f4e1cf91 100644 --- a/package.json +++ b/package.json @@ -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", @@ -153,7 +152,7 @@ } }, "volta": { - "node": "22.16.0", - "npm": "11.4.1" + "node": "22.21.1", + "npm": "11.6.2" } } diff --git a/test-tap/assert.js b/test-tap/assert.js index 9f47de960..ae0fd3bac 100644 --- a/test-tap/assert.js +++ b/test-tap/assert.js @@ -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'; @@ -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, []); diff --git a/test-tap/integration/assorted.js b/test-tap/integration/assorted.js index 694b47c6f..91cefff66 100644 --- a/test-tap/integration/assorted.js +++ b/test-tap/integration/assorted.js @@ -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'; @@ -82,7 +82,7 @@ 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(); }); }); @@ -90,7 +90,7 @@ test('--no-color disables formatting colors', t => { 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(); }); }); diff --git a/test/external-assertions/snapshots/test.js.md b/test/external-assertions/snapshots/test.js.md index 7d97da549..174c6b260 100644 --- a/test/external-assertions/snapshots/test.js.md +++ b/test/external-assertions/snapshots/test.js.md @@ -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 ---␊ @@ -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 ---␊ diff --git a/test/external-assertions/snapshots/test.js.snap b/test/external-assertions/snapshots/test.js.snap index 52bc4f0fb..3b34f8e5b 100644 Binary files a/test/external-assertions/snapshots/test.js.snap and b/test/external-assertions/snapshots/test.js.snap differ