Skip to content
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

Cannot find module 'react-cheetah-grid' in Jest test #377

Open
JWesorick opened this issue Jul 20, 2022 · 4 comments
Open

Cannot find module 'react-cheetah-grid' in Jest test #377

JWesorick opened this issue Jul 20, 2022 · 4 comments

Comments

@JWesorick
Copy link
Contributor

react-cheetah-grid is working great with normal setup and a dev server. But when I go to write tests with Jest I get Cannot find module 'react-cheetah-grid' from 'src/components/Grid/index.js'. Again this is only in tests and imports fine from the same component when running on local dev server.

@ota-meshi
Copy link
Member

Thank you for posting issue.

There may be a compatibility issue with jest-resolver. Can you try adding the following field to the react-cheetah-grid package.json and let me know the result?

  "type": "module",
  "main": "dist/react-cheetah-grid.es.js",

If that works, I think we can add those fields and release.

@JWesorick
Copy link
Contributor Author

Ok that mostly worked. Jest then recognizes it as a module. But then my specs are still written as CommonJS so I had to add

"transformIgnorePatterns": [
  "/node_modules/(?!react-cheetah-grid)"
 ]

to my jest config to compile it. I think if my specs were written in the experimental ECMAScript way it would just work.

@ota-meshi
Copy link
Member

@shibukawa What do you think about adding fields to package.json?

@shibukawa
Copy link
Contributor

Looks good.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants