Skip to content

Commit 7fd01a6

Browse files
committed
test: improve code coverage for streams/duplexify
1 parent 6847fec commit 7fd01a6

File tree

1 file changed

+14
-9
lines changed

1 file changed

+14
-9
lines changed

test/parallel/test-stream-duplex-from.js

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -252,15 +252,20 @@ const { Blob } = require('buffer');
252252

253253
// Ensure that given readable stream that throws an error it calls destroy
254254
{
255-
const myErrorMessage = 'error!';
256-
const duplex = Duplex.from(Readable({
257-
read() {
258-
throw new Error(myErrorMessage);
259-
}
260-
}));
261-
duplex.on('error', common.mustCall((msg) => {
262-
assert.strictEqual(msg.message, myErrorMessage);
263-
}));
255+
// As throwing exceptions on readable streams works only for Node v17+
256+
// Ignoring this test on older versions
257+
const isv16Higher = parseInt(process.versions.node.match(/\d{2}/)) > 16;
258+
if (isv16Higher) {
259+
const myErrorMessage = 'error!';
260+
const duplex = Duplex.from(Readable({
261+
read() {
262+
throw new Error(myErrorMessage);
263+
}
264+
}));
265+
duplex.on('error', common.mustCall((msg) => {
266+
assert.strictEqual(msg.message, myErrorMessage);
267+
}));
268+
}
264269
}
265270

266271
// Ensure that given writable stream that throws an error it calls destroy

0 commit comments

Comments
 (0)