[特性]: 允许在测试超时时监听 `AbortSignal`
作者: dmurvihill创建于 2025年8月29日更新于 2026年9月15日
标签:rocket: Feature RequestStale
Naive implementation:
test('MyWritableStream should eventually process all records', async () => {
const data: Iterable<unknown> = generateTooMuchTestData(); // too much to process
const myWritableStream = new MyWritableStream();
await Promise.all([
pipeline(stream.Readable.from(data), myWritableStream); // pipeline continues running
runFakeTimersUntilStreamCloses(myWritableStream),
]);
expect(new Set(myWritableStream.processedData)).toStrictEqual(new Set(data));
}, 1, /* not enough time */);
If the test times out, the pipeline continues running:
ReferenceError: You are trying to access a property or method of the Jest environment after it has been torn down. From lib/stream.spec.ts.
This ought to fix it, but seems like a kludge:
内容来源: jestjs/jest