diff --git a/test/eslint.config_partial.mjs b/test/eslint.config_partial.mjs index bd54c481a19be8..c972e4de13d5ed 100644 --- a/test/eslint.config_partial.mjs +++ b/test/eslint.config_partial.mjs @@ -195,7 +195,7 @@ export default [ `test/parallel/test-{${ // 0x61 is code for 'a', this generates a string enumerating latin letters: 'a*,b*,…' Array.from({ length: 13 }, (_, i) => String.fromCharCode(0x61 + i, 42)).join(',') - },n*,${ + },n*,r*,${ // 0x61 is code for 'a', this generates a string enumerating latin letters: 'z*,y*,…' Array.from({ length: 8 }, (_, i) => String.fromCharCode(0x61 + 25 - i, 42)).join(',') }}.{js,mjs,cjs}`, diff --git a/test/parallel/test-readable-from-iterator-closing.js b/test/parallel/test-readable-from-iterator-closing.js index 02252ffe56854c..ff2746dc4601ea 100644 --- a/test/parallel/test-readable-from-iterator-closing.js +++ b/test/parallel/test-readable-from-iterator-closing.js @@ -2,7 +2,7 @@ const { mustCall, mustNotCall } = require('../common'); const { Readable } = require('stream'); -const { strictEqual } = require('assert'); +const assert = require('assert'); async function asyncSupport() { const finallyMustCall = mustCall(); @@ -20,7 +20,7 @@ async function asyncSupport() { for await (const chunk of stream) { bodyMustCall(); - strictEqual(chunk, 'a'); + assert.strictEqual(chunk, 'a'); break; } } @@ -41,7 +41,7 @@ async function syncSupport() { for await (const chunk of stream) { bodyMustCall(); - strictEqual(chunk, 'a'); + assert.strictEqual(chunk, 'a'); break; } } @@ -66,7 +66,7 @@ async function syncPromiseSupport() { for await (const chunk of stream) { bodyMustCall(); - strictEqual(chunk, 'a'); + assert.strictEqual(chunk, 'a'); break; } } @@ -130,7 +130,6 @@ async function noReturnAfterThrow() { async function closeStreamWhileNextIsPending() { const finallyMustCall = mustCall(); - const dataMustCall = mustCall(); let resolveDestroy; const destroyed = @@ -153,10 +152,9 @@ async function closeStreamWhileNextIsPending() { const stream = Readable.from(infiniteGenerate()); - stream.on('data', (data) => { - dataMustCall(); - strictEqual(data, 'a'); - }); + stream.on('data', mustCall((data) => { + assert.strictEqual(data, 'a'); + })); yielded.then(() => { stream.destroy(); @@ -166,7 +164,6 @@ async function closeStreamWhileNextIsPending() { async function closeAfterNullYielded() { const finallyMustCall = mustCall(); - const dataMustCall = mustCall(3); function* generate() { try { @@ -180,10 +177,9 @@ async function closeAfterNullYielded() { const stream = Readable.from(generate()); - stream.on('data', (chunk) => { - dataMustCall(); - strictEqual(chunk, 'a'); - }); + stream.on('data', mustCall((chunk) => { + assert.strictEqual(chunk, 'a'); + }, 3)); } Promise.all([ diff --git a/test/parallel/test-readable-from-web-enqueue-then-close.js b/test/parallel/test-readable-from-web-enqueue-then-close.js index e96df70c9eb9d1..67b861596741b2 100644 --- a/test/parallel/test-readable-from-web-enqueue-then-close.js +++ b/test/parallel/test-readable-from-web-enqueue-then-close.js @@ -1,7 +1,7 @@ 'use strict'; const { mustCall } = require('../common'); const { Readable, Duplex } = require('stream'); -const { strictEqual } = require('assert'); +const assert = require('assert'); function start(controller) { controller.enqueue(new Uint8Array(1)); @@ -10,7 +10,7 @@ function start(controller) { Readable.fromWeb(new ReadableStream({ start })) .on('data', mustCall((d) => { - strictEqual(d.length, 1); + assert.strictEqual(d.length, 1); })) .on('end', mustCall()) .resume(); @@ -20,7 +20,7 @@ Duplex.fromWeb({ writable: new WritableStream({ write(chunk) {} }) }) .on('data', mustCall((d) => { - strictEqual(d.length, 1); + assert.strictEqual(d.length, 1); })) .on('end', mustCall()) .resume(); diff --git a/test/parallel/test-readable-from.js b/test/parallel/test-readable-from.js index b844574dc9e347..1d812ade3f23e6 100644 --- a/test/parallel/test-readable-from.js +++ b/test/parallel/test-readable-from.js @@ -3,11 +3,11 @@ const { mustCall } = require('../common'); const { once } = require('events'); const { Readable } = require('stream'); -const { strictEqual, throws } = require('assert'); +const assert = require('assert'); const common = require('../common'); { - throws(() => { + assert.throws(() => { Readable.from(null); }, /ERR_INVALID_ARG_TYPE/); } @@ -24,7 +24,7 @@ async function toReadableBasicSupport() { const expected = ['a', 'b', 'c']; for await (const chunk of stream) { - strictEqual(chunk, expected.shift()); + assert.strictEqual(chunk, expected.shift()); } } @@ -40,7 +40,7 @@ async function toReadableSyncIterator() { const expected = ['a', 'b', 'c']; for await (const chunk of stream) { - strictEqual(chunk, expected.shift()); + assert.strictEqual(chunk, expected.shift()); } } @@ -56,7 +56,7 @@ async function toReadablePromises() { const expected = ['a', 'b', 'c']; for await (const chunk of stream) { - strictEqual(chunk, expected.shift()); + assert.strictEqual(chunk, expected.shift()); } } @@ -66,7 +66,7 @@ async function toReadableString() { const expected = ['abc']; for await (const chunk of stream) { - strictEqual(chunk, expected.shift()); + assert.strictEqual(chunk, expected.shift()); } } @@ -76,7 +76,7 @@ async function toReadableBuffer() { const expected = ['abc']; for await (const chunk of stream) { - strictEqual(chunk.toString(), expected.shift()); + assert.strictEqual(chunk.toString(), expected.shift()); } } @@ -92,14 +92,14 @@ async function toReadableOnData() { let iterations = 0; const expected = ['a', 'b', 'c']; - stream.on('data', (chunk) => { + stream.on('data', common.mustCallAtLeast((chunk) => { iterations++; - strictEqual(chunk, expected.shift()); - }); + assert.strictEqual(chunk, expected.shift()); + })); await once(stream, 'end'); - strictEqual(iterations, 3); + assert.strictEqual(iterations, 3); } async function toReadableOnDataNonObject() { @@ -114,15 +114,15 @@ async function toReadableOnDataNonObject() { let iterations = 0; const expected = ['a', 'b', 'c']; - stream.on('data', (chunk) => { + stream.on('data', common.mustCallAtLeast((chunk) => { iterations++; - strictEqual(chunk instanceof Buffer, true); - strictEqual(chunk.toString(), expected.shift()); - }); + assert.strictEqual(chunk instanceof Buffer, true); + assert.strictEqual(chunk.toString(), expected.shift()); + })); await once(stream, 'end'); - strictEqual(iterations, 3); + assert.strictEqual(iterations, 3); } async function destroysTheStreamWhenThrowing() { @@ -135,8 +135,8 @@ async function destroysTheStreamWhenThrowing() { stream.read(); const [err] = await once(stream, 'error'); - strictEqual(err.message, 'kaboom'); - strictEqual(stream.destroyed, true); + assert.strictEqual(err.message, 'kaboom'); + assert.strictEqual(stream.destroyed, true); } @@ -162,7 +162,7 @@ async function asTransformStream() { const expected = ['A', 'B', 'C']; for await (const chunk of stream) { - strictEqual(chunk, expected.shift()); + assert.strictEqual(chunk, expected.shift()); } } @@ -179,18 +179,18 @@ async function endWithError() { try { for await (const chunk of stream) { - strictEqual(chunk, expected.shift()); + assert.strictEqual(chunk, expected.shift()); } throw new Error(); } catch (err) { - strictEqual(expected.length, 0); - strictEqual(err, 'Boum'); + assert.strictEqual(expected.length, 0); + assert.strictEqual(err, 'Boum'); } } async function destroyingStreamWithErrorThrowsInGenerator() { const validateError = common.mustCall((e) => { - strictEqual(e, 'Boum'); + assert.strictEqual(e, 'Boum'); }); async function* generate() { try { diff --git a/test/parallel/test-readline-interface.js b/test/parallel/test-readline-interface.js index c640654a7c742d..af18a5c32d3702 100644 --- a/test/parallel/test-readline-interface.js +++ b/test/parallel/test-readline-interface.js @@ -284,10 +284,10 @@ function assertCursorRowsAndCols(rli, rows, cols) { const expectedLines = ['foo', 'bar', 'baz', 'bar', 'bat', 'bat']; // ['foo', 'baz', 'bar', bat']; let callCount = 0; - rli.on('line', (line) => { + rli.on('line', common.mustCallAtLeast((line) => { assert.strictEqual(line, expectedLines[callCount]); callCount++; - }); + })); fi.emit('data', `${expectedLines.join('\n')}\n`); assert.strictEqual(callCount, expectedLines.length); fi.emit('keypress', '.', { name: 'up' }); // 'bat' @@ -360,10 +360,10 @@ function assertCursorRowsAndCols(rli, rows, cols) { }); const expectedLines = ['foo', 'bar', 'baz', 'bar', 'bat', 'bat']; let callCount = 0; - rli.on('line', (line) => { + rli.on('line', common.mustCallAtLeast((line) => { assert.strictEqual(line, expectedLines[callCount]); callCount++; - }); + })); fi.emit('data', `${expectedLines.join('\n')}\n`); assert.strictEqual(callCount, expectedLines.length); fi.emit('keypress', '.', { name: 'up' }); // 'bat' @@ -968,10 +968,10 @@ for (let i = 0; i < 12; i++) { { const [rli, fi] = getInterface({ terminal }); let called = false; - rli.on('line', (line) => { + rli.on('line', common.mustCallAtLeast((line) => { called = true; assert.strictEqual(line, 'a'); - }); + })); fi.emit('data', 'a'); assert.ok(!called); fi.emit('data', '\n'); @@ -1020,10 +1020,10 @@ for (let i = 0; i < 12; i++) { const buf = Buffer.from('☮', 'utf8'); const [rli, fi] = getInterface({ terminal }); let callCount = 0; - rli.on('line', (line) => { + rli.on('line', common.mustCallAtLeast((line) => { callCount++; assert.strictEqual(line, buf.toString('utf8')); - }); + })); for (const i of buf) { fi.emit('data', Buffer.from([i])); } diff --git a/test/parallel/test-readline-keys.js b/test/parallel/test-readline-keys.js index 28b5846d4eb58f..4379193b82f1ed 100644 --- a/test/parallel/test-readline-keys.js +++ b/test/parallel/test-readline-keys.js @@ -49,9 +49,9 @@ function addTest(sequences, expectedKeys) { // (addKeyIntervalTest(..)(noop)))() // where noop is a terminal function(() => {}). -const addKeyIntervalTest = (sequences, expectedKeys, interval = 550, - assertDelay = 550) => { - const fn = common.mustCall((next) => () => { +function addKeyIntervalTest(sequences, expectedKeys, interval = 550, + assertDelay = 550) { + const fn = common.mustCall((next) => common.mustCall(() => { if (!Array.isArray(sequences)) { sequences = [ sequences ]; @@ -66,21 +66,21 @@ const addKeyIntervalTest = (sequences, expectedKeys, interval = 550, const keys = []; fi.on('keypress', (s, k) => keys.push(k)); - const emitKeys = ([head, ...tail]) => { + const emitKeys = common.mustCallAtLeast(([head, ...tail]) => { if (head) { fi.write(head); setTimeout(() => emitKeys(tail), interval); } else { - setTimeout(() => { + setTimeout(common.mustCall(() => { next(); assert.deepStrictEqual(keys, expectedKeys); - }, assertDelay); + }), assertDelay); } - }; + }); emitKeys(sequences); - }); + })); return fn; -}; +} // Regular alphanumerics addTest('io.JS', [ diff --git a/test/parallel/test-readline-promises-interface.js b/test/parallel/test-readline-promises-interface.js index 12d72f49735401..19c445572b9806 100644 --- a/test/parallel/test-readline-promises-interface.js +++ b/test/parallel/test-readline-promises-interface.js @@ -261,10 +261,10 @@ function assertCursorRowsAndCols(rli, rows, cols) { const expectedLines = ['foo', 'bar', 'baz', 'bar', 'bat', 'bat']; // ['foo', 'baz', 'bar', bat']; let callCount = 0; - rli.on('line', function(line) { + rli.on('line', common.mustCallAtLeast((line) => { assert.strictEqual(line, expectedLines[callCount]); callCount++; - }); + })); fi.emit('data', `${expectedLines.join('\n')}\n`); assert.strictEqual(callCount, expectedLines.length); fi.emit('keypress', '.', { name: 'up' }); // 'bat' @@ -337,10 +337,10 @@ function assertCursorRowsAndCols(rli, rows, cols) { }); const expectedLines = ['foo', 'bar', 'baz', 'bar', 'bat', 'bat']; let callCount = 0; - rli.on('line', function(line) { + rli.on('line', common.mustCallAtLeast((line) => { assert.strictEqual(line, expectedLines[callCount]); callCount++; - }); + })); fi.emit('data', `${expectedLines.join('\n')}\n`); assert.strictEqual(callCount, expectedLines.length); fi.emit('keypress', '.', { name: 'up' }); // 'bat' @@ -840,10 +840,10 @@ for (let i = 0; i < 12; i++) { { const [rli, fi] = getInterface({ terminal }); let called = false; - rli.on('line', (line) => { + rli.on('line', common.mustCallAtLeast((line) => { called = true; assert.strictEqual(line, 'a'); - }); + })); fi.emit('data', 'a'); assert.ok(!called); fi.emit('data', '\n'); @@ -892,10 +892,10 @@ for (let i = 0; i < 12; i++) { const buf = Buffer.from('☮', 'utf8'); const [rli, fi] = getInterface({ terminal }); let callCount = 0; - rli.on('line', function(line) { + rli.on('line', common.mustCallAtLeast((line) => { callCount++; assert.strictEqual(line, buf.toString('utf8')); - }); + })); for (const i of buf) { fi.emit('data', Buffer.from([i])); } diff --git a/test/parallel/test-readline-promises-tab-complete.js b/test/parallel/test-readline-promises-tab-complete.js index 602bdd9e7965bf..13c2c905a9796d 100644 --- a/test/parallel/test-readline-promises-tab-complete.js +++ b/test/parallel/test-readline-promises-tab-complete.js @@ -75,10 +75,10 @@ if (process.env.TERM === 'dumb') { rli.on('line', common.mustNotCall()); for (const character of `${char}\t\t`) { fi.emit('data', character); - queueMicrotask(() => { + queueMicrotask(common.mustCall(() => { assert.strictEqual(output, expectations.shift()); output = ''; - }); + })); } fi.end(); }); @@ -110,9 +110,9 @@ if (process.env.TERM === 'dumb') { rli.on('line', common.mustNotCall()); fi.emit('data', '\t'); - queueMicrotask(() => { + queueMicrotask(common.mustCall(() => { assert.match(output, /^Tab completion error: Error: message/); output = ''; - }); + })); fi.end(); } diff --git a/test/parallel/test-readline-set-raw-mode.js b/test/parallel/test-readline-set-raw-mode.js index de47d14b03de8a..57015077781fd0 100644 --- a/test/parallel/test-readline-set-raw-mode.js +++ b/test/parallel/test-readline-set-raw-mode.js @@ -20,7 +20,7 @@ // USE OR OTHER DEALINGS IN THE SOFTWARE. 'use strict'; -require('../common'); +const common = require('../common'); const assert = require('assert'); const readline = require('readline'); const Stream = require('stream'); @@ -31,10 +31,10 @@ let rawModeCalled = false; let resumeCalled = false; let pauseCalled = false; -stream.setRawMode = function(mode) { +stream.setRawMode = common.mustCallAtLeast(function(mode) { rawModeCalled = true; assert.strictEqual(mode, expectedRawMode); -}; +}); stream.resume = function() { resumeCalled = true; }; diff --git a/test/parallel/test-readline-tab-complete.js b/test/parallel/test-readline-tab-complete.js index 5b7b19102f412a..83b5da349d0d06 100644 --- a/test/parallel/test-readline-tab-complete.js +++ b/test/parallel/test-readline-tab-complete.js @@ -96,10 +96,10 @@ if (process.env.TERM === 'dumb') { rli.on('line', common.mustNotCall()); fi.emit('data', '\t'); - queueMicrotask(() => { + queueMicrotask(common.mustCall(() => { assert.match(output, /^Tab completion error: Error: message/); output = ''; - }); + })); rli.close(); } @@ -129,12 +129,12 @@ if (process.env.TERM === 'dumb') { rli.on('line', common.mustNotCall()); fi.emit('data', 'input'); - queueMicrotask(() => { + queueMicrotask(common.mustCall(() => { fi.emit('data', '\t'); - queueMicrotask(() => { + queueMicrotask(common.mustCall(() => { assert.match(output, /> Input/); output = ''; rli.close(); - }); - }); + })); + })); } diff --git a/test/parallel/test-release-changelog.js b/test/parallel/test-release-changelog.js index c78efeeff0cf68..6b8e6ece43af52 100644 --- a/test/parallel/test-release-changelog.js +++ b/test/parallel/test-release-changelog.js @@ -7,12 +7,12 @@ const assert = require('assert'); const fs = require('fs'); const path = require('path'); -const getDefine = (text, name) => { +const getDefine = common.mustCallAtLeast((text, name) => { const regexp = new RegExp(`#define\\s+${RegExp.escape(name)}\\s+(.*)`); const match = regexp.exec(text); assert.notStrictEqual(match, null); return match[1]; -}; +}); const srcRoot = path.join(__dirname, '..', '..'); const mainChangelogFile = path.join(srcRoot, 'CHANGELOG.md'); diff --git a/test/parallel/test-repl-autocomplete.js b/test/parallel/test-repl-autocomplete.js index a68322c501e264..de801a8e12f095 100644 --- a/test/parallel/test-repl-autocomplete.js +++ b/test/parallel/test-repl-autocomplete.js @@ -152,7 +152,7 @@ function runTest() { REPL.createInternalRepl(opts.env, { input: new ActionStream(), output: new stream.Writable({ - write(chunk, _, next) { + write: common.mustCallAtLeast((chunk, _, next) => { const output = chunk.toString(); if (!opts.showEscapeCodes && @@ -177,7 +177,7 @@ function runTest() { } next(); - } + }), }), allowBlockingCompletions: true, completer: opts.completer, @@ -185,13 +185,13 @@ function runTest() { useColors: false, preview: opts.preview, terminal: true - }, function(err, repl) { + }, common.mustCall((err, repl) => { if (err) { console.error(`Failed test # ${numtests - tests.length}`); throw err; } - repl.once('close', () => { + repl.once('close', common.mustCall(() => { if (opts.clean) cleanupTmpFile(); @@ -203,7 +203,7 @@ function runTest() { } setImmediate(runTestWrap, true); - }); + })); if (opts.columns) { Object.defineProperty(repl, 'columns', { @@ -212,7 +212,7 @@ function runTest() { }); } repl.input.run(opts.test); - }); + })); } // run the tests diff --git a/test/parallel/test-repl-autolibs.js b/test/parallel/test-repl-autolibs.js index 5a34e1aecb1c8c..d3ab60a1b1d0c7 100644 --- a/test/parallel/test-repl-autolibs.js +++ b/test/parallel/test-repl-autolibs.js @@ -33,7 +33,7 @@ test1(); function test1() { let gotWrite = false; - putIn.write = function(data) { + putIn.write = common.mustCall(function(data) { gotWrite = true; if (data.length) { @@ -44,7 +44,7 @@ function test1() { assert.strictEqual(globalThis.fs, require('fs')); test2(); } - }; + }); assert(!gotWrite); putIn.run(['fs']); assert(gotWrite); @@ -52,7 +52,7 @@ function test1() { function test2() { let gotWrite = false; - putIn.write = function(data) { + putIn.write = common.mustCallAtLeast(function(data) { gotWrite = true; if (data.length) { // REPL response error message @@ -60,7 +60,7 @@ function test2() { // Original value wasn't overwritten assert.strictEqual(val, globalThis.url); } - }; + }); const val = {}; globalThis.url = val; common.allowGlobals(val); diff --git a/test/parallel/test-repl-colors.js b/test/parallel/test-repl-colors.js index cdbca5790ad5aa..226585b377b107 100644 --- a/test/parallel/test-repl-colors.js +++ b/test/parallel/test-repl-colors.js @@ -2,7 +2,7 @@ require('../common'); const { Duplex } = require('stream'); const { inspect } = require('util'); -const { strictEqual } = require('assert'); +const assert = require('assert'); const { REPLServer } = require('repl'); let output = ''; @@ -25,9 +25,9 @@ process.on('exit', function() { // https://github.com/nodejs/node/pull/16485#issuecomment-350428638 // The color setting of the REPL should not have leaked over into // the color setting of `util.inspect.defaultOptions`. - strictEqual(output.includes(`"'string'"`), true); - strictEqual(output.includes(`'\u001b[32m\\'string\\'\u001b[39m'`), false); - strictEqual(inspect.defaultOptions.colors, false); - strictEqual(repl.writer.options.colors, true); - strictEqual(repl2.writer.options.colors, true); + assert.strictEqual(output.includes(`"'string'"`), true); + assert.strictEqual(output.includes(`'\u001b[32m\\'string\\'\u001b[39m'`), false); + assert.strictEqual(inspect.defaultOptions.colors, false); + assert.strictEqual(repl.writer.options.colors, true); + assert.strictEqual(repl2.writer.options.colors, true); }); diff --git a/test/parallel/test-repl-dynamic-import.js b/test/parallel/test-repl-dynamic-import.js index a043e31bf5b2d0..3ce21d662f6f56 100644 --- a/test/parallel/test-repl-dynamic-import.js +++ b/test/parallel/test-repl-dynamic-import.js @@ -14,7 +14,7 @@ setTimeout(() => { child.stdin.write('\nimport("fs");\n'); child.stdin.write('\nprocess.exit(0);\n'); }, common.platformTimeout(50)); -child.on('exit', (code, signal) => { +child.on('exit', common.mustCall((code, signal) => { assert.strictEqual(code, 0); assert.strictEqual(signal, null); -}); +})); diff --git a/test/parallel/test-repl-envvars.js b/test/parallel/test-repl-envvars.js index 4efa04072d5fee..ba4de43b20f987 100644 --- a/test/parallel/test-repl-envvars.js +++ b/test/parallel/test-repl-envvars.js @@ -2,7 +2,7 @@ // Flags: --expose-internals -require('../common'); +const common = require('../common'); const stream = require('stream'); const { describe, test } = require('node:test'); const REPL = require('internal/repl'); @@ -66,9 +66,7 @@ function run(test) { Object.assign(process.env, env); return new Promise((resolve) => { - REPL.createInternalRepl(process.env, opts, function(err, repl) { - assert.ifError(err); - + REPL.createInternalRepl(process.env, opts, common.mustSucceed((repl) => { assert.strictEqual(repl.terminal, expected.terminal, `Expected ${inspect(expected)} with ${inspect(env)}`); assert.strictEqual(repl.useColors, expected.useColors, @@ -80,7 +78,7 @@ function run(test) { } repl.close(); resolve(); - }); + })); }); } diff --git a/test/parallel/test-repl-harmony.js b/test/parallel/test-repl-harmony.js index f03cd03d0f97b2..ee42957fe03908 100644 --- a/test/parallel/test-repl-harmony.js +++ b/test/parallel/test-repl-harmony.js @@ -20,7 +20,7 @@ // USE OR OTHER DEALINGS IN THE SOFTWARE. 'use strict'; -require('../common'); +const common = require('../common'); const assert = require('assert'); const spawn = require('child_process').spawn; @@ -42,9 +42,9 @@ let out = ''; child.stdout.on('data', (d) => { out += d; }); -child.stdout.on('end', () => { +child.stdout.on('end', common.mustCall(() => { assert.match(out, expectOut); console.log('ok'); -}); +})); child.stdin.end(input); diff --git a/test/parallel/test-repl-history-navigation.js b/test/parallel/test-repl-history-navigation.js index 77be0b0fc05e59..88c1058c0b29b4 100644 --- a/test/parallel/test-repl-history-navigation.js +++ b/test/parallel/test-repl-history-navigation.js @@ -867,7 +867,7 @@ function runTest() { REPL.createInternalRepl(opts.env, { input: new ActionStream(), output: new stream.Writable({ - write(chunk, _, next) { + write: common.mustCallAtLeast((chunk, _, next) => { const output = chunk.toString(); if (!opts.showEscapeCodes && @@ -892,20 +892,20 @@ function runTest() { } next(); - } + }), }), completer: opts.completer, prompt, useColors: false, preview: opts.preview, terminal: true - }, function(err, repl) { + }, common.mustCall((err, repl) => { if (err) { console.error(`Failed test # ${numtests - tests.length}`); throw err; } - repl.once('close', () => { + repl.once('close', common.mustCall(() => { if (opts.clean) cleanupTmpFile(); @@ -917,7 +917,7 @@ function runTest() { } setImmediate(runTestWrap, true); - }); + })); if (opts.columns) { Object.defineProperty(repl, 'columns', { @@ -926,7 +926,7 @@ function runTest() { }); } repl.input.run(opts.test); - }); + })); } // run the tests diff --git a/test/parallel/test-repl-null-thrown.js b/test/parallel/test-repl-null-thrown.js index 4babbab1e3989e..e62c3706e02be8 100644 --- a/test/parallel/test-repl-null-thrown.js +++ b/test/parallel/test-repl-null-thrown.js @@ -1,5 +1,5 @@ 'use strict'; -require('../common'); +const common = require('../common'); const assert = require('assert'); const { startNewREPLServer } = require('../common/repl'); @@ -8,6 +8,6 @@ const { replServer, output } = startNewREPLServer(); replServer.emit('line', 'process.nextTick(() => { throw null; })'); replServer.emit('line', '.exit'); -setTimeout(() => { +setTimeout(common.mustCall(() => { assert(output.accumulator.includes('Uncaught null')); -}, 0); +}), 0); diff --git a/test/parallel/test-repl-permission-model.js b/test/parallel/test-repl-permission-model.js index ab5c7bff06cde8..b29a03fba5745e 100644 --- a/test/parallel/test-repl-permission-model.js +++ b/test/parallel/test-repl-permission-model.js @@ -78,7 +78,7 @@ function runTest() { REPL.createInternalRepl(opts.env, { input: new ActionStream(), output: new stream.Writable({ - write(chunk, _, next) { + write: common.mustCallAtLeast((chunk, _, next) => { const output = chunk.toString(); if (!opts.showEscapeCodes && @@ -103,7 +103,7 @@ function runTest() { } next(); - } + }), }), allowBlockingCompletions: true, completer: opts.completer, @@ -111,13 +111,13 @@ function runTest() { useColors: false, preview: opts.preview, terminal: true - }, function(err, repl) { + }, common.mustCall((err, repl) => { if (err) { console.error(`Failed test # ${numtests - tests.length}`); throw err; } - repl.once('close', () => { + repl.once('close', common.mustCall(() => { if (opts.checkTotal) { assert.deepStrictEqual(lastChunks, expected); @@ -127,10 +127,10 @@ function runTest() { } setImmediate(runTestWrap, true); - }); + })); repl.input.run(opts.test); - }); + })); } // run the tests diff --git a/test/parallel/test-repl-persistent-history.js b/test/parallel/test-repl-persistent-history.js index efd1aa141357c2..0807a10a08a8a6 100644 --- a/test/parallel/test-repl-persistent-history.js +++ b/test/parallel/test-repl-persistent-history.js @@ -137,14 +137,12 @@ const tests = [ expected: [prompt, replFailedRead, prompt, replDisabled, prompt] }, { - before: function before() { + before: common.mustCall(function before() { if (common.isWindows) { const execSync = require('child_process').execSync; - execSync(`ATTRIB +H "${emptyHiddenHistoryPath}"`, (err) => { - assert.ifError(err); - }); + execSync(`ATTRIB +H "${emptyHiddenHistoryPath}"`); } - }, + }), env: { NODE_REPL_HISTORY: emptyHiddenHistoryPath }, test: [UP], expected: [prompt] @@ -216,7 +214,7 @@ function runTest(assertCleaned) { REPL.createInternalRepl(env, { input: new ActionStream(), output: new stream.Writable({ - write(chunk, _, next) { + write: common.mustCallAtLeast((chunk, _, next) => { const output = chunk.toString(); // Ignore escapes and blank lines @@ -230,12 +228,12 @@ function runTest(assertCleaned) { throw err; } next(); - } + }), }), prompt, useColors: false, terminal: true - }, function(err, repl) { + }, common.mustCall((err, repl) => { if (err) { console.error(`Failed test # ${numtests - tests.length}`); throw err; @@ -250,7 +248,7 @@ function runTest(assertCleaned) { onClose(); }); - function onClose() { + const onClose = common.mustCall(() => { const cleaned = clean === false ? false : cleanupTmpFile(); try { @@ -261,8 +259,8 @@ function runTest(assertCleaned) { console.error(`Failed test # ${numtests - tests.length}`); throw err; } - } + }); repl.inputStream.run(test); - }); + })); } diff --git a/test/parallel/test-repl-programmatic-history-setup-history.js b/test/parallel/test-repl-programmatic-history-setup-history.js index 038972b8566ba0..544f3994ef331b 100644 --- a/test/parallel/test-repl-programmatic-history-setup-history.js +++ b/test/parallel/test-repl-programmatic-history-setup-history.js @@ -138,14 +138,12 @@ const tests = [ }, // Checking the history file permissions { - before: function before() { + before: common.mustCall(function before() { if (common.isWindows) { const execSync = require('child_process').execSync; - execSync(`ATTRIB +H "${emptyHiddenHistoryPath}"`, (err) => { - assert.ifError(err); - }); + execSync(`ATTRIB +H "${emptyHiddenHistoryPath}"`); } - }, + }), env: { NODE_REPL_HISTORY: emptyHiddenHistoryPath }, test: [UP], expected: [prompt] @@ -220,7 +218,7 @@ function runTest(assertCleaned) { const repl = REPL.start({ input: new ActionStream(), output: new stream.Writable({ - write(chunk, _, next) { + write: common.mustCallAtLeast((chunk, _, next) => { const output = chunk.toString(); // Ignore escapes and blank lines @@ -234,7 +232,7 @@ function runTest(assertCleaned) { throw err; } next(); - } + }), }), prompt: prompt, useColors: false, diff --git a/test/parallel/test-repl-programmatic-history.js b/test/parallel/test-repl-programmatic-history.js index c762e83840e41c..c2bb6c88e52ed9 100644 --- a/test/parallel/test-repl-programmatic-history.js +++ b/test/parallel/test-repl-programmatic-history.js @@ -131,14 +131,12 @@ const tests = [ expected: [prompt, replFailedRead, prompt, replDisabled, prompt] }, { - before: function before() { + before: common.mustCall(function before() { if (common.isWindows) { const execSync = require('child_process').execSync; - execSync(`ATTRIB +H "${emptyHiddenHistoryPath}"`, (err) => { - assert.ifError(err); - }); + execSync(`ATTRIB +H "${emptyHiddenHistoryPath}"`); } - }, + }), env: { NODE_REPL_HISTORY: emptyHiddenHistoryPath }, test: [UP], expected: [prompt] @@ -211,7 +209,7 @@ function runTest(assertCleaned) { const repl = REPL.start({ input: new ActionStream(), output: new stream.Writable({ - write(chunk, _, next) { + write: common.mustCallAtLeast((chunk, _, next) => { const output = chunk.toString(); // Ignore escapes and blank lines @@ -225,7 +223,7 @@ function runTest(assertCleaned) { throw err; } next(); - } + }), }), prompt: prompt, useColors: false, @@ -233,7 +231,7 @@ function runTest(assertCleaned) { historySize }); - repl.setupHistory(file, function(err, repl) { + repl.setupHistory(file, common.mustCall((err, repl) => { if (err) { console.error(`Failed test # ${numtests - tests.length}`); throw err; @@ -248,7 +246,7 @@ function runTest(assertCleaned) { onClose(); }); - function onClose() { + const onClose = common.mustCall(() => { const cleaned = clean === false ? false : cleanupTmpFile(); try { @@ -259,8 +257,8 @@ function runTest(assertCleaned) { console.error(`Failed test # ${numtests - tests.length}`); throw err; } - } + }); repl.inputStream.run(test); - }); + })); } diff --git a/test/parallel/test-repl-reverse-search.js b/test/parallel/test-repl-reverse-search.js index 314d772adc67a5..cbe848afee082a 100644 --- a/test/parallel/test-repl-reverse-search.js +++ b/test/parallel/test-repl-reverse-search.js @@ -301,7 +301,7 @@ function runTest() { REPL.createInternalRepl(opts.env, { input: new ActionStream(), output: new stream.Writable({ - write(chunk, _, next) { + write: common.mustCallAtLeast((chunk, _, next) => { const output = chunk.toString(); if (!opts.showEscapeCodes && @@ -325,19 +325,19 @@ function runTest() { } next(); - } + }), }), completer: opts.completer, prompt, useColors: opts.useColors || false, terminal: true - }, function(err, repl) { + }, common.mustCall((err, repl) => { if (err) { console.error(`Failed test # ${numtests - tests.length}`); throw err; } - repl.once('close', () => { + repl.once('close', common.mustCall(() => { if (opts.clean) cleanupTmpFile(); @@ -349,7 +349,7 @@ function runTest() { } setImmediate(runTestWrap, true); - }); + })); if (opts.columns) { Object.defineProperty(repl, 'columns', { @@ -358,7 +358,7 @@ function runTest() { }); } repl.inputStream.run(opts.test); - }); + })); } // run the tests diff --git a/test/parallel/test-repl-setprompt.js b/test/parallel/test-repl-setprompt.js index d9eb85be145734..9901f8f974f646 100644 --- a/test/parallel/test-repl-setprompt.js +++ b/test/parallel/test-repl-setprompt.js @@ -20,7 +20,7 @@ // USE OR OTHER DEALINGS IN THE SOFTWARE. 'use strict'; -require('../common'); +const common = require('../common'); const assert = require('assert'); const spawn = require('child_process').spawn; const os = require('os'); @@ -41,9 +41,9 @@ child.stdout.on('data', function(d) { data += d; }); child.stdin.end(`e.setPrompt("${p}");${os.EOL}`); -child.on('close', function(code, signal) { +child.on('close', common.mustCall((code, signal) => { assert.strictEqual(code, 0); assert.ok(!signal); const lines = data.split('\n'); assert.strictEqual(lines.pop(), p); -}); +})); diff --git a/test/parallel/test-repl-sigint-nested-eval.js b/test/parallel/test-repl-sigint-nested-eval.js index 7955cf413f7c49..555802b725d145 100644 --- a/test/parallel/test-repl-sigint-nested-eval.js +++ b/test/parallel/test-repl-sigint-nested-eval.js @@ -40,7 +40,7 @@ child.stdout.once('data', common.mustCall(() => { ); })); -child.on('close', function(code) { +child.on('close', common.mustCall((code) => { const expected = 'Script execution was interrupted by `SIGINT`'; assert.ok( stdout.includes(expected), @@ -50,4 +50,4 @@ child.on('close', function(code) { stdout.includes('foobar'), `Expected stdout to contain "foobar", got ${stdout}` ); -}); +})); diff --git a/test/parallel/test-repl-sigint.js b/test/parallel/test-repl-sigint.js index f4087b11d488d6..33495f80a77a2a 100644 --- a/test/parallel/test-repl-sigint.js +++ b/test/parallel/test-repl-sigint.js @@ -39,7 +39,7 @@ child.stdout.once('data', common.mustCall(() => { 'while(true){}\n'); })); -child.on('close', function(code) { +child.on('close', common.mustCall((code) => { assert.strictEqual(code, 0); const expected = 'Script execution was interrupted by `SIGINT`'; assert.ok( @@ -50,4 +50,4 @@ child.on('close', function(code) { stdout.includes('42042\n'), `Expected stdout to contain "42042", got ${stdout}` ); -}); +})); diff --git a/test/parallel/test-repl-syntax-error-handling.js b/test/parallel/test-repl-syntax-error-handling.js index 91a8614d1deb93..2b57af8c80117f 100644 --- a/test/parallel/test-repl-syntax-error-handling.js +++ b/test/parallel/test-repl-syntax-error-handling.js @@ -20,7 +20,7 @@ // USE OR OTHER DEALINGS IN THE SOFTWARE. 'use strict'; -require('../common'); +const common = require('../common'); const assert = require('assert'); switch (process.argv[2]) { @@ -47,15 +47,15 @@ function parent() { child.stdout.on('data', function(c) { out += c; }); - child.stdout.on('end', function() { + child.stdout.on('end', common.mustCall(() => { assert.strictEqual(out, '10\n'); console.log('ok - got expected output'); - }); + })); - child.on('exit', function(c) { + child.on('exit', common.mustCall((c) => { assert(!c); console.log('ok - exit success'); - }); + })); } function child() { diff --git a/test/parallel/test-repl-tab-complete-buffer.js b/test/parallel/test-repl-tab-complete-buffer.js index 72c5e26cb799ae..25a5dc6fe6c8af 100644 --- a/test/parallel/test-repl-tab-complete-buffer.js +++ b/test/parallel/test-repl-tab-complete-buffer.js @@ -48,10 +48,10 @@ for (const type of [ assert.strictEqual(data[0].includes('ele.biu'), true); - data[0].forEach((key) => { + for (const key of data[0]) { if (!key || key === 'ele.biu') return; assert.notStrictEqual(ele[key.slice(4)], undefined); - }); + } }) ); } diff --git a/test/parallel/test-repl-tab-complete-import.js b/test/parallel/test-repl-tab-complete-import.js index 1f6cf7bff94b22..ed8a6c2de5efc5 100644 --- a/test/parallel/test-repl-tab-complete-import.js +++ b/test/parallel/test-repl-tab-complete-import.js @@ -56,9 +56,9 @@ replServer.complete("import\t( 'n", common.mustSucceed((data) => { assert.strictEqual(completions[lastIndex + 2], 'net'); assert.strictEqual(completions[lastIndex + 3], ''); // It's possible to pick up non-core modules too - completions.slice(lastIndex + 4).forEach((completion) => { + for (const completion of completions.slice(lastIndex + 4)) { assert.match(completion, /^n/); - }); + } })); { diff --git a/test/parallel/test-repl-tab-complete-require.js b/test/parallel/test-repl-tab-complete-require.js index 12be39c7f6aca3..47c03d8d5990a6 100644 --- a/test/parallel/test-repl-tab-complete-require.js +++ b/test/parallel/test-repl-tab-complete-require.js @@ -62,20 +62,18 @@ const { startNewREPLServer } = require('../common/repl'); // require(...) completions include `node:`-prefixed modules: let lastIndex = -1; - publicModules - .filter((lib) => !lib.startsWith('node:')) - .forEach((lib, index) => { - lastIndex = data[0].indexOf(`node:${lib}`); - assert.notStrictEqual(lastIndex, -1); - }); + for (const lib of publicModules.filter((lib) => !lib.startsWith('node:'))) { + lastIndex = data[0].indexOf(`node:${lib}`); + assert.notStrictEqual(lastIndex, -1); + } assert.strictEqual(data[0][lastIndex + 1], ''); // There is only one Node.js module that starts with n: assert.strictEqual(data[0][lastIndex + 2], 'net'); assert.strictEqual(data[0][lastIndex + 3], ''); // It's possible to pick up non-core modules too - data[0].slice(lastIndex + 4).forEach((completion) => { + for (const completion of data[0].slice(lastIndex + 4)) { assert.match(completion, /^n/); - }); + } }) ); } diff --git a/test/parallel/test-repl-tab.js b/test/parallel/test-repl-tab.js index f64a00d8bca99e..e99f667c4a38f5 100644 --- a/test/parallel/test-repl-tab.js +++ b/test/parallel/test-repl-tab.js @@ -1,6 +1,5 @@ 'use strict'; const common = require('../common'); -const assert = require('assert'); const repl = require('repl'); const zlib = require('zlib'); @@ -13,6 +12,4 @@ const testMe = repl.start('', putIn, function(cmd, context, filename, testMe._domain.on('error', common.mustNotCall()); -testMe.complete('', function(err, results) { - assert.strictEqual(err, null); -}); +testMe.complete('', common.mustSucceed()); diff --git a/test/parallel/test-repl-uncaught-exception-async.js b/test/parallel/test-repl-uncaught-exception-async.js index 8e0d9b4075ada4..f4180080f496f7 100644 --- a/test/parallel/test-repl-uncaught-exception-async.js +++ b/test/parallel/test-repl-uncaught-exception-async.js @@ -4,7 +4,7 @@ // does not suppress errors in the whole application. Adding such listener // should throw. -require('../common'); +const common = require('../common'); const assert = require('assert'); const { startNewREPLServer } = require('../common/repl'); @@ -32,10 +32,10 @@ replServer.write( '}, 1);console.log()\n' ); -setTimeout(() => { +setTimeout(common.mustCall(() => { replServer.close(); const len = process.listenerCount('uncaughtException'); process.removeAllListeners('uncaughtException'); assert.strictEqual(len, 0); assert.match(output.accumulator, /ERR_INVALID_REPL_INPUT.*(?!Type)RangeError: abc/s); -}, 2); +}), 2); diff --git a/test/parallel/test-repl-underscore.js b/test/parallel/test-repl-underscore.js index 38008fcc04c5d1..52d4cd86e94176 100644 --- a/test/parallel/test-repl-underscore.js +++ b/test/parallel/test-repl-underscore.js @@ -1,6 +1,6 @@ 'use strict'; -require('../common'); +const common = require('../common'); const assert = require('assert'); const repl = require('repl'); const { startNewREPLServer } = require('../common/repl'); @@ -190,7 +190,7 @@ function testError() { // throws error, async `); - setImmediate(() => { + setImmediate(common.mustCall(() => { const lines = output.accumulator.trim().split('\n').filter( (line) => !line.includes(testingReplPrompt) || line.includes('Uncaught Error') ); @@ -243,7 +243,7 @@ function testError() { 'Uncaught Error: quux', '0', ]); - }); + })); } function assertOutput(output, expected) { diff --git a/test/parallel/test-repl-unexpected-token-recoverable.js b/test/parallel/test-repl-unexpected-token-recoverable.js index 747f502ec56eaf..f81855c879b979 100644 --- a/test/parallel/test-repl-unexpected-token-recoverable.js +++ b/test/parallel/test-repl-unexpected-token-recoverable.js @@ -2,7 +2,7 @@ // This is a regression test for https://github.com/joyent/node/issues/8874. -require('../common'); +const common = require('../common'); const assert = require('assert'); const spawn = require('child_process').spawn; @@ -25,9 +25,9 @@ child.stdout.on('data', (d) => { out += d; }); -child.stdout.on('end', () => { +child.stdout.on('end', common.mustCall(() => { assert.match(out, expectOut); console.log('ok'); -}); +})); child.stdin.end(input); diff --git a/test/parallel/test-require-symlink.js b/test/parallel/test-require-symlink.js index 9ca543e8d64ca4..6e303517171089 100644 --- a/test/parallel/test-require-symlink.js +++ b/test/parallel/test-require-symlink.js @@ -76,19 +76,19 @@ function test() { // Load symlinked-script as main const node = process.execPath; const child = spawn(node, ['--preserve-symlinks', linkScript]); - child.on('close', function(code, signal) { + child.on('close', common.mustCall((code, signal) => { assert.strictEqual(code, 0); assert(!signal); - }); + })); // Also verify that symlinks works for setting preserve via env variables const childEnv = spawn(node, [linkScript], { env: { ...process.env, NODE_PRESERVE_SYMLINKS: '1' } }); - childEnv.on('close', function(code, signal) { + childEnv.on('close', common.mustCall((code, signal) => { assert.strictEqual(code, 0); assert(!signal); - }); + })); // Also verify that symlinks works for setting preserve via env variables in // Workers. diff --git a/test/parallel/test-runner-aliases.js b/test/parallel/test-runner-aliases.js index 1a61da896e9e38..00b8d24b61b8af 100644 --- a/test/parallel/test-runner-aliases.js +++ b/test/parallel/test-runner-aliases.js @@ -1,8 +1,8 @@ 'use strict'; require('../common'); -const { strictEqual } = require('node:assert'); +const assert = require('node:assert'); const test = require('node:test'); -strictEqual(test.test, test); -strictEqual(test.it, test); -strictEqual(test.describe, test.suite); +assert.strictEqual(test.test, test); +assert.strictEqual(test.it, test); +assert.strictEqual(test.describe, test.suite); diff --git a/test/parallel/test-runner-coverage.js b/test/parallel/test-runner-coverage.js index 0de2af4d57a98c..e014035c2687f8 100644 --- a/test/parallel/test-runner-coverage.js +++ b/test/parallel/test-runner-coverage.js @@ -230,7 +230,7 @@ test('coverage is combined for multiple processes', skipIfNoInspector, () => { assert.strictEqual(result.status, 0); }); -test.skip('coverage works with isolation=none', skipIfNoInspector, () => { +test.skip('coverage works with isolation=none', skipIfNoInspector, common.mustCallAtLeast(() => { // There is a bug in coverage calculation. The branch % in the common.js // fixture is different depending on the test isolation mode. The 'none' mode // is closer to what c8 reports here, so the bug is likely in the code that @@ -270,7 +270,7 @@ test.skip('coverage works with isolation=none', skipIfNoInspector, () => { assert.strictEqual(result.stderr.toString(), ''); assert(result.stdout.toString().includes(report)); assert.strictEqual(result.status, 0); -}); +}, 0)); test('coverage reports on lines, functions, and branches', skipIfNoInspector, async (t) => { const fixture = fixtures.path('test-runner', 'coverage.js'); @@ -290,9 +290,9 @@ test('coverage reports on lines, functions, and branches', skipIfNoInspector, as await t.test('does not include node_modules', () => { assert.strictEqual(coverage.summary.files.length, 3); const files = ['coverage.js', 'invalid-tap.js', 'throw.js']; - coverage.summary.files.forEach((file, index) => { + coverage.summary.files.forEach(common.mustCallAtLeast((file, index) => { assert.ok(file.path.endsWith(files[index])); - }); + })); }); const file = coverage.summary.files[0]; diff --git a/test/parallel/test-runner-custom-assertions.js b/test/parallel/test-runner-custom-assertions.js index a4bdf0f548be80..6e398339afe1f4 100644 --- a/test/parallel/test-runner-custom-assertions.js +++ b/test/parallel/test-runner-custom-assertions.js @@ -1,11 +1,11 @@ 'use strict'; -require('../common'); +const common = require('../common'); const assert = require('node:assert'); const { test, assert: testAssertions } = require('node:test'); -testAssertions.register('isOdd', (n) => { +testAssertions.register('isOdd', common.mustCallAtLeast((n) => { assert.strictEqual(n % 2, 1); -}); +})); testAssertions.register('ok', () => { return 'ok'; diff --git a/test/parallel/test-runner-filetest-location.js b/test/parallel/test-runner-filetest-location.js index 44293632dbdc68..0b43198a743d78 100644 --- a/test/parallel/test-runner-filetest-location.js +++ b/test/parallel/test-runner-filetest-location.js @@ -1,7 +1,7 @@ 'use strict'; const common = require('../common'); const fixtures = require('../common/fixtures'); -const { strictEqual } = require('node:assert'); +const assert = require('node:assert'); const { relative } = require('node:path'); const { run } = require('node:test'); const fixture = fixtures.path('test-runner', 'index.js'); @@ -12,9 +12,9 @@ const stream = run({ }); stream.on('test:fail', common.mustCall((result) => { - strictEqual(result.name, relativePath); - strictEqual(result.details.error.failureType, 'testCodeFailure'); - strictEqual(result.line, 1); - strictEqual(result.column, 1); - strictEqual(result.file, fixture); + assert.strictEqual(result.name, relativePath); + assert.strictEqual(result.details.error.failureType, 'testCodeFailure'); + assert.strictEqual(result.line, 1); + assert.strictEqual(result.column, 1); + assert.strictEqual(result.file, fixture); })); diff --git a/test/parallel/test-runner-force-exit-failure.js b/test/parallel/test-runner-force-exit-failure.js index 9d40d4aea48e77..52032372405eab 100644 --- a/test/parallel/test-runner-force-exit-failure.js +++ b/test/parallel/test-runner-force-exit-failure.js @@ -1,6 +1,6 @@ 'use strict'; require('../common'); -const { match, doesNotMatch, strictEqual } = require('node:assert'); +const assert = require('node:assert'); const { spawnSync } = require('node:child_process'); const fixtures = require('../common/fixtures'); const fixture = fixtures.path('test-runner/throws_sync_and_async.js'); @@ -15,11 +15,11 @@ for (const isolation of ['none', 'process']) { ]; const r = spawnSync(process.execPath, args); - strictEqual(r.status, 1); - strictEqual(r.signal, null); - strictEqual(r.stderr.toString(), ''); + assert.strictEqual(r.status, 1); + assert.strictEqual(r.signal, null); + assert.strictEqual(r.stderr.toString(), ''); const stdout = r.stdout.toString(); - match(stdout, /Error: fails/); - doesNotMatch(stdout, /this should not have a chance to be thrown/); + assert.match(stdout, /Error: fails/); + assert.doesNotMatch(stdout, /this should not have a chance to be thrown/); } diff --git a/test/parallel/test-runner-force-exit-flush.js b/test/parallel/test-runner-force-exit-flush.js index ddc4ea9771913a..f3b3a7fc26cdc0 100644 --- a/test/parallel/test-runner-force-exit-flush.js +++ b/test/parallel/test-runner-force-exit-flush.js @@ -2,7 +2,7 @@ require('../common'); const fixtures = require('../common/fixtures'); const tmpdir = require('../common/tmpdir'); -const { match, strictEqual } = require('node:assert'); +const assert = require('node:assert'); const { spawnSync } = require('node:child_process'); const { readFileSync } = require('node:fs'); const { test } = require('node:test'); @@ -16,9 +16,9 @@ function runWithReporter(reporter) { fixtures.path('test-runner', 'reporters.js'), ]; const child = spawnSync(process.execPath, args); - strictEqual(child.stdout.toString(), ''); - strictEqual(child.stderr.toString(), ''); - strictEqual(child.status, 1); + assert.strictEqual(child.stdout.toString(), ''); + assert.strictEqual(child.stderr.toString(), ''); + assert.strictEqual(child.status, 1); return destination; } @@ -26,24 +26,24 @@ tmpdir.refresh(); test('junit reporter', () => { const output = readFileSync(runWithReporter('junit'), 'utf8'); - match(output, //); - match(output, //); - match(output, //); - match(output, //); + assert.match(output, //); + assert.match(output, //); + assert.match(output, /