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
[Next.js 9.0.2] Shallow rendering issue: App cannot be invoked without 'new' #8175
Comments
Hey @rzschoch, could you test it with the latest canary? There should be a fix for it. |
Hi @huv1k 9.0.3-canary.5 does not fix it, unfortunately. |
That’s @huv1k solution for now (thank you):
|
It is now working fine with the latest canary (9.0.3-canary.6 in my case) and a
|
Same issue in 9.0.3 |
I have the same problem with 9.0.3 on a HOC of the custom _app.ts. I get the same error at super(props) in constructor of HOC. compiled line:
source:
|
The latest canary didn't work for me, but the following did:
|
Just a data point, I was able to resolve this issue with unit testing a custom
|
Still same problem in
It workes when removing both |
Never mind, removing |
I have the same issue. This is mine next.config.js:
and this is babel.rc:
I tried with calling: |
I'm also facing the same issue after updating from 7 to 9.0.5.
Also my next.config.js:
|
after i removed the preset-env in presets, all i had in .babelrc was
and it didn't work After that i changed to
and it works 👍 |
This also worked for me, I replaced
with
|
I'm running into this:
with the following tsconfig.json:
Any ideas? |
In my case, I had a custom webpack config which was using babel loader like this:
and the
This was giving me an error 'App cannot be invoked without new' The error was resolved by either of these:
Did not choose this option as nextjs docs specifically suggest not to add the presets which are already included in 'next/babel'
This was the option we went ahead with, although it is still not clear why this solves the issue. |
Helpful references: - https://github.com/zeit/next.js/blob/master/errors/static-dir-deprecated.md - https://github.com/zeit/next.js/blob/master/errors/opt-out-auto-static-optimization.md - https://github.com/zeit/next.js/blob/master/errors/app-container-deprecated.md - https://github.com/zeit/next.js/blob/canary/UPGRADING.md - https://nextjs.org/blog/next-9 - vercel/next.js#8175
What's the working solution for lerna, nextjs, and babel these days? I'm trying to avoid pre-transpiling my libraries before import, and I've hit a brick wall with every solution here. Here's what I can't get working:
|
This issue has been automatically locked due to no recent activity. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you. |
Bug report
Describe the bug
After updating our app from Next.js 7.0.2 to 9.0.2 enzyme’s shallow rendering (same issue with enzyme’s mount) for the custom
<App>
(_app.is) not working anymore. The local development server is serving the app perfectly fine, though.For experimental purposes we also tried running our tests with Next.js 8.1.0 and the rendering caused no problems.
To Reproduce
Clone the issue repository:
https://github.com/rzschoch/next-9-issues/tree/shallow-issue
npm install
npm run test
TypeError: Class constructor App cannot be invoked without 'new'
Expected behavior
The test in
/src/pagesSpecs/_app.spec.js
should be rendered without issues and compared against the existing snapshot (from Next.js 7.0.2).Screenshots
System information
The text was updated successfully, but these errors were encountered: