-
-
Notifications
You must be signed in to change notification settings - Fork 203
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
Global $localize() function is not loaded in tests context #678
Comments
I guess the solution is to add the import you specified in the default setupJest file provided by the builder. Would you like to make a PR? |
Gave it another look and it appears that it's relevant only if you depend on i18n. It also assumes that you have |
Thank you for your response. I'll have a closer look and check if it can be solved with the global mock you mentioned. I also found that it might be related to the following issue in |
Alright, I gave it another try and found out, that the |
That would be the right place to open an issue, however I'm not sure it's a bug. Maybe they are not importing the polyfills intentionally. |
I opened an issue (thymikee/jest-preset-angular#347) with an updated repro, let's see what they think :) |
@pkaufi Have you tried by any chance adding a global mock for |
Unfortunately, I did not have time for this, I'm sorry. I'm also not sure when I can start with it, as I'm quite busy right now |
The issue was resolved within thymikee/jest-preset-angular#347 - Simply add the following to your setup-jest.ts:
And make sure it's imported into your jest.config.js:
|
Describe the Bug
After running
ngcc
as proposed in the angular update guide (https://update.angular.io/#8.2:9.0), tests are failing with the error messageI added a small reproduction below (updated and adapted the example app in this repository), where I installed
@angular/localized
with the help of the cli (ng add @angular/localized
). It then added an import to thepolyfills.ts
files automatically (polyfills.ts).It looks like
polyfills.ts
is not properly picked up during the test run, asng serve
still works after runningngcc
.When you add a minimal
jest.config.js
inside the root directory looking likeand the corresponding
setupJest.ts
filethe tests are green again. In my production app, this still breaks some other tests, but at least the majority of them runs.
However, I don't think that's the proper solution for it.
Minimal Reproduction
https://github.com/pkaufi/ngcc-i18n-jest
Expected Behavior
Tests should run successfully after running
ngcc
Environment
see reproduction repository
The text was updated successfully, but these errors were encountered: