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.

whatwg-fetch and breaking boilerplate tests through yarn rw tests

See original GitHub issue

Hey everyone, I see this has come up a few times before, notably in #1264

I am still getting these errors even after running yarn rw upgrade about five minutes ago.

yarn rw test is failing with this error:

  ● Test suite failed to run

    Cannot find module 'whatwg-fetch' from '../node_modules/@redwoodjs/core/dist/configs/browser/jest.setup.js'

      at Resolver.resolveModule (../node_modules/jest-resolve/build/index.js:306:11)
      at Object.<anonymous> (../node_modules/@redwoodjs/core/dist/configs/browser/jest.setup.js:5:1)

Looks like I’m running v0.21.0. All of my web tests are failing, including the boilerplate ones from running the page generator like: yarn rw g page home. API tests are all fine.

Are there additional steps I need to take in upgrading, beyond yarn rw upgrade? Or is something still broken here? Thank you!

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:11 (8 by maintainers)

github_iconTop GitHub Comments

2reactions
Tobbecommented, Jan 12, 2021

As I noted in a previous comment we had whatwg-fetch because one of our dependencies brought it in.

=> Found "whatwg-fetch@3.5.0"
info Reasons this module exists
   - "_project_#api#@redwoodjs#api#graphql-tools#@graphql-tools#relay-operation-optimizer#relay-compiler#fbjs#isomorphic-fetch" depends on it
   - Hoisted from "_project_#api#@redwoodjs#api#graphql-tools#@graphql-tools#relay-operation-optimizer#relay-compiler#fbjs#isomorphic-fetch#whatwg-fetch"

If you look in that chain of packages you’ll find fbjs.

In April of last year they replaced isomorphic-fetch with cross-fetch, which doesn’t have a dependency on whatwg-fetch

https://github.com/facebook/fbjs/commit/16620e3623fd46b435313abd639b86313facb7b8#diff-7e0047660b998823aee877b216662b68226c4d851056cc51f115fc3a1b6589d9

This was released as fbjs 2.0.0 (up from 1.0.0) in July 2020. And then fbjs 3.0.0 was released in October.

Redwood’s dependencies have now updated to use fbjs 3, and so we no longer get whatwg-fetch. This is the reason this doesn’t work at all anymore.

1reaction
thedavidpricecommented, Jan 12, 2021

Wow, gents. This one is bonkers. I cloned the repo and took a look (thanks for providing @ogdenstudios). The package isn’t there. Removing node_modules and recreating yarn.lock does not resolve. I also upgraded to v0.21.1, repeated the process, and still. no. whatwg-fetch package.

Here’s where it got even more fun. --> I have an existing project that 1) runs test successfully and 2) has whatwg-fetch in the lockfile. (Running v0.21.1)

  • I deleted node_modules and yarn.lock and then ran yarn
  • ERROR: no whatwg-fetch in my new yarn.lock

@peterp I’m I correct in thinking there’s something missing from our v0.21.1 packages? Must be, right? We’ve included it:

  1. here in the root package.json
  2. and here in core/package.json

So very confused…

Workaround

@ogdenstudios to complete your project you can manually add this package to your project’s dev dependencies.

  • yarn add -WD whatwg-fetch
  • rw test should then work. Some tests are failing but everything is running correctly.
Read more comments on GitHub >

github_iconTop Results From Across the Web

How to test code that is using whatwg-fetch with mocha?
I'm using https://github.com/github/fetch in my app, which works fine but I would like to test my code with Mocha and babel since I'm...
Read more >
Testing | RedwoodJS Docs
By default, starting Jest via yarn rw test will start a watch process that monitors your files for changes and re-runs the test(s)...
Read more >
Testing custom react hooks that use fetch (or other async ...
I'm using useRef(true) to make sure it doesn't make a call on it's first render and useState to update the error/data state which...
Read more >
Debian -- Пакеты программ в "sid", Подсекция javascript
JavaScript utility for merging multiple objects into one. libjs-microplugin.js (0.0.3+dfsg-1.1): Lightweight plugin / dependency system for libraries; libjs- ...
Read more >
ChangeLog.openSUSE-Leap-15.3-x86_64 ... - BYU Linux Club
+ * Bug fixes +- Updates since 2.3.1 + * Infrastructure + * Documentation in Doxygen format + * Unit test support +...
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