-
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
Component testing with Next JS 13.4 no longer works after migrating to the "app router" directory structure #26802
Comments
|
I was able to successfully run Cypress I would guess that a reproducible example would need to be shared in order for this to be investigated further. |
My experience was the same as Mikes, a reproduction would be really helpful here. Even with That said, it would make sense to catch up our code to match the latest Next.js practices. |
Right now there doesn't seem to be enough information to reproduce the problem on our end. We'll have to close this issue until we can reproduce it. This does not mean that your issue is not happening - it just means that we do not have a path to move forward. Please open a new issue with a reproducible example and link to this issue. Here are some tips for providing a Short, Self Contained, Correct, Example and our own Troubleshooting Cypress guide. |
I'm coming from #17898 For anyone having this issue after migrating from the pages dir to the appdir, we had the same problem and found out that the error message was caused by a barrel file in our app directory. // forms.ts
export * from './field';
export * from './form';
export * from './input';
export * from './dropzone';
export * from './select';
export * from './color-picker';
export * from './checkbox'; We were using it like this : import { Field, Input } from '../../forms'; We've deleted the barrel file and now import files like this : import { Field } from '../../forms/field';
import { Input } from '../../forms/input'; |
Here is a working repro for the export * issue https://github.com/cwillsea-mtg/cypress-next-export-star-repro If you run As noted above, this error can be bypassed by either creating an empty |
I'm getting a similar issue with the app directory, I don't believe it's exactly the same tho. We're using Next 13.4.7. I've tried creating an empty Is there a workaround here? |
I can confirm that this issue is still happening and seems to be related to barrel exports with |
Any updates regarding this issue? |
confirmed adding an empty |
The issue I think has to do with the |
Does the suggested solution I described fix the issue? |
+1 This also solved the issue form me in
|
Current behavior
The latest release of Next JS https://nextjs.org/blog/next-13-4 includes a change to the recommended folder structure, and removes the previous "pages" directory. This is no longer compatible with the next framework helper built into Cypress, resulting in compilation errors.
The symptoms seem to be identical to #17898, where Cypress previously failed to correctly locate the pages directory.
Same syntax error:
Syntax error: Using `export * from '...'` in a page is disallowed.
I believe the cause for this is https://github.com/cypress-io/cypress/blob/develop/npm/webpack-dev-server/src/helpers/nextHandler.ts#L264 where Cypress expects the pages directory to exist at one of either
/pages
or/src/pages
. It's possible that adding/app
as a possible option would also resolve the issue, but I haven't been able to verify this.The project already had Cypress (specifically component tests) implemented and configured, but it stopped working after migrating to the Next JS app router setup. The workaround I found was to simply create an empty
/pages
directory in the project, this immediately solved the compilation errors, but obviously shouldn't be necessary.Desired behavior
Cypress should correctly handle the lack of a /pages directory within a Next JS application since this is now the recommended folder structure.
Test code to reproduce
I can't currently provide a repo
Cypress Version
latest
Node version
18.x
Operating System
Ubuntu
Debug Logs
No response
Other
No response
The text was updated successfully, but these errors were encountered: