node/test/parallel/test-child-process-send-after-close.js
Ruben Bridgewater 1b2733f272
test: common.expectsError should be a must call
Wrap expectsError in mustCall to make sure it's really called
as expected.

PR-URL: https://github.com/nodejs/node/pull/14088
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
2017-07-09 14:19:13 -04:00

31 lines
723 B
JavaScript

'use strict';
const common = require('../common');
const assert = require('assert');
const cp = require('child_process');
const path = require('path');
const fixture = path.join(common.fixturesDir, 'empty.js');
const child = cp.fork(fixture);
child.on('close', common.mustCall((code, signal) => {
assert.strictEqual(code, 0);
assert.strictEqual(signal, null);
const testError = common.expectsError({
type: Error,
message: 'Channel closed',
code: 'ERR_IPC_CHANNEL_CLOSED'
}, 2);
child.on('error', testError);
{
const result = child.send('ping');
assert.strictEqual(result, false);
}
{
const result = child.send('pong', testError);
assert.strictEqual(result, false);
}
}));