Tests passed locally, failed in CI
Today, two tests passed locally but failed in CI with this error
TypeError: object.stream is not a function The issue was that my machine was running Node 24, while CI was using Node 22.
The tests were running in jsdom, which provides its own Blob implementation. The mock used:
new Response(new Blob(['x']))
Node 24 accepted it, but Node 22 tried to call .stream() on the jsdom Blob, which doesn’t implement it.
The fix was to use new Response('x') It tests the same behavior without depending on the Blob implementation.
I’m also adding an .nvmrc file and an engines field to package.json so the expected Node version is clear. I’ll also start testing locally with the same Node version used in CI.
@devwitheyob
#CI #tips
Today, two tests passed locally but failed in CI with this error
TypeError: object.stream is not a function The issue was that my machine was running Node 24, while CI was using Node 22.
The tests were running in jsdom, which provides its own Blob implementation. The mock used:
new Response(new Blob(['x']))
Node 24 accepted it, but Node 22 tried to call .stream() on the jsdom Blob, which doesn’t implement it.
The fix was to use new Response('x') It tests the same behavior without depending on the Blob implementation.
I’m also adding an .nvmrc file and an engines field to package.json so the expected Node version is clear. I’ll also start testing locally with the same Node version used in CI.
@devwitheyob
#CI #tips