-
-
Notifications
You must be signed in to change notification settings - Fork 367
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
Ariakit can't be imported when using Create React App and Jest #2400
Comments
Could you please provide a link with the reproduction code (repository, CodeSandbox, StackBlitz)? Anyway, I don't recommend using JSDOM (if you're using it with Jest) to test components that use Ariakit or any other accessible component library. You will need a real browser to test most interactions. |
|
Is there a specific reason why you don't recommend JSDom and Jest for testing? I think Jest (with JSDom) is one of the most popular ways to write unit tests for JavaScript applications. |
Thanks for the reproduction. Looks like it's an issue with Create React App that ships with a custom The last CRA release was over a year ago, and it's super outdated. I don't recommend it for new projects. If you want to keep using it, I suggest ejecting (which would allow you to update the Jest config). Or just use Vite. |
You can use JSDOM, but you'll likely see a lot of We do use JSDOM to test Ariakit components internally, but we have an internal I recommend using a more robust testing framework like Playwright to test your components and pages. |
Current behavior
Steps to reproduce the bug
https://github.com/Eldor901/Ariakit-jest
Expected behavior
Jest tests should not fail
Workaround
Eject and update the
moduleFileExtensions
option to includecjs
.Possible solutions
We can potentially fix this on our build script by including the
.cjs
extension on the package.json files inside the proxy folders:ariakit/scripts/build/utils.js
Lines 263 to 264 in 8e4d7e6
The same way we do here for the main package.json:
ariakit/scripts/build/utils.js
Lines 67 to 68 in 8e4d7e6
The text was updated successfully, but these errors were encountered: