Cannot find module 'react-cheetah-grid' in Jest test
JWesorick opened this issue · 4 comments
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.
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.
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.
@shibukawa What do you think about adding fields to package.json?
Looks good.