We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
After running ngcc tests are failing with the error message:
ngcc
PrettyFormatPluginError: Cannot read property 'element' of undefinedTypeError: Cannot read property 'element' of undefined 19 | 20 | it(`should match snapshot`, () => { > 21 | expect(fixture).toMatchSnapshot(); | ^ 22 | }); 23 | }); 24 | at Object.print (node_modules/jest-preset-angular/build/AngularSnapshotSerializer.js:21:49) at it (src/app/match-test/match-test.component.spec.ts:21:21)
https://github.com/wachri/jest-preset-angular-9-ngcc-bug
Tests should run successfully after running ngcc
I debugged it a little bit and for me it looks like that the old ViewEngine is used instead of ivy. Before the running ngcc var componentName = val.componentRef._elDef.element.name is available (https://github.com/thymikee/jest-preset-angular/blob/master/src/AngularSnapshotSerializer.js#L26)
ViewEngine
ivy
var componentName = val.componentRef._elDef.element.name
When i do console.warn(val.componentRef); it looks like:
console.warn(val.componentRef);
ComponentRef_ { _view: { def: { factory: [Function], nodeFlags: 33669121, rootNodeFlags: 33554433, nodeMatchedQueries: 0, flags: 0, nodes: [Array], updateDirectives: [Function], updateRenderer: [Function: NOOP], handleEvent: [Function: handleEvent], bindingCount: 0, outputCount: 0, lastRenderRootNode: [Object] }, //...
After running ngcc it looks like
ComponentRef { location: ElementRef { nativeElement: HTMLDivElement { __ngContext__: [LRootView], __ng_debug__: [DebugElement__POST_R3__] } }, _rootLView: LRootView [ null, TView { type: 0, id: -1, blueprint: [LViewBlueprint], template: null, queries: null, viewQuery: null, node: [TNode], //...
Originally posted by @wachri in #347 (comment)
The text was updated successfully, but these errors were encountered:
related to Ivy compatibility for serializers in jest-preset-angular
jest-preset-angular
Sorry, something went wrong.
Same here...
Angular 9 "jest": "^25.1.0", "jest-preset-angular": "^8.0.0",
AngularSnapshotSerializer
I have enabled ivy but I am using Angular version 10 and still i get the issue as PrettyFormatPluginError: Cannot read property 'element' of undefined
Successfully merging a pull request may close this issue.
Describe the Bug
After running
ngcc
tests are failing with the error message:Minimal Reproduction
https://github.com/wachri/jest-preset-angular-9-ngcc-bug
Expected Behavior
Tests should run successfully after running ngcc
More details
I debugged it a little bit and for me it looks like that the old
ViewEngine
is used instead ofivy
.Before the running
ngcc
var componentName = val.componentRef._elDef.element.name
is available (https://github.com/thymikee/jest-preset-angular/blob/master/src/AngularSnapshotSerializer.js#L26)When i do
console.warn(val.componentRef);
it looks like:After running
ngcc
it looks likeOriginally posted by @wachri in #347 (comment)
Originally posted by @wachri in #347 (comment)
The text was updated successfully, but these errors were encountered: