-
Notifications
You must be signed in to change notification settings - Fork 304
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
[Bug]: Unexpected value 'Module' imported by the module 'DynamicTestModule'. Please add an @NgModule annotation - while Module from library present in transformIgnorePatterns #2158
Comments
@ahnpnl yes, I did, I started with it, but there are always the same or similiar issues, mainly comming from node_modules |
The error I can see coming from a library you are using |
No, this isnt a library, its an app that I try to use the jest in |
This is the part if you want to use ESM mode (The title "Use ES modules" seems to be not clear enough) In your case, If your project doesn't have any custom config on transforming files, perhaps you can compare your project config with example project https://github.com/thymikee/jest-preset-angular/blob/main/examples/example-app-v13/jest.config.js? Another way is configuring |
I'd recommend to keep It's hard to check about this without a repo. Maybe you can somehow replicate the issue in the |
@ahnpnl brother, i added this to the mjs config but i get those errors now: |
I can see that you are running Jest in ESM mode. The 2nd screenshot has a lib called Moving to ESM mode is a very big thing btw. Normally I make CJS mode work first before trying out ESM mode. |
@ahnpnl thank u for your patience and responding to me, I managed to get past the config with your guidance and tests are almost working, I have one issue left to which I cannot comprehend and to which I cannot find a clear answer I get this error while trying to use modules from my components library This is how my library is in dist folder: (I think it may be related) As I mentioned before, I have issue with running ngcc which produces following error Could you perhaps point me to direction I should take to resolve this? |
Bumping to angular ver 14 didnt resolve nothing also |
I'm sorry I was busy. Now coming back to this I lost the context of what we've tried |
Version
13.1.1
Steps to reproduce
Expected behavior
There are so much conflicting information around from previous and newer preset versions, I could not find one clear sentence on exactly what to do with these kind of errors. It should either work OOTB or at least have a clear information what to add to where, as ive tried to add transformIgnorePatterns or globals and it does nothing or produces other errors.
Actual behavior
SyntaxError: Unexpected token 'export'
with this config:
As I understand something with modules changed and I should transform or not dist files from node_modules?
Additional context
There are at least 2 big projects I need to be bumped up regarding angular version and jest, they use variety of dependencies and it is really quite problematic not to know what to do. Ive also tried bumping to ver 15 of angular but that changed nothing, same errors, same behavior. I was careful about using proper dep versions from examples. What should I do? At least a ballpark advice or clear explanation of change in mechanisms would be very welcomed.
Environment
The text was updated successfully, but these errors were encountered: