-
Notifications
You must be signed in to change notification settings - Fork 28.4k
Page Router with Next 14 and 'use client' does not work with cypress 12.3.0 #58061
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
Comments
|
← Go Back</Link>
</p>
</main>
</div>
)
}">
In ← Go Back</Link>
</p>
</main>
</div>
)
}">
|
|
This issue has been automatically marked as stale due to two years of inactivity. It will be closed in 7 days unless there’s further input. If you believe this issue is still relevant, please leave a comment or provide updated details. Thank you. |
|
This issue has been automatically closed due to two years of inactivity. If you’re still experiencing a similar problem or have additional details to share, please open a new issue following our current issue template. Your updated report helps us investigate and address concerns more efficiently. Thank you for your understanding! |


Link to the code that reproduces this issue
https://github.com/eduardo-villasboas/with-cypress-app
I am getting the error when running next with cypress.
To Reproduce
There are two manners to reproduces the error
Using https://www.npmjs.com/package/start-server-and-test
npm run e2e:headlessthis command will start next in dev mode and run e2e tests using https://www.npmjs.com/package/start-server-and-testRunning next server manually
rm .next -rfrm node_modules/ -rfnpm installnpm run buildnpm run devnpx cypress run --e2e***Note that the errors don't happen always and in the second approach, running manually I got the error in the first executions after deleting the paths .next and node_modules/. In the repo https://github.com/eduardo-villasboas/with-cypress-app, I create two branches next-14-with-app-routing-error-tests and next-14-with-pages-routing-sucess-tests, because I have discovered this error occurs only when using the new nextjs routing system and accessing an component using 'use client' ***
Current vs. Expected behavior
Test app.cy.ts should pass
But I getting the following error. I am attaching a video that the own cypress have recorded.
1) Navigation should navigate to the about page: TypeError: The following error originated from your application code, not from Cypress. > __webpack_require__.n is not a function When Cypress detects uncaught errors originating from your application it will automatically fail the current test. This behavior is configurable, and you can choose to turn this off by listening to the `uncaught:exception` event. https://on.cypress.io/uncaught-exception-from-application at eval (webpack-internal:///app-pages-browser/./app/about/page.tsx:7:108) at <unknown> (app-pages-browser/./app/about/page.tsx http://localhost:3000/_next/static/chunks/app/about/page.js:38:1) at options.factory (http://localhost:3000/_next/static/chunks/webpack.js?v=1699211960328:704:31) at __webpack_require__ (http://localhost:3000/_next/static/chunks/webpack.js?v=1699211960328:37:33) at fn (http://localhost:3000/_next/static/chunks/webpack.js?v=1699211960328:359:21) at requireModule (webpack-internal:///app-pages-browser/./node_modules/next/dist/compiled/react-server-dom-webpack/cjs/react-server-dom-webpack-client.browser.development.js:156:23) at initializeModuleChunk (webpack-internal:///app-pages-browser/./node_modules/next/dist/compiled/react-server-dom-webpack/cjs/react-server-dom-webpack-client.browser.development.js:1357:17) at resolveModuleChunk (webpack-internal:///app-pages-browser/./node_modules/next/dist/compiled/react-server-dom-webpack/cjs/react-server-dom-webpack-client.browser.development.js:1302:5) at eval (webpack-internal:///app-pages-browser/./node_modules/next/dist/compiled/react-server-dom-webpack/cjs/react-server-dom-webpack-client.browser.development.js:1774:14)app.cy.ts.mp4
Verify canary release
Provide environment information
Operating System: Platform: linux Arch: x64 Version: #26~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Thu Jul 13 16:27:29 UTC 2 Binaries: Node: 20.9.0 npm: 10.1.0 Yarn: N/A pnpm: N/A Relevant Packages: next: 14.0.2-canary.12 eslint-config-next: N/A react: 18.2.0 react-dom: 18.2.0 typescript: 5.2.2 Next.js Config: output: N/AWhich area(s) are affected? (Select all that apply)
App Router
Additional context
I see that this issue only occurs when using the app router and it happened because webpack.js sometimes doesn't finish its execution until the test access the function webpack_require.n.
I am not sure if this is a Nextjs issue or Cypress issue, but it works with the same version using the page router, therefore I am opening this issue.
The text was updated successfully, but these errors were encountered: