New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Regression in 12.0.8 for jest: TypeError: require.resolveWeak is not a function #33476
Comments
Based on your reproduction, I could not reproduce this issue. Could you create one that I can have a look at? On |
We see the same issue in our code base (closed source, sorry): with |
Hi, @Parnswir, thanks! Please create a small public reproduction then 🙏 I cannot see the issue, so it might be related to your project specifically. Try reducing the number of pages/components/code until a point it can be shared and the issue still reproduces. Here is a good resource on this topic. |
https://codesandbox.io/s/next-dynamic-22ejz if you fork it on codesandbox, you can run Often, when the codesandbox container hangs; you can restart the next server from the menu on the left: |
Hmm. Thanks for the CodeSandbox, it is helpful! I recognized you did not follow the test setup from https://nextjs.org/docs/testing Applying those seems to solve the problem. Could you try it? @zmarty are you using a custom/Babel setup for your test environment? Could you share it? |
What exactly are you referring to or what exactly did you changed in the codesandbox to make the test run? Can you provide a link? |
So far we have tried to repro this on an empty Next.js instance and we can't. We stopped using a custom babel setup for the website entirely a few versions ago. I do see we use some custom webpack config in next.config.js, so we'll be looking at that as well. Inside the unit tests folder I only see that we set up some mocks. |
We also tried on an the https://github.com/vercel/next.js/tree/canary/examples/with-jest example and there it works. Unfortunately we still need babel, otherwise we cannot use jest's automock functionality. I've forked and provided an example here:
|
@duc-gp Do note we provide a babel setup as well: |
@balazsorban44 thanks, ive just checked out the setup you mentioned and added a simple test: when you run |
what exactly did you do to try to reproduce this? from what setup is your screenshot from?
edit: I just tried the same steps on another machine and could reproduce this as well node versions I've tried:
|
I tried a totally clean project again with |
Thank you for reporting this. I was upgrading a project to Next.js 12 and the CI just barfed all over with the error On another note, the Upgrade Guide does not specify the changes that need to be done to setup Jest with the Rust compiler when upgrading to Next 12. It'd be nice to have the docs updated please. |
Found the problem, opening a PR with a new test that covers this case. |
Fixes vercel#33476 I've added the test for this but it passes either way, even when the change to loadable.js is not made.
Fixes #33476 I've added the test for this but it passes either way, even when the change to loadable.js is not made. On the reproduction I was able to reproduce it consistently and it's fixed with this change. ## Bug - [ ] Related issues linked using `fixes #number` - [ ] Integration tests added - [ ] Errors have helpful link attached, see `contributing.md` ## Feature - [ ] Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR. - [ ] Related issues linked using `fixes #number` - [ ] Integration tests added - [ ] Documentation added - [ ] Telemetry added. In case of a feature if it's used or not. - [ ] Errors have helpful link attached, see `contributing.md` ## Documentation / Examples - [ ] Make sure the linting passes by running `yarn lint`
This is released on canary 🎉 Please try it out: |
Works for me 👍🏻 Thanks! |
Fixes vercel#33476 I've added the test for this but it passes either way, even when the change to loadable.js is not made. On the reproduction I was able to reproduce it consistently and it's fixed with this change. ## Bug - [ ] Related issues linked using `fixes #number` - [ ] Integration tests added - [ ] Errors have helpful link attached, see `contributing.md` ## Feature - [ ] Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR. - [ ] Related issues linked using `fixes #number` - [ ] Integration tests added - [ ] Documentation added - [ ] Telemetry added. In case of a feature if it's used or not. - [ ] Errors have helpful link attached, see `contributing.md` ## Documentation / Examples - [ ] Make sure the linting passes by running `yarn lint`
Great 👍 This is out on stable in 12.1 |
This closed issue has been automatically locked because it had no new activity for a month. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you. |
Run
next info
(available from version 12.0.8 and up)What version of Next.js are you using?
12.0.8
What version of Node.js are you using?
16.8.0
What browser are you using?
Edge (Chromium)
What operating system are you using?
Windows 11 Enterprise (by the way, why does next info say I am using Windows 10??)
How are you deploying your application?
On Azure App Service as docker container
Describe the Bug
We have a Next.js website where the unit tests are using Jest. When I try to upgrade the website from Next.js 12.0.7 to 12.0.8 the unit tests which test code that uses dynamic code loading start failing.
It looks to me this is related to this previously closed bug, which would make this a regression for Next.js 12.0.8: TypeError: require.resolveWeak is not a function (jest test) #19862
Example output
Expected Behavior
Tests should pass even if the code they test uses dynamic()
To Reproduce
Run a Jest test where the test code tests some code that uses dynamic() to load some other code.
The text was updated successfully, but these errors were encountered: