MCPcopy Create free account
hub / github.com/sindresorhus/execa / assertUnhandledRejection

Function assertUnhandledRejection

test/pipe/sequence.js:17–32  ·  view source on GitHub ↗
(t, pipePromise, unhandledRejectionPromise)

Source from the content-addressed store, hash-verified

15const timeoutSymbol = Symbol('timeout');
16
17const assertUnhandledRejection = async (t, pipePromise, unhandledRejectionPromise) => {
18 const result = await Promise.race([
19 unhandledRejectionPromise,
20 setTimeout(500, timeoutSymbol),
21 ]);
22
23 t.not(result, timeoutSymbol);
24
25 if (result === timeoutSymbol) {
26 return;
27 }
28
29 const [reason, unhandledPromise] = result;
30 t.is(unhandledPromise, pipePromise);
31 t.regex(reason.message, /Command failed with exit code 2/);
32};
33
34const assertUnhandledPipePromise = async (t, {destinationOptions = {}, inspectPipePromise} = {}) => {
35 const source = execa('fail.js');

Callers 2

sequence.jsFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected