whatwg-fetch and breaking boilerplate tests through yarn rw tests
See original GitHub issueHey 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:
- Created 3 years ago
- Comments:11 (8 by maintainers)
Top 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 >
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
As I noted in a previous comment we had whatwg-fetch because one of our dependencies brought it in.
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.
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 recreatingyarn.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)node_modules
andyarn.lock
and then ranyarn
whatwg-fetch
in my newyarn.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:
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.