Skip to content

Commit

Permalink
refactor(serializers): drop support snapshot "pre-ngcc" mode (#1098)
Browse files Browse the repository at this point in the history
BREAKING CHANGE
Since users are forced to run `ngcc` before running Jest, workaround for snapshot serializer with "pre-ngcc" mode is no longer required, hence this support is dropped.
  • Loading branch information
ahnpnl authored Oct 18, 2021
1 parent b62a2a2 commit a5fbe99
Showing 1 changed file with 1 addition and 10 deletions.
11 changes: 1 addition & 10 deletions src/serializers/ng-snapshot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@ import type { Colors } from 'pretty-format';
interface ComponentDef {
selectors: ɵCssSelectorList;
}
interface VEComponentType extends Type<unknown> {
ngComponentDef: ComponentDef;
}
interface IvyComponentType extends Type<unknown> {
ɵcmp: ComponentDef;
}
Expand Down Expand Up @@ -72,12 +69,6 @@ const ivyEnabled = (): boolean => {
return !!ɵivyEnabled;
};

// Ivy component definition was stored on the `ngComponentDef`
// property before `9.0.0-next.10`. Since `9.0.0-next.10` it was
// renamed to `ɵcmp`.
const getComponentDef = (type: VEComponentType | IvyComponentType): ComponentDef =>
(type as VEComponentType).ngComponentDef ?? (type as IvyComponentType).ɵcmp;

const print = (
fixture: NgComponentFixture,
print: Printer,
Expand All @@ -90,7 +81,7 @@ const print = (
let componentName = '';

if (ivyEnabled()) {
const componentDef = getComponentDef(fixture.componentRef.componentType as IvyComponentType);
const componentDef = (fixture.componentRef.componentType as IvyComponentType).ɵcmp;
componentName = componentDef.selectors[0][0] as string;
nodes = Array.from(fixture.componentRef.location.nativeElement.childNodes).map(print).join('');
} else {
Expand Down

0 comments on commit a5fbe99

Please sign in to comment.