`@remix-run/web-fetch` causes tests to error after upgrade to jest 28
See original GitHub issueWhat version of Remix are you using?
1.5.1
Steps to Reproduce
- update jest-related dependencies to v28 as per #3400
- add transformIgnorePatterns as per https://github.com/remix-run/remix/pull/3400#issuecomment-1147594562
- run
yarn test:primary
Expected Behavior
Tests should pass
Actual Behavior
TypeError: Class extends value undefined is not a constructor or null
34 | class NodeRequest extends WebRequest {
35 | constructor(info: NodeRequestInfo, init?: NodeRequestInit) {
> 36 | super(info, init as RequestInit);
| ^
37 | }
38 |
This seems to relate to the types output by @remix-run/web-fetch
:
export { default, fetch, Headers, Request, Response } from "./fetch.js";
export { ReadableStream, Blob, FormData } from "./package.js";
//# sourceMappingURL=lib.node.d.ts.map
node_modules/@remix-run/web-fetch/dist/src/lib.node.d.ts
fetch.js and package.js do not exist in the distributed @remix-run/web-fetch
and should either be included or lib.node.d.ts should be pointing to fetch.d.ts
and package.d.ts
Issue Analytics
- State:
- Created a year ago
- Comments:17 (16 by maintainers)
Top Results From Across the Web
Progressive Enhancement with Remix
Remix makes progressively enhancing web sites/web apps incredibly simple. ... Vitest is a testing framework, similar to Jest, but way faster, built on...
Read more >Setup - Testing Library
In these docs we'll demonstrate configuring Jest, but you should be able to do similar things with any testing framework (React Testing Library ......
Read more >remix-run/web-fetch - NPM Package Overview - Socket.dev
@remix-run/web-fetch@4.3.2. Patch Changes. 3b9b384: Memory leak caused by unregistered listeners. Solution was copied from a node-fetch pr.
Read more >Error [ERR_REQUIRE_ESM]: require() of ES Module not ...
The node-fetch latest version doesn't use the require() syntax to import the package. You need to go to your package.json and type
Read more >cannot read properties of undefined (reading 'pathname') jest ...
updated my custom JS transformer to use babel 7 stuff. When I run my tests, I get the following error: ○ ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Changing the order to
Still results in the same issue, though
It is fixed as before. I’d read about the types export recently too - I’ll update my PR to do that.
I haven’t completely traced the source of the issue but it seems changing
to
…in the @remix-run/web-fetch package.json seems to resolve this issue.
There are continued Jest issues after this though so I’ll try to keep digging.