duration.js
This file
Path
test/return/duration.js
61 lines · 1.8 KiB · JavaScript
Last changed by
Upgrade xo (#980)ehmickybefore adoptionccfa412
History of this fileTake it
Add `result|error.durationMs` (#896)ehmickybefore adoption7088091
lines 1–2why, one step back1import test from 'ava';2import {execa, execaSync} from '../../index.js';Upgrade xo (#980)ehmickybefore adoptionccfa412
line 3why, one step back3import {setFixtureDirectory} from '../helpers/fixtures-directory.js';Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343
line 4why, one step back4import {getEarlyErrorSubprocess, getEarlyErrorSubprocessSync} from '../helpers/early-error.js';Add `result|error.durationMs` (#896)ehmickybefore adoption7088091
line 5why, one step back5Upgrade xo (#980)ehmickybefore adoptionccfa412
line 6why, one step back6setFixtureDirectory();Add `result|error.durationMs` (#896)ehmickybefore adoption7088091
lines 7–37why, one step back78const assertDurationMs = (t, durationMs) => {9 t.is(typeof durationMs, 'number');10 t.true(Number.isFinite(durationMs));11 t.not(durationMs, 0);12 t.true(durationMs > 0);13};1415test('result.durationMs', async t => {16 const {durationMs} = await execa('empty.js');17 assertDurationMs(t, durationMs);18});1920test('result.durationMs - sync', t => {21 const {durationMs} = execaSync('empty.js');22 assertDurationMs(t, durationMs);23});2425test('error.durationMs', async t => {26 const {durationMs} = await t.throwsAsync(execa('fail.js'));27 assertDurationMs(t, durationMs);28});2930test('error.durationMs - sync', t => {31 const {durationMs} = t.throws(() => {32 execaSync('fail.js');33 });34 assertDurationMs(t, durationMs);35});3637test('error.durationMs - early validation', async t => {Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343
line 38why, one step back38 const {durationMs} = await t.throwsAsync(getEarlyErrorSubprocess());Add `result|error.durationMs` (#896)ehmickybefore adoption7088091
lines 39–42why, one step back39 assertDurationMs(t, durationMs);40});4142test('error.durationMs - early validation, sync', t => {Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343
line 43why, one step back43 const {durationMs} = t.throws(getEarlyErrorSubprocessSync);Add `result|error.durationMs` (#896)ehmickybefore adoption7088091
lines 44–61why, one step back44 assertDurationMs(t, durationMs);45});4647test('error.durationMs - unpipeSignal', async t => {48 const {durationMs} = await t.throwsAsync(execa('noop.js').pipe('stdin.js', {signal: AbortSignal.abort()}));49 assertDurationMs(t, durationMs);50});5152test('error.durationMs - pipe validation', async t => {53 const {durationMs} = await t.throwsAsync(execa('noop.js').pipe(false));54 assertDurationMs(t, durationMs);55});5657test.serial('result.durationMs is accurate', async t => {58 const minDurationMs = 1e3;59 const {durationMs} = await execa('delay.js', [minDurationMs]);60 t.true(durationMs >= minDurationMs);61});