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

Function assertCanceledPipeReader

test/pipe/methods.js:378–398  ·  view source on GitHub ↗
(t, getReader, shouldAbortBeforePipe = false)

Source from the content-addressed store, hash-verified

376});
377
378const assertCanceledPipeReader = async (t, getReader, shouldAbortBeforePipe = false) => {
379 const abortController = new AbortController();
380 if (shouldAbortBeforePipe) {
381 abortController.abort();
382 }
383
384 const source = execa('stdin.js');
385 const destination = execa('stdin.js', {all: true});
386 t.teardown(async () => {
387 await cleanupSubprocesses(source, destination);
388 });
389
390 const piped = source.pipe(destination, {unpipeSignal: abortController.signal});
391 const readerPromise = t.throwsAsync(getReader(piped), {message: /Pipe canceled/});
392
393 if (!shouldAbortBeforePipe) {
394 abortController.abort();
395 }
396
397 await assertSettles(t, readerPromise, 200);
398};
399
400test('The .pipe() return value .readable() waits for pipe cancellation', async t => {
401 await assertCanceledPipeReader(t, piped => text(piped.readable()));

Callers 1

methods.jsFile · 0.85

Calls 2

cleanupSubprocessesFunction · 0.85
assertSettlesFunction · 0.85

Tested by

no test coverage detected