Skip to content
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]: Jest snapshots feature is broken with Angular 15.2.2 #2003

Closed
richardeschloss opened this issue Mar 14, 2023 · 6 comments
Closed

[Bug]: Jest snapshots feature is broken with Angular 15.2.2 #2003

richardeschloss opened this issue Mar 14, 2023 · 6 comments
Labels
🐛 Bug Confirmed Bug is confirmed

Comments

@richardeschloss
Copy link

richardeschloss commented Mar 14, 2023

Version

13.0.0-next.1

Steps to reproduce

Attempt to create a snapshot on a very simple component: (AppComponent here, for example)

//
...
await TestBed.configureTestingModule({
  declarations: [AppComponent],
}).compileComponents();
const fixture = TestBed.createComponent(AppComponent);
expect(fixture).toMatchSnapshot()

The test errors out because the latest @angular/core at 15.2.2 no longer exports ɵivyEnabled :( as the serializer is expecting here and as a result, the else block here incorrectly gets hit, causing the undefined error.

Expected behavior

Expect snapshots to be taken / tested against.

Actual behavior

Test failing on undefined errors.

Additional context

Perhaps we might want to do away with the "is Ivy check?" altogether, and just make the latest preset only compatible with Ivy (and eliminate the else condition)? (Alternatives: read in the version property from angular/core to do the isIvy check)

Environment

Windows 11 (I'm away from work computer at the moment)
@richardeschloss
Copy link
Author

That export was removed recently in this PR: angular/angular#49296

I'm not sure what the meaning is behind their use of "theta" as a prefix for the export. Is that a Google convention?

@ahnpnl
Copy link
Collaborator

ahnpnl commented Mar 14, 2023

Indeed we observed our CI also failed in #2001

The theta is an Angular thing when they made the Ivy compiler.

The original PR for Ivy compatibility is here #366

This preset is still supporting Angular versions which contain VE so I think we should create a separate serializer which doesn’t use that ivyEnabled check and ask Ivy users to use the new serializer. That will not become a breaking change.

@rubiesonthesky
Copy link
Contributor

Is there any way to fix this temporary locally until new serializer is added?

I wonder could this library do something similar as help-me-mom/ng-mocks#5126 ? That does not seem to be breaking change and keeps non-ivy / ivy support?

@ahnpnl
Copy link
Collaborator

ahnpnl commented Mar 21, 2023

As long as there is an alternative way to detect Ivy mode, it should be ok. PR is welcome.

@vicentematus
Copy link

What would be the solution the to make snapshots works? is there any flag for the ivy related thing for Angular 15?

@vicentematus
Copy link

Ok so the solution was to update to jest-preset-angular 13.0.1 based on the issue on angular-builders. And also Jest.

Running

ng update jest-preset-angular@13.0.1 jest@29 ts-jest@29

And after that the snapshots started working

ruegenbfr added a commit to SiLeBAT/fcl-client that referenced this issue May 7, 2024
- updates typscript to v4.8.4
- updates all @angular*/* libs to v15
- updates @ngrx/* to v15
- updates jest to v29
- updates jest-preset-angular to v13

Jest update was required because the test snapshot feature
was broken, [see](thymikee/jest-preset-angular#2003)

supported browserlist was reduced:
- kaios 2.5 was removed
- op_mini all was removed

ticket: #725
Change-Id: I654cbe1a855a09d00e4c5ed7beadfcb3b25148d4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐛 Bug Confirmed Bug is confirmed
Projects
None yet
Development

No branches or pull requests

4 participants