Skip to content

Commit 78e0cb9

Browse files
sreepurnajastiMylesBorins
authored andcommitted
test: use common module API in test-child-process-exec-stdout-stderr-data-string
PR-URL: #17751 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Yuta Hiroto <hello@about-hiroppy.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Jon Moss <me@jonathanmoss.me> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
1 parent 1a966f1 commit 78e0cb9

File tree

1 file changed

+4
-14
lines changed

1 file changed

+4
-14
lines changed

test/parallel/test-child-process-exec-stdout-stderr-data-string.js

+4-14
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,10 @@ const common = require('../common');
44
const assert = require('assert');
55
const exec = require('child_process').exec;
66

7-
let stdoutCalls = 0;
8-
let stderrCalls = 0;
9-
107
const command = common.isWindows ? 'dir' : 'ls';
11-
exec(command).stdout.on('data', (data) => {
12-
stdoutCalls += 1;
13-
});
148

15-
exec('fhqwhgads').stderr.on('data', (data) => {
16-
assert.strictEqual(typeof data, 'string');
17-
stderrCalls += 1;
18-
});
9+
exec(command).stdout.on('data', common.mustCallAtLeast());
1910

20-
process.on('exit', () => {
21-
assert(stdoutCalls > 0);
22-
assert(stderrCalls > 0);
23-
});
11+
exec('fhqwhgads').stderr.on('data', common.mustCallAtLeast((data) => {
12+
assert.strictEqual(typeof data, 'string');
13+
}));

0 commit comments

Comments
 (0)