-
Notifications
You must be signed in to change notification settings - Fork 309
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
tests failing on angular 9 after running ngcc with @angular/localize #347
Comments
Hey! The ngcc (angular compatibility compiler) basically upgrades modules, that have not been compiled with the ivy compiler (ngtsc), to be compatible with it. In the README:.
There are currently four types of code that have to be transformed, although the migrations itself are not defined inside the
I personally do not have time to look into it before March, but I just had an idea. Maybe you can try to move the import to I'll have a look at it in two weeks. |
This temporary solution works for me:
setup-jest.js
|
Exactly, that's what I meant with
It will definitely work like this and shouldn't be a blocker for upgrading to angular 9. @wtho thank you for having a look at it at providing some more insight into |
Add |
In my project I've added this snipet code into the jest.config.js file located in the root of monorepository. Other projects use this root jest.config.js file as preset: Root jest.config.js const path = require('path');
const rootSetupFile = path.resolve('./setup-jest.ts');
module.exports = {
...
setupFiles: [rootSetupFile],
}; Root setup-jest.ts import '@angular/localize/init'; Project jest.config.js module.exports = {
name: 'module-authentication',
preset: '../../../jest.config.js',
...
}; |
If the demand is high I would argue we should add it to
We are just passing Unfortunately Anyways I think many imports into |
I think the problem is bigger than just projects that use |
No it's not typo, |
Ok, thanks for clarifying!
I would love to use it, but unfortunately I feel like this discussion is key for the future of this preset, but on the other hand I am also confident Angular will not modify the |
At the moment I have a branch on ts-jest which includes compiler by Program. However I need some helps to clarify and test if it is the correct implementation. You can find it here |
Ok! I will be free-ish from next week on, will definitely get into this then! |
I found another problem after running
Created also a reproduction repository: |
seems to be a problem in |
Should i open another ticket? I debugged it a little bit and for me it looks like that the old When i do
After running
|
Ya I think it seems to be not related to this issue. My guess is the current serializers run with VE AST only but not Ivy AST. Is it right @wtho ? |
Yeah, internals have changed. This should be easily solvable by making the serializers compatible with both. |
FYI: |
Any updates on this? |
Ivy does quite some magic under the hood, as it is a compiler. It is still a long way to go, but we are on the way (in our free time, unpaid). Shout-out to @ahnpnl for the ton of work he is currently putting in. Subscribe #409 for more updates. |
Hi @Godrules500 , if you are having issues with
|
Due to the fact that testing with We can solve this difference by using AST transformer to inject polyfills, angular localized import or any global files into your setup jest, but this comes with a cost on performance (walking in AST tree is not free). I would propose that adding |
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).After I investigated a bit, I found out, that
polyfills.ts
is not picked up during the test run.When you add either
import './polyfills';
orimport '@angular/localize/init';
tosetupJest.ts
, the tests run successfully. But isn't that what we have thetsconfig
's for? Intsconfig.spec.json
for example, you can see that we haveWhat seems strange to me is and what I don't understand is, that before you run
ngcc
, the tests run successfully, even thoughpolyfills.ts
is not picked up. However, I also don't know exactly whatngcc
is doing.Minimal Reproduction
https://github.com/pkaufi/ngcc-i18n-jest/tree/jest-preset-angular
Expected Behavior
Tests should run successfully after running
ngcc
Environment
see reproduction repository
The text was updated successfully, but these errors were encountered: