Skip to content

Commit 7cd59d9

Browse files
committed
test: expect AbortError for stream iter broadcast signal abort
1 parent 7954266 commit 7cd59d9

1 file changed

Lines changed: 12 additions & 10 deletions

File tree

test/parallel/test-stream-iter-broadcast-from.js

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -70,11 +70,12 @@ async function testAbortSignal() {
7070

7171
ac.abort();
7272

73-
const batches = [];
74-
for await (const batch of consumer) {
75-
batches.push(batch);
76-
}
77-
assert.strictEqual(batches.length, 0);
73+
await assert.rejects(async () => {
74+
// eslint-disable-next-line no-unused-vars
75+
for await (const _ of consumer) {
76+
assert.fail('Should not reach here');
77+
}
78+
}, { name: 'AbortError' });
7879
}
7980

8081
async function testAlreadyAbortedSignal() {
@@ -84,11 +85,12 @@ async function testAlreadyAbortedSignal() {
8485
const { broadcast: bc } = broadcast({ signal: ac.signal });
8586
const consumer = bc.push();
8687

87-
const batches = [];
88-
for await (const batch of consumer) {
89-
batches.push(batch);
90-
}
91-
assert.strictEqual(batches.length, 0);
88+
await assert.rejects(async () => {
89+
// eslint-disable-next-line no-unused-vars
90+
for await (const _ of consumer) {
91+
assert.fail('Should not reach here');
92+
}
93+
}, { name: 'AbortError' });
9294
}
9395

9496
// =============================================================================

0 commit comments

Comments
 (0)