Skip to content
Myr

node.js

This file

Path

test/node.js

103 lines · 2.4 KiB · JavaScript

Last changed by

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

History of this file

Take it

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

line 1why, one step back
1import process from 'node:process';

Add `.node()` method (#200)Guillaume Martignybefore adoptionc2f5edf

line 2why, one step back
2import test from 'ava';

Minor tweaksSindre Sorhusbefore adoption244e87a

line 3why, one step back
3import {pEvent} from 'p-event';

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

line 4why, one step back
4import {execaNode} from '../index.js';

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

line 5why, one step back
5import {setFixtureDir} from './helpers/fixtures-dir.js';

Add `.node()` method (#200)Guillaume Martignybefore adoptionc2f5edf

line 6why, one step back
6

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

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

Add `.node()` method (#200)Guillaume Martignybefore adoptionc2f5edf

line 8why, one step back
8

Remove `--inspect` & `--inspect-brk` from `execArgv` (#435)Ward Peetersbefore adoption8fd3f64

lines 9–12why, one step back
9async function inspectMacro(t, input) {
10 const originalArgv = process.execArgv;11 process.execArgv = [input, '-e'];12 try {

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

lines 13–14why, one step back
13 const subprocess = execaNode('console.log("foo")', {
14 reject: false,

Remove `--inspect` & `--inspect-brk` from `execArgv` (#435)Ward Peetersbefore adoption8fd3f64

lines 15–25why, one step back
15 });
1617 const {stdout, stderr} = await subprocess;1819 t.is(stdout, 'foo');20 t.is(stderr, '');21 } finally {22 process.execArgv = originalArgv;23 }24}25

Add `.node()` method (#200)Guillaume Martignybefore adoptionc2f5edf

line 26why, one step back
26test('node()', async t => {

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

line 27why, one step back
27 const {exitCode} = await execaNode('test/fixtures/noop.js');

Add `.node()` method (#200)Guillaume Martignybefore adoptionc2f5edf

lines 28–31why, one step back
28 t.is(exitCode, 0);
29});3031test('node pipe stdout', async t => {

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

lines 32–33why, one step back
32 const {stdout} = await execaNode('test/fixtures/noop.js', ['foo'], {
33 stdout: 'pipe',

Add `.node()` method (#200)Guillaume Martignybefore adoptionc2f5edf

lines 34–39why, one step back
34 });
3536 t.is(stdout, 'foo');37});3839test('node correctly use nodePath', async t => {

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

line 40why, one step back
40 const {stdout} = await execaNode(process.platform === 'win32' ? 'hello.cmd' : 'hello.sh', {

Add `.node()` method (#200)Guillaume Martignybefore adoptionc2f5edf

lines 41–42why, one step back
41 stdout: 'pipe',
42 nodePath: process.platform === 'win32' ? 'cmd.exe' : 'bash',

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

line 43why, one step back
43 nodeOptions: process.platform === 'win32' ? ['/c'] : [],

Add `.node()` method (#200)Guillaume Martignybefore adoptionc2f5edf

lines 44–48why, one step back
44 });
4546 t.is(stdout, 'Hello World');47});48

Rename `nodeArguments` to `nodeOptions` (#299)ehmickybefore adoptionb979534

line 49why, one step back
49test('node pass on nodeOptions', async t => {

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

line 50why, one step back
50 const {stdout} = await execaNode('console.log("foo")', {

Add `.node()` method (#200)Guillaume Martignybefore adoptionc2f5edf

line 51why, one step back
51 stdout: 'pipe',

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

line 52why, one step back
52 nodeOptions: ['-e'],

Add `.node()` method (#200)Guillaume Martignybefore adoptionc2f5edf

lines 53–56why, one step back
53 });
5455 t.is(stdout, 'foo');56});

Remove `--inspect` & `--inspect-brk` from `execArgv` (#435)Ward Peetersbefore adoption8fd3f64

lines 57–60why, one step back
57
58test.serial(59 'node removes --inspect from nodeOptions when defined by parent process',60 inspectMacro,

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

line 61why, one step back
61 '--inspect',

Remove `--inspect` & `--inspect-brk` from `execArgv` (#435)Ward Peetersbefore adoption8fd3f64

lines 62–66why, one step back
62);
6364test.serial(65 'node removes --inspect=9222 from nodeOptions when defined by parent process',66 inspectMacro,

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

line 67why, one step back
67 '--inspect=9222',

Remove `--inspect` & `--inspect-brk` from `execArgv` (#435)Ward Peetersbefore adoption8fd3f64

lines 68–72why, one step back
68);
6970test.serial(71 'node removes --inspect-brk from nodeOptions when defined by parent process',72 inspectMacro,

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

line 73why, one step back
73 '--inspect-brk',

Remove `--inspect` & `--inspect-brk` from `execArgv` (#435)Ward Peetersbefore adoption8fd3f64

lines 74–78why, one step back
74);
7576test.serial(77 'node removes --inspect-brk=9222 from nodeOptions when defined by parent process',78 inspectMacro,

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

line 79why, one step back
79 '--inspect-brk=9222',

Remove `--inspect` & `--inspect-brk` from `execArgv` (#435)Ward Peetersbefore adoption8fd3f64

lines 80–84why, one step back
80);
8182test.serial(83 'node should not remove --inspect when passed through nodeOptions',84 async t => {

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

line 85why, one step back
85 const {stdout, stderr} = await execaNode('console.log("foo")', {

Remove `--inspect` & `--inspect-brk` from `execArgv` (#435)Ward Peetersbefore adoption8fd3f64

line 86why, one step back
86 reject: false,

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

line 87why, one step back
87 nodeOptions: ['--inspect', '-e'],

Remove `--inspect` & `--inspect-brk` from `execArgv` (#435)Ward Peetersbefore adoption8fd3f64

lines 88–91why, one step back
88 });
8990 t.is(stdout, 'foo');91 t.true(stderr.includes('Debugger listening'));

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

line 92why, one step back
92 },

Remove `--inspect` & `--inspect-brk` from `execArgv` (#435)Ward Peetersbefore adoption8fd3f64

line 93why, one step back
93);

Add `.node()` method (#200)Guillaume Martignybefore adoptionc2f5edf

lines 94–95why, one step back
94
95test('node\'s forked script has a communication channel', async t => {

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

lines 96–98why, one step back
96 const subprocess = execaNode('test/fixtures/send.js');
97 await pEvent(subprocess, 'message');98

Add `.node()` method (#200)Guillaume Martignybefore adoptionc2f5edf

lines 99–103why, one step back
99 subprocess.send('ping');
100101 const message = await pEvent(subprocess, 'message');102 t.is(message, 'pong');103});