Skip to content

Commit

Permalink
Add a test about heavy load
Browse files Browse the repository at this point in the history
  • Loading branch information
ehmicky committed Sep 1, 2024
1 parent e55dbd2 commit 45bf14c
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion test/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import test from 'ava';
import nanoSpawn from '../source/index.js';
import {assertSigterm} from './helpers/assert.js';
import {nodePrintStdout, nodeHanging} from './helpers/commands.js';
import {nodePrintStdout, nodeHanging, nodePrint} from './helpers/commands.js';

test('Can pass no arguments', async t => {
const error = await t.throwsAsync(nanoSpawn(...nodeHanging, {timeout: 1}));
Expand Down Expand Up @@ -30,3 +30,11 @@ test('promise.nodeChildProcess is set', async t => {
t.true(Number.isInteger(nodeChildProcess.pid));
await promise;
});

const PARALLEL_COUNT = 100;

test.serial('Can run many times at once', async t => {
const inputs = Array.from({length: PARALLEL_COUNT}, (_, index) => `${index}`);
const results = await Promise.all(inputs.map(input => nanoSpawn(...nodePrint(input))));
t.deepEqual(results.map(({output}) => output), inputs);
});

0 comments on commit 45bf14c

Please sign in to comment.