-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
Issues with Cypress Component Testing in Next.js v13 #27890
Comments
I am also seeing the same issue related to From debugging, I've noticed the errors stop when I comment out any of my NextJS Server Actions used for form submission. |
For server components, we can just skip using the I still don't have a solution for styles. Tried using a custom mount with the RootLayout component, and it fails the same way. On the bright side, finally locked down a good method to test server componets with CyCT. |
I've been trying to make it work with server actions but without success. I've tried to
but no success in doing so |
Found a solution to Issue1 (styles) thanks to a YouTube comment. We need to add a line Here's the PR that fixes it. |
@raphaelbadia did you ever find a solution to this? I'm thinking it's probably easiest to pass actions down from the server component rather than importing them directly, but it would be nice if we could just stub out the import instead. That article has enough differences (js instead of ts, CRA instead of next, etc) that I'm having a hard time getting it to work. |
@redbmk unfortunately no, we're passing actions as props like you said. :/ |
Current behavior
Overview
As we transition some of our applications to Next.js v13, we are keen to leverage Cypress component testing. However, given the novelty of Next.js v13, we're facing challenges due to the scarcity of resources detailing best practices and the core mechanics of integrating Cypress component tests with this new version.
We've identified two primary issues which may resonate with other users:
Issue 1: CSS Importing in Component Tests
Description:
When attempting to include styles in our Cypress component tests by directly importing the CSS file (e.g.,
import '../app/globals.css'
), we encountered the following error:This error appears to emanate from Next.js's internal handling of CSS and may be conflicting with how Cypress sets up its testing environment.
Reproduction Steps:
Issue 2: Integration of Server Components in Cypress Tests
Description:
When attempting to test a component that makes use of Next.js's new "use server" directive, we encountered an error related to the module
react-server-dom-webpack/client
. This issue arises even when stubbing out the server component functions, indicating a deeper integration challenge.Reproduction Steps:
We are eager to find solutions or workarounds for these issues. Guidance or insights from the Cypress community and maintainers would be greatly appreciated.
/
Desired behavior
We can incorporate styles into component tests with NextJs 13.
We can test components involving 'use server' whether it is a server component or using server code in a client component.
Test code to reproduce
https://github.com/muratkeremozcan/next-13-todo-list
Search for the string "TODO: "
Cypress Version
13.2.0
Node version
18
Operating System
mac, ubuntu (CI), probably Windows as well
Debug Logs
No response
Other
No response
The text was updated successfully, but these errors were encountered: