Skip to content
Myr

Update test coverage for Node.js 26 (#1242)

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Sindre Sorhus · committed by GitHub · parent 3ed0544 · Browse files · 11 files+33 added−34 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

11 files+33 added−34 removed

  • tests:+31 added−33 removed
  • other:+2 added−1 removed

11 files+33 added−34 removed

modified:.github/workflows/main.yml+2 added-1 removed
modified:test/arguments/local.js+15 added-14 removed
modified:test/helpers/early-error.js+2 added-2 removed
modified:test/helpers/input.js+1 added
modified:test/return/message.js+2 added-2 removed
89 unmodified lines
90test('error.message newlines are consistent - no newline', testErrorMessageConsistent, 'stdout');91test('error.message newlines are consistent - newline', testErrorMessageConsistent, 'stdout\n');9293test('Original error.message is kept', async t => {94 const {originalMessage} = await t.throwsAsync(execa('noop.js', {uid: true}));95 t.is(originalMessage, 'The "options.uid" property must be int32. Received type boolean (true)');94 const {originalMessage} = await t.throwsAsync(execa('noop.js', {windowsHide: 'true'}));95 t.is(originalMessage, 'The "options.windowsHide" property must be of type boolean. Received type string (\'true\')');96});9798const testIpcOutput = async (t, doubles, ipcInput, returnedMessage) => {99 const fixtureName = doubles ? 'ipc-echo-twice-fail.js' : 'ipc-echo-fail.js';
19 unmodified lines
modified:test/verbose/error.js+2 added-3 removed
1import test from 'ava';2import {red} from 'yoctocolors';2import {setFixtureDirectory} from '../helpers/fixtures-directory.js';4import {foobarString} from '../helpers/input.js';3import {foobarString, foobarRed} from '../helpers/input.js';4import {nestedSubprocess} from '../helpers/nested.js';5import {6 QUOTE,7 runErrorSubprocess,
140 unmodified lines
148 ]);149});150151test('Escapes and strips color sequences from error', async t => {153 const {stderr} = await t.throwsAsync(nestedSubprocess('noop-forever.js', [red(foobarString)], {parentFixture: 'nested-fail.js', verbose: 'short'}, {env: {FORCE_COLOR: '1'}}));152 const {stderr} = await t.throwsAsync(nestedSubprocess('noop-forever.js', [foobarRed], {parentFixture: 'nested-fail.js', verbose: 'short'}));153 t.deepEqual(getErrorLines(stderr), [154 `${testTimestamp} [0] × Command was killed with SIGTERM (Termination): noop-forever.js ${QUOTE}\\u001b[31m${foobarString}\\u001b[39m${QUOTE}`,155 `${testTimestamp} [0] × ${foobarString}`,156 ]);
9 unmodified lines
modified:test/verbose/info.js+2 added-2 removed
83 unmodified lines
84test('Prints early spawn errors, sync', async t => {85 const {stderr} = await nestedSubprocess('empty.js', {...earlyErrorOptionsSync, verbose: 'full', isSync: true});86 t.deepEqual(getNormalizedLines(stderr), [87 `${testTimestamp} [0] $ empty.js`,88 `${testTimestamp} [0] × Command failed with ERR_OUT_OF_RANGE: empty.js`,89 `${testTimestamp} [0] × The value of "options.maxBuffer" is out of range. It must be a positive number. Received false`,88 `${testTimestamp} [0] × Command failed with ERR_INVALID_ARG_TYPE: empty.js`,89 `${testTimestamp} [0] × The "options.windowsHide" property must be of type boolean. Received type string ('true')`,90 `${testTimestamp} [0] × (done in 0ms)`,91 ]);92});
modified:test/verbose/ipc.js+2 added-3 removed
1import {on} from 'node:events';2import {inspect} from 'node:util';3import test from 'ava';4import {red} from 'yoctocolors';4import {setFixtureDirectory} from '../helpers/fixtures-directory.js';6import {foobarString, foobarObject} from '../helpers/input.js';5import {foobarString, foobarRed, foobarObject} from '../helpers/input.js';6import {nestedSubprocess, nestedInstance} from '../helpers/nested.js';7import {8 getIpcLine,9 getIpcLines,
72 unmodified lines
82 t.is(getIpcLine(stderr), `${testTimestamp} [0] * ã`);83});8485test('Strips color sequences from IPC', async t => {87 const {stderr} = await nestedSubprocess('ipc-send.js', [red(foobarString)], {ipc: true, verbose: 'full'}, {env: {FORCE_COLOR: '1'}});86 const {stderr} = await nestedSubprocess('ipc-send.js', [foobarRed], {ipc: true, verbose: 'full'});87 t.is(getIpcLine(stderr), `${testTimestamp} [0] * ${foobarString}`);88});8990test('Escapes control characters from IPC', async t => {
17 unmodified lines
modified:test/verbose/log.js+1 added-1 removed
19 unmodified lines
20test('Logs on stderr not stdout, verbose "short", sync', testNoStdout, 'short', true);21test('Logs on stderr not stdout, verbose "full", sync', testNoStdout, 'full', true);2223const testColor = async (t, expectedResult, forceColor) => {24 const {stderr} = await nestedSubprocess('noop.js', [foobarString], {verbose: 'short'}, {env: {FORCE_COLOR: forceColor}});24 const {stderr} = await nestedSubprocess('noop.js', [foobarString], {verbose: 'short'}, {env: {FORCE_COLOR: forceColor, NO_COLOR: undefined}});25 t.is(stderr !== stripVTControlCharacters(stderr), expectedResult);26};2728test('Prints with colors if supported', testColor, true, '1');
13 unmodified lines
modified:test/verbose/output-enable.js+2 added-3 removed
1import test from 'ava';2import {red} from 'yoctocolors';2import {setFixtureDirectory} from '../helpers/fixtures-directory.js';4import {foobarString, foobarUtf16Uint8Array} from '../helpers/input.js';3import {foobarString, foobarRed, foobarUtf16Uint8Array} from '../helpers/input.js';4import {fullStdio} from '../helpers/stdio.js';5import {nestedSubprocess} from '../helpers/nested.js';6import {7 runErrorSubprocess,
96 unmodified lines
104 t.is(getOutputLine(stderr), `${testTimestamp} [0] ã`);105});106107test('Strips color sequences from stdout', async t => {109 const {stderr} = await nestedSubprocess('noop.js', [red(foobarString)], {verbose: 'full'}, {env: {FORCE_COLOR: '1'}});108 const {stderr} = await nestedSubprocess('noop.js', [foobarRed], {verbose: 'full'});109 t.is(getOutputLine(stderr), `${testTimestamp} [0] ${foobarString}`);110});111112test('Escapes control characters from stdout', async t => {
32 unmodified lines
modified:test/verbose/start.js+2 added-3 removed
1import test from 'ava';2import {red} from 'yoctocolors';2import {setFixtureDirectory} from '../helpers/fixtures-directory.js';4import {foobarString} from '../helpers/input.js';3import {foobarString, foobarRed} from '../helpers/input.js';4import {nestedSubprocess} from '../helpers/nested.js';5import {6 QUOTE,7 runErrorSubprocess,
142 unmodified lines
150 t.is(getCommandLine(stderr), `${testTimestamp} [0] $ noop.js ${QUOTE}ã${QUOTE}`);151});152153test('Escapes color sequences from command', async t => {155 const {stderr} = await nestedSubprocess('noop.js', [red(foobarString)], {verbose: 'short'}, {env: {FORCE_COLOR: '1'}});154 const {stderr} = await nestedSubprocess('noop.js', [foobarRed], {verbose: 'short'});155 t.true(getCommandLine(stderr).includes(`${QUOTE}\\u001b[31m${foobarString}\\u001b[39m${QUOTE}`));156});157158test('Escapes control characters from command', async t => {
3 unmodified lines