I have a function that uses a stream pipeline consisting of a fs.createReadStream
a zlib.createGunzip
and an XML parser as per: await pipeline(readStream, gunzipStream, xmlParser)
this code is inside a try/catch and my jest test invokes this function with an invalid gz file which is expected to generate an error in the gunzip stream. The catch statement triggers as expected on the zlib error which then prints it and returns without propagating the error.
Despite catching and handling the error my jest test still fails with the following error:
Error: incorrect header checkn at Zlib.zlibOnError [as onerror] (node:zlib:189:17)n at Zlib.callbackTrampoline (node:internal/async_hooks:128:17)
I have run the test using the debugger and I can see the test executing correctly and returning however when i step into the jest code i can see that it registered the zlib error in the testResults array inside of jestAdapterInit.js
:
const assertionResults = runResult.testResults.map(testResult => {