-
Notifications
You must be signed in to change notification settings - Fork 127
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
Jests tests cannot execute imports inside circuit-ui components #662
Comments
Thanks for filing an issue @AndriyOnyshchenko. Please use an issue template next time your file an issue — it ensures that all relevant information is included so that we can help you faster and the consistent format helps others to browse the issues. It seems like Jest isn't able to parse the Circuit UI code, likely because we changed how it is transpiled in v2 (see the migration guide). Try including Circuit UI in Jest's transpilation by excluding it from the
From jestjs/jest#6229 (comment)
You could try |
@connor-baer I have added current line |
@AndriyOnyshchenko Hm, that's too bad. I would need to look at the code/project to be able to debug it further. Do you have a reproducible test case? Can you share the project? |
When importing a named export, Jest got confused and tried to access the property on the default export. ISSUES CLOSED: #662 bugfix/default-vs-named-export
When importing a named export, Jest got confused and tried to access the property on the default export. ISSUES CLOSED: #662
🎉 This issue has been resolved in version 2.1.0-canary.3 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Update for future reference: @AndriyOnyshchenko provided access to the project which enabled me to debug the issue further. It turned out the problem wasn't solved with the bugfix above. Rather, it was the configuration for absolute import paths that was too greedy. It matched all imports starting with jest.config.js - Components: '<rootDir>/client/static/react/components/',`
+ '^Components/(.*)$': '<rootDir>/client/static/react/components/$1', |
🎉 This issue has been resolved in version 2.1.0-beta.1 🎉 The release is available on: Your semantic-release bot 📦🚀 |
🎉 This issue has been resolved in version 2.1.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
First problem I faced is that imports from index file not working in tests (like this
import { Toggle } from '@sumup/circuit-ui'
). In this case import statement returnsundefined
. I fixed it by changing path toimport Toggle from '@sumup/circuit-ui/dist/es/components/Toggle/Toggle';
Right now jest cannot import modules inside circuit component
/node_modules/@sumup/circuit-ui/dist/es/components/Toggle/Toggle.js:15 import React from 'react'; SyntaxError: Cannot use import statement outside a module
jest.config.js
babel.config.json
package.json dependencies
The text was updated successfully, but these errors were encountered: