-
Notifications
You must be signed in to change notification settings - Fork 98
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
[BUG] Cannot be imported in Jest with Next.js #240
Comments
Hi, better try to google it, seems like it's common problem with NextJs. I'm planning to update Nextjs and test with it, but not right now. |
@xian0831 Have you fixed this issue? |
I have resolved the issue.
|
@andrey-shostik Sorry for getting back on this super late. I'm still having issue with your approach. However, if I switch from |
@xian0831 No, I don't use
|
I tested it with NextJs v14.0.1. This is really messed up, it depends on NextJS version, library, your setup and phase of the moon. Steps: 1. Install testing library and deps 2. Create
3. Create
5. Create test file:
6. Add test script to |
I was able to get past this error by updating my jest.config.js with these values:
|
Jest can be tricky, recently I just switched to |
Describe the bug
@asmyshlyaev177 Thanks for building this library. I would like to report an issue I'm facing related to testing components that leverage the react-horizontal-scrolling-menu. I'm able to build the app fine, it is just not working with Jest unit test.
To Reproduce
There is not issue when using the library so there is nothing to reproduce.
I suspect the issue might have something to do with the Jest transform.This is the config I have.
When I run the test, this is what I get
SyntaxError: Cannot use import statement outside a module
Expected behavior
Successfully rendering by Jest using
jsdom
Screenshots
If applicable, add screenshots to help explain your problem.
Desktop (please complete the following information):
Additional context
Someone else had anther import issue. I suspect it is somewhat related to this issue. However, I can't confirm that. Again, thanks for building the library.
The text was updated successfully, but these errors were encountered: