Skip to content

Commit

Permalink
fix(storyshots): fix broken storyshots with angular
Browse files Browse the repository at this point in the history
  • Loading branch information
mattlewis92 committed Jul 21, 2023
1 parent 5b34161 commit 379e484
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 3 deletions.
Expand Up @@ -2,7 +2,7 @@ import AngularSnapshotSerializer from 'jest-preset-angular/build/serializers/ng-
import HTMLCommentSerializer from 'jest-preset-angular/build/serializers/html-comment';
import { TestBed } from '@angular/core/testing';
import { addSerializer } from 'jest-specific-snapshot';
import { getApplication, storyPropsProvider } from '@storybook/angular/renderer';
import { getApplication, storyPropsProvider, PropertyExtractor } from '@storybook/angular/renderer';
import { BehaviorSubject } from 'rxjs';

addSerializer(HTMLCommentSerializer);
Expand All @@ -11,11 +11,14 @@ addSerializer(AngularSnapshotSerializer);
function getRenderedTree(story: any) {
const currentStory = story.render();

const analyzedMetadata = new PropertyExtractor(currentStory.moduleMetadata, story.component);

const application = getApplication({
storyFnAngular: currentStory,
component: story.component,
// TODO : To change with the story Id in v7. Currently keep with static id to avoid changes in snapshots
targetSelector: 'storybook-wrapper',
analyzedMetadata,
});

TestBed.configureTestingModule({
Expand Down
Expand Up @@ -12,7 +12,7 @@ export const getApplication = ({
storyFnAngular: StoryFnAngularReturnType;
component?: any;
targetSelector: string;
analyzedMetadata?: PropertyExtractor;
analyzedMetadata: PropertyExtractor;
}) => {
const { props, styles, moduleMetadata = {} } = storyFnAngular;
let { template } = storyFnAngular;
Expand Down
Expand Up @@ -52,7 +52,7 @@ export const createStorybookWrapperComponent = ({
styles: string[];
moduleMetadata: NgModuleMetadata;
initialProps?: ICollection;
analyzedMetadata?: PropertyExtractor;
analyzedMetadata: PropertyExtractor;
}): Type<any> => {
// In ivy, a '' selector is not allowed, therefore we need to just set it to anything if
// storyComponent was not provided.
Expand Down
1 change: 1 addition & 0 deletions code/frameworks/angular/src/renderer.ts
Expand Up @@ -3,3 +3,4 @@ export { computesTemplateSourceFromComponent } from './client/angular-beta/Compu
export { rendererFactory } from './client/render';
export { AbstractRenderer } from './client/angular-beta/AbstractRenderer';
export { getApplication } from './client/angular-beta/StorybookModule';
export { PropertyExtractor } from './client/angular-beta/utils/PropertyExtractor';

0 comments on commit 379e484

Please sign in to comment.