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 fileTake it
Require Node.js 12.20 and move to ESM (#478)Minh Nguyenbefore adoption7707880
line 1why, one step back1import process from 'node:process';Add `.node()` method (#200)Guillaume Martignybefore adoptionc2f5edf
line 2why, one step back2import test from 'ava';Minor tweaksSindre Sorhusbefore adoption244e87a
line 3why, one step back3import {pEvent} from 'p-event';Require Node.js 12.20 and move to ESM (#478)Minh Nguyenbefore adoption7707880
line 4why, one step back4import {execaNode} from '../index.js';Re-enable Windows in CI (#500)ehmickybefore adoption071d0a2
line 5why, one step back5import {setFixtureDir} from './helpers/fixtures-dir.js';Add `.node()` method (#200)Guillaume Martignybefore adoptionc2f5edf
line 6why, one step back6Re-enable Windows in CI (#500)ehmickybefore adoption071d0a2
line 7why, one step back7setFixtureDir();Add `.node()` method (#200)Guillaume Martignybefore adoptionc2f5edf
line 8why, one step back8Remove `--inspect` & `--inspect-brk` from `execArgv` (#435)Ward Peetersbefore adoption8fd3f64
lines 9–12why, one step back9async 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 back13 const subprocess = execaNode('console.log("foo")', {14 reject: false,Remove `--inspect` & `--inspect-brk` from `execArgv` (#435)Ward Peetersbefore adoption8fd3f64
lines 15–25why, one step back15 });1617 const {stdout, stderr} = await subprocess;1819 t.is(stdout, 'foo');20 t.is(stderr, '');21 } finally {22 process.execArgv = originalArgv;23 }24}25Add `.node()` method (#200)Guillaume Martignybefore adoptionc2f5edf
line 26why, one step back26test('node()', async t => {Require Node.js 12.20 and move to ESM (#478)Minh Nguyenbefore adoption7707880
line 27why, one step back27 const {exitCode} = await execaNode('test/fixtures/noop.js');Add `.node()` method (#200)Guillaume Martignybefore adoptionc2f5edf
lines 28–31why, one step back28 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 back32 const {stdout} = await execaNode('test/fixtures/noop.js', ['foo'], {33 stdout: 'pipe',Add `.node()` method (#200)Guillaume Martignybefore adoptionc2f5edf
lines 34–39why, one step back34 });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 back40 const {stdout} = await execaNode(process.platform === 'win32' ? 'hello.cmd' : 'hello.sh', {Add `.node()` method (#200)Guillaume Martignybefore adoptionc2f5edf
lines 41–42why, one step back41 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 back43 nodeOptions: process.platform === 'win32' ? ['/c'] : [],Add `.node()` method (#200)Guillaume Martignybefore adoptionc2f5edf
lines 44–48why, one step back44 });4546 t.is(stdout, 'Hello World');47});48Rename `nodeArguments` to `nodeOptions` (#299)ehmickybefore adoptionb979534
line 49why, one step back49test('node pass on nodeOptions', async t => {Require Node.js 12.20 and move to ESM (#478)Minh Nguyenbefore adoption7707880
line 50why, one step back50 const {stdout} = await execaNode('console.log("foo")', {Add `.node()` method (#200)Guillaume Martignybefore adoptionc2f5edf
line 51why, one step back51 stdout: 'pipe',Require Node.js 12.20 and move to ESM (#478)Minh Nguyenbefore adoption7707880
line 52why, one step back52 nodeOptions: ['-e'],Add `.node()` method (#200)Guillaume Martignybefore adoptionc2f5edf
lines 53–56why, one step back53 });5455 t.is(stdout, 'foo');56});Remove `--inspect` & `--inspect-brk` from `execArgv` (#435)Ward Peetersbefore adoption8fd3f64
lines 57–60why, one step back5758test.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 back61 '--inspect',Remove `--inspect` & `--inspect-brk` from `execArgv` (#435)Ward Peetersbefore adoption8fd3f64
lines 62–66why, one step back62);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 back67 '--inspect=9222',Remove `--inspect` & `--inspect-brk` from `execArgv` (#435)Ward Peetersbefore adoption8fd3f64
lines 68–72why, one step back68);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 back73 '--inspect-brk',Remove `--inspect` & `--inspect-brk` from `execArgv` (#435)Ward Peetersbefore adoption8fd3f64
lines 74–78why, one step back74);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 back79 '--inspect-brk=9222',Remove `--inspect` & `--inspect-brk` from `execArgv` (#435)Ward Peetersbefore adoption8fd3f64
lines 80–84why, one step back80);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 back85 const {stdout, stderr} = await execaNode('console.log("foo")', {Remove `--inspect` & `--inspect-brk` from `execArgv` (#435)Ward Peetersbefore adoption8fd3f64
line 86why, one step back86 reject: false,Require Node.js 12.20 and move to ESM (#478)Minh Nguyenbefore adoption7707880
line 87why, one step back87 nodeOptions: ['--inspect', '-e'],Remove `--inspect` & `--inspect-brk` from `execArgv` (#435)Ward Peetersbefore adoption8fd3f64
lines 88–91why, one step back88 });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 back92 },Remove `--inspect` & `--inspect-brk` from `execArgv` (#435)Ward Peetersbefore adoption8fd3f64
line 93why, one step back93);Add `.node()` method (#200)Guillaume Martignybefore adoptionc2f5edf
lines 94–95why, one step back9495test('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 back96 const subprocess = execaNode('test/fixtures/send.js');97 await pEvent(subprocess, 'message');98Add `.node()` method (#200)Guillaume Martignybefore adoptionc2f5edf
lines 99–103why, one step back99 subprocess.send('ping');100101 const message = await pEvent(subprocess, 'message');102 t.is(message, 'pong');103});