Skip to content
Myr

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 file

Take it

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

TweaksSindre Sorhusbefore adoption698a1b8

lines 1–3why, one step back
1import assert from 'node:assert/strict';
2import test from 'node:test';3import {assertThrows} from '../helpers/assert.js';

100% test coverage (#1018)ehmickybefore adoption9f65b86

lines 4–10why, one step back
4import {execaSync} from '../../index.js';
5import {setFixtureDirectory} from '../helpers/fixtures-directory.js';6import {throwingGenerator} from '../helpers/generator.js';7import {foobarString} from '../helpers/input.js';89setFixtureDirectory();10

TweaksSindre Sorhusbefore adoption698a1b8

line 11why, one step back
11test('Handles errors with stdout generator, sync', () => {

100% test coverage (#1018)ehmickybefore adoption9f65b86

line 12why, one step back
12 const cause = new Error(foobarString);

TweaksSindre Sorhusbefore adoption698a1b8

line 13why, one step back
13 const error = assertThrows(() => {

100% test coverage (#1018)ehmickybefore adoption9f65b86

lines 14–15why, one step back
14 execaSync('noop.js', {stdout: throwingGenerator(cause)()});
15 });

TweaksSindre Sorhusbefore adoption698a1b8

line 16why, one step back
16 assert.equal(error.cause, cause);

100% test coverage (#1018)ehmickybefore adoption9f65b86

lines 17–18why, one step back
17});
18

TweaksSindre Sorhusbefore adoption698a1b8

line 19why, one step back
19test('Handles errors with stdout generator, spawn failure, sync', () => {

100% test coverage (#1018)ehmickybefore adoption9f65b86

line 20why, one step back
20 const cause = new Error(foobarString);

TweaksSindre Sorhusbefore adoption698a1b8

line 21why, one step back
21 const error = assertThrows(() => {

100% test coverage (#1018)ehmickybefore adoption9f65b86

lines 22–23why, one step back
22 execaSync('noop.js', {cwd: 'does_not_exist', stdout: throwingGenerator(cause)()});
23 });

TweaksSindre Sorhusbefore adoption698a1b8

lines 24–25why, one step back
24 assert.equal(error.failed, true);
25 assert.equal(error.cause.code, 'ENOENT');

100% test coverage (#1018)ehmickybefore adoption9f65b86

lines 26–27why, one step back
26});
27

TweaksSindre Sorhusbefore adoption698a1b8

line 28why, one step back
28test('Handles errors with stdout generator, subprocess failure, sync', () => {

100% test coverage (#1018)ehmickybefore adoption9f65b86

line 29why, one step back
29 const cause = new Error(foobarString);

TweaksSindre Sorhusbefore adoption698a1b8

line 30why, one step back
30 const error = assertThrows(() => {

100% test coverage (#1018)ehmickybefore adoption9f65b86

lines 31–32why, one step back
31 execaSync('noop-fail.js', ['1'], {stdout: throwingGenerator(cause)()});
32 });

TweaksSindre Sorhusbefore adoption698a1b8

lines 33–34why, one step back
33 assert.equal(error.failed, true);
34 assert.equal(error.cause, cause);

100% test coverage (#1018)ehmickybefore adoption9f65b86

line 35why, one step back
35});