output-sync.js
This file
Path
test/io/output-sync.js
35 lines · 1.2 KiB · JavaScript
Last changed by
TweaksSindre Sorhusbefore adoption698a1b8
History of this fileTake it
123456789101112131415161718192021222324252627282930313233343536import assert from 'node:assert/strict';import test from 'node:test';import {assertThrows} from '../helpers/assert.js';import {execaSync} from '../../index.js';import {setFixtureDirectory} from '../helpers/fixtures-directory.js';import {throwingGenerator} from '../helpers/generator.js';import {foobarString} from '../helpers/input.js';
setFixtureDirectory();
test('Handles errors with stdout generator, sync', () => { const cause = new Error(foobarString); const error = assertThrows(() => { execaSync('noop.js', {stdout: throwingGenerator(cause)()}); }); assert.equal(error.cause, cause);});
test('Handles errors with stdout generator, spawn failure, sync', () => { const cause = new Error(foobarString); const error = assertThrows(() => { execaSync('noop.js', {cwd: 'does_not_exist', stdout: throwingGenerator(cause)()}); }); assert.equal(error.failed, true); assert.equal(error.cause.code, 'ENOENT');});
test('Handles errors with stdout generator, subprocess failure, sync', () => { const cause = new Error(foobarString); const error = assertThrows(() => { execaSync('noop-fail.js', ['1'], {stdout: throwingGenerator(cause)()}); }); assert.equal(error.failed, true); assert.equal(error.cause, cause);});