Skip to content

Commit 461e2d8

Browse files
committed
Add test for error handling via try/catch with async iterator
https://claude.ai/code/session_01Rx48d2xCMjtzmoynPwet77
1 parent 047145a commit 461e2d8

1 file changed

Lines changed: 16 additions & 0 deletions

File tree

test/examples.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,20 @@ describe('examples', function () {
1414

1515
assert.equal(items.length, 4);
1616
});
17+
18+
it('should surface errors via try/catch when using async iterator', async function () {
19+
var feedparser = new FeedParser();
20+
var feed = __dirname + '/feeds/notafeed.html';
21+
fs.createReadStream(feed).pipe(feedparser);
22+
23+
var caught = null;
24+
try {
25+
for await (const item of feedparser) {} // eslint-disable-line no-unused-vars
26+
} catch (err) {
27+
caught = err;
28+
}
29+
30+
assert.ok(caught instanceof Error);
31+
assert.equal(caught.message, 'Not a feed');
32+
});
1733
});

0 commit comments

Comments
 (0)