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
Problem importing Clarity components in Jest Unit Tests #194
Comments
Hi @ngfelixl, Take a look at the discussion and the solution here -> vmware-archive/clarity#6310 Let us know if the solution didn't work and what happened so we can investigate it. |
Hi @bbogdanov, thanks for the suggestion. However when I change the transformIgnorePatterns: [
'node_modules/(?!(@cds|@lit|lit|ramda|.*\\.mjs$))'
], I receive a different output. But still not working. When I run the testing command it says:
NX sets up the repository with the Jest types as suggested in the linked thread. I've found several threads for this issue so far and all say that it's related to the |
Happy new year everyone! Unfortunately, I could not find any solutions. @bbogdanov do you have any additional ideas? Thank you! |
I met the same issue. |
@ngfelixl I think I found a solution. You can take a look at https://github.com/wghglory/nx-vmware/blob/main/apps/seed/jest.config.ts. The key thing is to map
|
Hey @wghglory thank you! Unfortunately, the repository seems to be private. Only with the |
@ngfelixl I just changed it to public. Yes, only
My workspace doesn't install |
Heyhey, the solution works with Jest 28. In the demo repository we've used Jest 28, however in our real repo we've used Jest 27. So the combination of
works. Still one remark: The transformIgnorePattern might be wrong as the "or" includes any mjs files (see |
Hi there 👋, this is an automated message. To help Clarity keep track of discussions, we automatically lock closed issues after 14 days. Please look for another open issue or open a new issue with updated details and reference this one as necessary. |
Describe the bug
When working with Angular in an NX workspace and writing unit tests with Jest I can not import Clarity components without braking the tests.
How to reproduce
I am using an NX workspace with Angular preset and install @cds packages.
Then, if a clarity component is part of a Jest unit test, for example:
It is throwing:
Here is a demo repository https://github.com/ngfelixl/clarity-jest-test
Expected behavior
I would expect that the components can be used and imported in Jest unit tests.
Versions
Clarity project:
Clarity version:
Framework:
Framework version:
Device:
The text was updated successfully, but these errors were encountered: