Skip to content
Myr

node.js

This file

Path

test/node.js

46 lines · 1.2 KiB · JavaScript

Last changed by

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

History of this file

Take it

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

lines 1–46why, one step back
1import test from 'ava';
2import pEvent from 'p-event';3import path from 'path';4import execa from '..';56process.env.PATH = path.join(__dirname, 'fixtures') + path.delimiter + process.env.PATH;78test('node()', async t => {9 const {exitCode} = await execa.node('test/fixtures/noop');10 t.is(exitCode, 0);11});1213test('node pipe stdout', async t => {14 const {stdout} = await execa.node('test/fixtures/noop', ['foo'], {15 stdout: 'pipe'16 });1718 t.is(stdout, 'foo');19});2021test('node correctly use nodePath', async t => {22 const {stdout} = await execa.node(process.platform === 'win32' ? 'hello.cmd' : 'hello.sh', {23 stdout: 'pipe',24 nodePath: process.platform === 'win32' ? 'cmd.exe' : 'bash',25 nodeArguments: process.platform === 'win32' ? ['/c'] : []26 });2728 t.is(stdout, 'Hello World');29});3031test('node pass on nodeArguments', async t => {32 const {stdout} = await execa.node('console.log("foo")', {33 stdout: 'pipe',34 nodeArguments: ['-e']35 });3637 t.is(stdout, 'foo');38});3940test('node\'s forked script has a communication channel', async t => {41 const subprocess = execa.node('test/fixtures/send');42 subprocess.send('ping');4344 const message = await pEvent(subprocess, 'message');45 t.is(message, 'pong');46});