question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

`@remix-run/web-fetch` causes tests to error after upgrade to jest 28

See original GitHub issue

What version of Remix are you using?

1.5.1

Steps to Reproduce

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:open
  • Created a year ago
  • Comments:17 (16 by maintainers)

github_iconTop GitHub Comments

2reactions
penxcommented, Jun 6, 2022

Changing the order to

      "types": "./dist/src/lib.node.d.ts",
      "browser": "./src/lib.js",
      "require": "./dist/lib.node.cjs",
      "import": "./src/lib.node.js"

Still results in the same issue, though

      "types": "./dist/src/lib.node.d.ts",
      "require": "./dist/lib.node.cjs",
      "import": "./src/lib.node.js",
      "browser": "./src/lib.js"

It is fixed as before. I’d read about the types export recently too - I’ll update my PR to do that.

2reactions
penxcommented, Jun 6, 2022

I haven’t completely traced the source of the issue but it seems changing

    ".": {
      "browser": "./src/lib.js",
      "require": "./dist/lib.node.cjs",
      "import": "./src/lib.node.js",
      "types": "./dist/src/lib.node.d.ts"
    },

to

    ".": {
      "require": "./dist/lib.node.cjs",
      "import": "./src/lib.node.js",
      "types": "./dist/src/lib.node.d.ts",
      "browser": "./src/lib.js"
    },

…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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found