async.js
This file
Path
test/async.js
36 lines · 981 bytes · JavaScript
Last changed by
Split files (#837)ehmickybefore adoption672c2d7
History of this fileTake it
12345678910111213141516171819202122232425262728293031323334353637import process from 'node:process';import test from 'ava';import {execa, execaSync} from '../index.js';import {setFixtureDir} from './helpers/fixtures-dir.js';
setFixtureDir();
const isWindows = process.platform === 'win32';
if (isWindows) { test('execa() - cmd file', async t => { const {stdout} = await execa('hello.cmd'); t.is(stdout, 'Hello World'); });
test('execa() - run cmd command', async t => { const {stdout} = await execa('cmd', ['/c', 'hello.cmd']); t.is(stdout, 'Hello World'); });}
test('skip throwing when using reject option', async t => { const {exitCode} = await execa('fail.js', {reject: false}); t.is(exitCode, 2);});
test('skip throwing when using reject option in sync mode', t => { const {exitCode} = execaSync('fail.js', {reject: false}); t.is(exitCode, 2);});
test('execa() returns a promise with pid', async t => { const subprocess = execa('noop.js', ['foo']); t.is(typeof subprocess.pid, 'number'); await subprocess;});