Skip to content
Myr

test.js

This file

Path

test/test.js

323 lines · 12.5 KiB · JavaScript

Last changed by

Fix `reject` option with early spawning errors (#734)ehmickybefore adoption8a18881

History of this file

Take it

The walk stopped after 200 commits: lines older than ecdbad3 point at it.

Require Node.js 12.20 and move to ESM (#478)Minh Nguyenbefore adoption7707880

lines 1–2why, one step back
1import path from 'node:path';
2import process from 'node:process';

Allow `cwd` and `localDir` options to be URLs (#492)ehmickybefore adoption93ab929

line 3why, one step back
3import {fileURLToPath, pathToFileURL} from 'node:url';

Add retry example to `Tips` readme section (#386)Dan Levybefore adoptionecdbad3

lines 4–6why, one step back
4import test from 'ava';
5import isRunning from 'is-running';6import getNode from 'get-node';

Allow `shell` option to be a file URL (#635)ehmickybefore adoption189d486

line 7why, one step back
7import which from 'which';

Allow the first argument of `execa()` to be a file URL (#631)ehmickybefore adoption3bbd8ae

lines 8–9why, one step back
8import {execa, execaSync, execaNode, $} from '../index.js';
9import {setFixtureDir, PATH_KEY, FIXTURES_DIR_URL} from './helpers/fixtures-dir.js';

Allow any type with transforms (#709)ehmickybefore adoptioned8b2ce

lines 10–11why, one step back
10import {identity, fullStdio, getStdio} from './helpers/stdio.js';
11import {noopGenerator} from './helpers/generator.js';

Add retry example to `Tips` readme section (#386)Dan Levybefore adoptionecdbad3

line 12why, one step back
12

Re-enable Windows in CI (#500)ehmickybefore adoption071d0a2

line 13why, one step back
13setFixtureDir();

Add retry example to `Tips` readme section (#386)Dan Levybefore adoptionecdbad3

lines 14–17why, one step back
14process.env.FOO = 'foo';
1516const ENOENT_REGEXP = process.platform === 'win32' ? /failed with exit code 1/ : /spawn.* ENOENT/;17

Add `result.stdio` and `error.stdio` (#676)ehmickybefore adoption62a5207

lines 18–20why, one step back
18const testOutput = async (t, index, execaCommand) => {
19 const {stdout, stderr, stdio} = await execaCommand('noop-fd.js', [`${index}`, 'foobar'], fullStdio);20 t.is(stdio[index], 'foobar');

Allow the `execPath` option to be a file URL (#633)ehmickybefore adoptionb495146

line 21why, one step back
21

Add `result.stdio` and `error.stdio` (#676)ehmickybefore adoption62a5207

lines 22–44why, one step back
22 if (index === 1) {
23 t.is(stdio[index], stdout);24 } else if (index === 2) {25 t.is(stdio[index], stderr);26 }27};2829test('can return stdout', testOutput, 1, execa);30test('can return stderr', testOutput, 2, execa);31test('can return output stdio[*]', testOutput, 3, execa);32test('can return stdout - sync', testOutput, 1, execaSync);33test('can return stderr - sync', testOutput, 2, execaSync);34test('can return output stdio[*] - sync', testOutput, 3, execaSync);3536const testNoStdin = async (t, execaCommand) => {37 const {stdio} = await execaCommand('noop.js', ['foobar']);38 t.is(stdio[0], undefined);39};4041test('cannot return stdin', testNoStdin, execa);42test('cannot return stdin - sync', testNoStdin, execaSync);4344test('cannot return input stdio[*]', async t => {

Allow any type with transforms (#709)ehmickybefore adoptioned8b2ce

line 45why, one step back
45 const {stdio} = await execa('stdin-fd.js', ['3'], getStdio(3, [['foobar']]));

Add `result.stdio` and `error.stdio` (#676)ehmickybefore adoption62a5207

line 46why, one step back
46 t.is(stdio[3], undefined);

Add retry example to `Tips` readme section (#386)Dan Levybefore adoptionecdbad3

lines 47–60why, one step back
47});
4849if (process.platform === 'win32') {50 test('execa() - cmd file', async t => {51 const {stdout} = await execa('hello.cmd');52 t.is(stdout, 'Hello World');53 });5455 test('execa() - run cmd command', async t => {56 const {stdout} = await execa('cmd', ['/c', 'hello.cmd']);57 t.is(stdout, 'Hello World');58 });59}60

Add `result.stdio` and `error.stdio` (#676)ehmickybefore adoption62a5207

line 61why, one step back
61test('execaSync() throws error if ENOENT', t => {

Add retry example to `Tips` readme section (#386)Dan Levybefore adoptionecdbad3

line 62why, one step back
62 t.throws(() => {

Require Node.js 12.20 and move to ESM (#478)Minh Nguyenbefore adoption7707880

lines 63–64why, one step back
63 execaSync('foo');
64 }, {message: ENOENT_REGEXP});

Add retry example to `Tips` readme section (#386)Dan Levybefore adoptionecdbad3

lines 65–67why, one step back
65});
6667test('skip throwing when using reject option', async t => {

Require Node.js 12.20 and move to ESM (#478)Minh Nguyenbefore adoption7707880

line 68why, one step back
68 const {exitCode} = await execa('fail.js', {reject: false});

Add retry example to `Tips` readme section (#386)Dan Levybefore adoptionecdbad3

lines 69–72why, one step back
69 t.is(exitCode, 2);
70});7172test('skip throwing when using reject option in sync mode', t => {

Require Node.js 12.20 and move to ESM (#478)Minh Nguyenbefore adoption7707880

line 73why, one step back
73 const {exitCode} = execaSync('fail.js', {reject: false});

Add retry example to `Tips` readme section (#386)Dan Levybefore adoptionecdbad3

lines 74–76why, one step back
74 t.is(exitCode, 2);
75});76

Add `result.stdio` and `error.stdio` (#676)ehmickybefore adoption62a5207

lines 77–78why, one step back
77const testStripFinalNewline = async (t, index, stripFinalNewline, execaCommand) => {
78 const {stdio} = await execaCommand('noop-fd.js', [`${index}`, 'foobar\n'], {...fullStdio, stripFinalNewline});

Fix passing `undefined` options (#712)ehmickybefore adoption472c065

line 79why, one step back
79 t.is(stdio[index], `foobar${stripFinalNewline === false ? '\n' : ''}`);

Add `result.stdio` and `error.stdio` (#676)ehmickybefore adoption62a5207

line 80why, one step back
80};

Add retry example to `Tips` readme section (#386)Dan Levybefore adoptionecdbad3

line 81why, one step back
81

Fix passing `undefined` options (#712)ehmickybefore adoption472c065

lines 82–83why, one step back
82test('stripFinalNewline: undefined with stdout', testStripFinalNewline, 1, undefined, execa);
83test('stripFinalNewline: true with stdout', testStripFinalNewline, 1, true, execa);

Add `result.stdio` and `error.stdio` (#676)ehmickybefore adoption62a5207

line 84why, one step back
84test('stripFinalNewline: false with stdout', testStripFinalNewline, 1, false, execa);

Fix passing `undefined` options (#712)ehmickybefore adoption472c065

lines 85–86why, one step back
85test('stripFinalNewline: undefined with stderr', testStripFinalNewline, 2, undefined, execa);
86test('stripFinalNewline: true with stderr', testStripFinalNewline, 2, true, execa);

Add `result.stdio` and `error.stdio` (#676)ehmickybefore adoption62a5207

line 87why, one step back
87test('stripFinalNewline: false with stderr', testStripFinalNewline, 2, false, execa);

Fix passing `undefined` options (#712)ehmickybefore adoption472c065

lines 88–89why, one step back
88test('stripFinalNewline: undefined with stdio[*]', testStripFinalNewline, 3, undefined, execa);
89test('stripFinalNewline: true with stdio[*]', testStripFinalNewline, 3, true, execa);

Add `result.stdio` and `error.stdio` (#676)ehmickybefore adoption62a5207

line 90why, one step back
90test('stripFinalNewline: false with stdio[*]', testStripFinalNewline, 3, false, execa);

Fix passing `undefined` options (#712)ehmickybefore adoption472c065

lines 91–92why, one step back
91test('stripFinalNewline: undefined with stdout - sync', testStripFinalNewline, 1, undefined, execaSync);
92test('stripFinalNewline: true with stdout - sync', testStripFinalNewline, 1, true, execaSync);

Add `result.stdio` and `error.stdio` (#676)ehmickybefore adoption62a5207

line 93why, one step back
93test('stripFinalNewline: false with stdout - sync', testStripFinalNewline, 1, false, execaSync);

Fix passing `undefined` options (#712)ehmickybefore adoption472c065

lines 94–95why, one step back
94test('stripFinalNewline: undefined with stderr - sync', testStripFinalNewline, 2, undefined, execaSync);
95test('stripFinalNewline: true with stderr - sync', testStripFinalNewline, 2, true, execaSync);

Add `result.stdio` and `error.stdio` (#676)ehmickybefore adoption62a5207

line 96why, one step back
96test('stripFinalNewline: false with stderr - sync', testStripFinalNewline, 2, false, execaSync);

Fix passing `undefined` options (#712)ehmickybefore adoption472c065

lines 97–98why, one step back
97test('stripFinalNewline: undefined with stdio[*] - sync', testStripFinalNewline, 3, undefined, execaSync);
98test('stripFinalNewline: true with stdio[*] - sync', testStripFinalNewline, 3, true, execaSync);

Add `result.stdio` and `error.stdio` (#676)ehmickybefore adoption62a5207

line 99why, one step back
99test('stripFinalNewline: false with stdio[*] - sync', testStripFinalNewline, 3, false, execaSync);

Allow any type with transforms (#709)ehmickybefore adoptioned8b2ce

lines 100–104why, one step back
100
101test('stripFinalNewline is not used in objectMode', async t => {102 const {stdout} = await execa('noop-fd.js', ['1', 'foobar\n'], {stripFinalNewline: true, stdout: noopGenerator(true)});103 t.deepEqual(stdout, ['foobar\n']);104});

Add retry example to `Tips` readme section (#386)Dan Levybefore adoptionecdbad3

line 105why, one step back
105

Re-enable Windows in CI (#500)ehmickybefore adoption071d0a2

lines 106–112why, one step back
106const getPathWithoutLocalDir = () => {
107 const newPath = process.env[PATH_KEY].split(path.delimiter).filter(pathDir => !BIN_DIR_REGEXP.test(pathDir)).join(path.delimiter);108 return {[PATH_KEY]: newPath};109};110111const BIN_DIR_REGEXP = /node_modules[\\/]\.bin/;112

Add retry example to `Tips` readme section (#386)Dan Levybefore adoptionecdbad3

line 113why, one step back
113test('preferLocal: true', async t => {

Re-enable Windows in CI (#500)ehmickybefore adoption071d0a2

line 114why, one step back
114 await t.notThrowsAsync(execa('ava', ['--version'], {preferLocal: true, env: getPathWithoutLocalDir()}));

Add retry example to `Tips` readme section (#386)Dan Levybefore adoptionecdbad3

lines 115–117why, one step back
115});
116117test('preferLocal: false', async t => {

Re-enable Windows in CI (#500)ehmickybefore adoption071d0a2

line 118why, one step back
118 await t.throwsAsync(execa('ava', ['--version'], {preferLocal: false, env: getPathWithoutLocalDir()}), {message: ENOENT_REGEXP});

Add retry example to `Tips` readme section (#386)Dan Levybefore adoptionecdbad3

lines 119–121why, one step back
119});
120121test('preferLocal: undefined', async t => {

Re-enable Windows in CI (#500)ehmickybefore adoption071d0a2

line 122why, one step back
122 await t.throwsAsync(execa('ava', ['--version'], {env: getPathWithoutLocalDir()}), {message: ENOENT_REGEXP});

Make `preferLocal` default to `true` with `$` (#529)ehmickybefore adoptiona6d1141

lines 123–126why, one step back
123});
124125test('preferLocal: undefined with $', async t => {126 await t.notThrowsAsync($({env: getPathWithoutLocalDir()})`ava --version`);

Add retry example to `Tips` readme section (#386)Dan Levybefore adoptionecdbad3

lines 127–128why, one step back
127});
128

Fix default value of `stdin` with `$` (#550)ehmickybefore adoption6fe7e51

lines 129–132why, one step back
129test('preferLocal: undefined with $.sync', t => {
130 t.notThrows(() => $({env: getPathWithoutLocalDir()}).sync`ava --version`);131});132

Add retry example to `Tips` readme section (#386)Dan Levybefore adoptionecdbad3

lines 133–139why, one step back
133test('localDir option', async t => {
134 const command = process.platform === 'win32' ? 'echo %PATH%' : 'echo $PATH';135 const {stdout} = await execa(command, {shell: true, preferLocal: true, localDir: '/test'});136 const envPaths = stdout.split(path.delimiter);137 t.true(envPaths.some(envPath => envPath.endsWith('.bin')));138});139

Allow the `execPath` option to be a file URL (#633)ehmickybefore adoptionb495146

lines 140–142why, one step back
140const testExecPath = async (t, mapPath) => {
141 const {path} = await getNode('16.0.0');142 const execPath = mapPath(path);

Add retry example to `Tips` readme section (#386)Dan Levybefore adoptionecdbad3

line 143why, one step back
143 const {stdout} = await execa('node', ['-p', 'process.env.Path || process.env.PATH'], {preferLocal: true, execPath});

Meta tweaksSindre Sorhusbefore adoption09df476

line 144why, one step back
144 t.true(stdout.includes('16.0.0'));

Allow the `execPath` option to be a file URL (#633)ehmickybefore adoptionb495146

lines 145–148why, one step back
145};
146147test.serial('execPath option', testExecPath, identity);148test.serial('execPath option can be a file URL', testExecPath, pathToFileURL);

Add retry example to `Tips` readme section (#386)Dan Levybefore adoptionecdbad3

line 149why, one step back
149

Add `result.stdio` and `error.stdio` (#676)ehmickybefore adoption62a5207

lines 150–153why, one step back
150test('execa() returns a promise with pid', async t => {
151 const subprocess = execa('noop.js', ['foo']);152 t.is(typeof subprocess.pid, 'number');153 await subprocess;

Add retry example to `Tips` readme section (#386)Dan Levybefore adoptionecdbad3

lines 154–155why, one step back
154});
155

Fix `reject` option with early spawning errors (#734)ehmickybefore adoption8a18881

lines 156–157why, one step back
156const testEarlyErrorShape = async (t, reject) => {
157 const subprocess = execa('', {reject});

Add retry example to `Tips` readme section (#386)Dan Levybefore adoptionecdbad3

lines 158–162why, one step back
158 t.notThrows(() => {
159 subprocess.catch(() => {});160 subprocess.unref();161 subprocess.on('error', () => {});162 });

Fix `reject` option with early spawning errors (#734)ehmickybefore adoption8a18881

lines 163–170why, one step back
163};
164165test('child_process.spawn() early errors have correct shape', testEarlyErrorShape, true);166test('child_process.spawn() early errors have correct shape - reject false', testEarlyErrorShape, false);167168test('child_process.spawn() early errors are propagated', async t => {169 const {failed} = await t.throwsAsync(execa(''));170 t.true(failed);

Add retry example to `Tips` readme section (#386)Dan Levybefore adoptionecdbad3

lines 171–172why, one step back
171});
172

Fix `reject` option with early spawning errors (#734)ehmickybefore adoption8a18881

lines 173–174why, one step back
173test('child_process.spawn() early errors are returned', async t => {
174 const {failed} = await execa('', {reject: false});

Add retry example to `Tips` readme section (#386)Dan Levybefore adoptionecdbad3

lines 175–177why, one step back
175 t.true(failed);
176});177

Fix `reject` option with early spawning errors (#734)ehmickybefore adoption8a18881

line 178why, one step back
178test('child_process.spawnSync() early errors are propagated with a correct shape', t => {

Add retry example to `Tips` readme section (#386)Dan Levybefore adoptionecdbad3

line 179why, one step back
179 const {failed} = t.throws(() => {

Fix `reject` option with early spawning errors (#734)ehmickybefore adoption8a18881

line 180why, one step back
180 execaSync('');

Add retry example to `Tips` readme section (#386)Dan Levybefore adoptionecdbad3

line 181why, one step back
181 });

Fix `reject` option with early spawning errors (#734)ehmickybefore adoption8a18881

lines 182–186why, one step back
182 t.true(failed);
183});184185test('child_process.spawnSync() early errors are propagated with a correct shape - reject false', t => {186 const {failed} = execaSync('', {reject: false});

Add retry example to `Tips` readme section (#386)Dan Levybefore adoptionecdbad3

lines 187–190why, one step back
187 t.true(failed);
188});189190test('do not try to consume streams twice', async t => {

Require Node.js 12.20 and move to ESM (#478)Minh Nguyenbefore adoption7707880

line 191why, one step back
191 const subprocess = execa('noop.js', ['foo']);

Meta tweaksSindre Sorhusbefore adoption5bac052

lines 192–195why, one step back
192 const {stdout} = await subprocess;
193 const {stdout: stdout2} = await subprocess;194 t.is(stdout, 'foo');195 t.is(stdout2, 'foo');

Add retry example to `Tips` readme section (#386)Dan Levybefore adoptionecdbad3

lines 196–198why, one step back
196});
197198test('use relative path with \'..\' chars', async t => {

Require Node.js 12.20 and move to ESM (#478)Minh Nguyenbefore adoption7707880

line 199why, one step back
199 const pathViaParentDir = path.join('..', path.basename(fileURLToPath(new URL('..', import.meta.url))), 'test', 'fixtures', 'noop.js');

Add retry example to `Tips` readme section (#386)Dan Levybefore adoptionecdbad3

lines 200–205why, one step back
200 const {stdout} = await execa(pathViaParentDir, ['foo']);
201 t.is(stdout, 'foo');202});203204if (process.platform !== 'win32') {205 test('execa() rejects if running non-executable', async t => {

Add `result.stdio` and `error.stdio` (#676)ehmickybefore adoption62a5207

line 206why, one step back
206 await t.throwsAsync(execa('non-executable.js'));

Add retry example to `Tips` readme section (#386)Dan Levybefore adoptionecdbad3

lines 207–209why, one step back
207 });
208209 test('execa() rejects with correct error and doesn\'t throw if running non-executable with input', async t => {

Drop support for Node 12 (#497)ehmickybefore adoptiona09cbc0

line 210why, one step back
210 await t.throwsAsync(execa('non-executable.js', {input: 'Hey!'}), {message: /EACCES/});

Add retry example to `Tips` readme section (#386)Dan Levybefore adoptionecdbad3

lines 211–227why, one step back
211 });
212}213214if (process.platform !== 'win32') {215 test('write to fast-exit process', async t => {216 // Try-catch here is necessary, because this test is not 100% accurate217 // Sometimes process can manage to accept input before exiting218 try {219 await execa(`fast-exit-${process.platform}`, [], {input: 'data'});220 t.pass();221 } catch (error) {222 t.is(error.code, 'EPIPE');223 }224 });225}226227test('use environment variables by default', async t => {

Require Node.js 12.20 and move to ESM (#478)Minh Nguyenbefore adoption7707880

line 228why, one step back
228 const {stdout} = await execa('environment.js');

Add retry example to `Tips` readme section (#386)Dan Levybefore adoptionecdbad3

lines 229–232why, one step back
229 t.deepEqual(stdout.split('\n'), ['foo', 'undefined']);
230});231232test('extend environment variables by default', async t => {

Re-enable Windows in CI (#500)ehmickybefore adoption071d0a2

line 233why, one step back
233 const {stdout} = await execa('environment.js', [], {env: {BAR: 'bar', [PATH_KEY]: process.env[PATH_KEY]}});

Add retry example to `Tips` readme section (#386)Dan Levybefore adoptionecdbad3

lines 234–237why, one step back
234 t.deepEqual(stdout.split('\n'), ['foo', 'bar']);
235});236237test('do not extend environment with `extendEnv: false`', async t => {

Re-enable Windows in CI (#500)ehmickybefore adoption071d0a2

line 238why, one step back
238 const {stdout} = await execa('environment.js', [], {env: {BAR: 'bar', [PATH_KEY]: process.env[PATH_KEY]}, extendEnv: false});

Add retry example to `Tips` readme section (#386)Dan Levybefore adoptionecdbad3

lines 239–240why, one step back
239 t.deepEqual(stdout.split('\n'), ['undefined', 'bar']);
240});

Allow `cwd` and `localDir` options to be URLs (#492)ehmickybefore adoption93ab929

lines 241–247why, one step back
241
242test('can use `options.cwd` as a string', async t => {243 const cwd = '/';244 const {stdout} = await execa('node', ['-p', 'process.cwd()'], {cwd});245 t.is(path.toNamespacedPath(stdout), path.toNamespacedPath(cwd));246});247

Drop support for Node 12 (#497)ehmickybefore adoptiona09cbc0

lines 248–253why, one step back
248test('localDir option can be a URL', async t => {
249 const command = process.platform === 'win32' ? 'echo %PATH%' : 'echo $PATH';250 const {stdout} = await execa(command, {shell: true, preferLocal: true, localDir: pathToFileURL('/test')});251 const envPaths = stdout.split(path.delimiter);252 t.true(envPaths.some(envPath => envPath.endsWith('.bin')));253});

Allow `cwd` and `localDir` options to be URLs (#492)ehmickybefore adoption93ab929

line 254why, one step back
254

Drop support for Node 12 (#497)ehmickybefore adoptiona09cbc0

lines 255–260why, one step back
255test('can use `options.cwd` as a URL', async t => {
256 const cwd = '/';257 const cwdUrl = pathToFileURL(cwd);258 const {stdout} = await execa('node', ['-p', 'process.cwd()'], {cwd: cwdUrl});259 t.is(path.toNamespacedPath(stdout), path.toNamespacedPath(cwd));260});

Add retry example to `Tips` readme section (#386)Dan Levybefore adoptionecdbad3

lines 261–262why, one step back
261
262test('can use `options.shell: true`', async t => {

Require Node.js 12.20 and move to ESM (#478)Minh Nguyenbefore adoption7707880

line 263why, one step back
263 const {stdout} = await execa('node test/fixtures/noop.js foo', {shell: true});

Add retry example to `Tips` readme section (#386)Dan Levybefore adoptionecdbad3

lines 264–266why, one step back
264 t.is(stdout, 'foo');
265});266

Allow `shell` option to be a file URL (#635)ehmickybefore adoption189d486

lines 267–269why, one step back
267const testShellPath = async (t, mapPath) => {
268 const shellPath = process.platform === 'win32' ? 'cmd.exe' : 'bash';269 const shell = mapPath(await which(shellPath));

Require Node.js 12.20 and move to ESM (#478)Minh Nguyenbefore adoption7707880

line 270why, one step back
270 const {stdout} = await execa('node test/fixtures/noop.js foo', {shell});

Add retry example to `Tips` readme section (#386)Dan Levybefore adoptionecdbad3

line 271why, one step back
271 t.is(stdout, 'foo');

Allow `shell` option to be a file URL (#635)ehmickybefore adoption189d486

lines 272–275why, one step back
272};
273274test('can use `options.shell: string`', testShellPath, identity);275test('can use `options.shell: file URL`', testShellPath, pathToFileURL);

Add retry example to `Tips` readme section (#386)Dan Levybefore adoptionecdbad3

lines 276–285why, one step back
276
277test('use extend environment with `extendEnv: true` and `shell: true`', async t => {278 process.env.TEST = 'test';279 const command = process.platform === 'win32' ? 'echo %TEST%' : 'echo $TEST';280 const {stdout} = await execa(command, {shell: true, env: {}, extendEnv: true});281 t.is(stdout, 'test');282 delete process.env.TEST;283});284285test('detach child process', async t => {

Require Node.js 12.20 and move to ESM (#478)Minh Nguyenbefore adoption7707880

line 286why, one step back
286 const {stdout} = await execa('detach.js');

Add retry example to `Tips` readme section (#386)Dan Levybefore adoptionecdbad3

lines 287–292why, one step back
287 const pid = Number(stdout);
288 t.true(Number.isInteger(pid));289 t.true(isRunning(pid));290291 process.kill(pid, 'SIGKILL');292});

Allow the first argument of `execa()` to be a file URL (#631)ehmickybefore adoption3bbd8ae

lines 293–323why, one step back
293
294const testFileUrl = async (t, execaMethod) => {295 const command = new URL('noop.js', FIXTURES_DIR_URL);296 const {stdout} = await execaMethod(command, ['foobar']);297 t.is(stdout, 'foobar');298};299300test('execa()\'s command argument can be a file URL', testFileUrl, execa);301test('execaSync()\'s command argument can be a file URL', testFileUrl, execaSync);302test('execaNode()\'s command argument can be a file URL', testFileUrl, execaNode);303304const testInvalidFileUrl = async (t, execaMethod) => {305 const invalidUrl = new URL('https://invalid.com');306 t.throws(() => {307 execaMethod(invalidUrl);308 }, {code: 'ERR_INVALID_URL_SCHEME'});309};310311test('execa()\'s command argument cannot be a non-file URL', testInvalidFileUrl, execa);312test('execaSync()\'s command argument cannot be a non-file URL', testInvalidFileUrl, execaSync);313test('execaNode()\'s command argument cannot be a non-file URL', testInvalidFileUrl, execaNode);314315const testInvalidCommand = async (t, execaMethod) => {316 t.throws(() => {317 execaMethod(['command', 'arg']);318 }, {message: /must be a string or a file URL/});319};320321test('execa()\'s command argument must be a string or file URL', testInvalidCommand, execa);322test('execaSync()\'s command argument must be a string or file URL', testInvalidCommand, execaSync);323test('execaNode()\'s command argument must be a string or file URL', testInvalidCommand, execaNode);