German Slides on applying visual regression to an Angular application with Storybook, Jest/Puppeteer and Cypress
The source code can be found on: https://github.com/rainerhahnekamp/visual-regression-angular-storybook-datev
Datev Coding Festival, 29.7.2021Rainer HahnekampVisuelle Regressionstestsmit StorybookDatev Coding Festival, 29.7.2021Rainer Hahnekamp
View Slide
Datev Coding Festival, 29.7.2021Rainer HahnekampÜber mich● Rainer HahnekampANGULARarchitects.io● Trainings and Consultancy● > 20 Years Experience@rainerhahnekamphttps://angulararchitects.io/workshops
Datev Coding Festival, 29.7.2021Rainer Hahnekamp
Datev Coding Festival, 29.7.2021Rainer HahnekampUnit TestsIntegrationstestsSystemtests
Datev Coding Festival, 29.7.2021Rainer HahnekampJSDomAnwendungscode@angular/testingTests
Datev Coding Festival, 29.7.2021Rainer HahnekampFrontend Applikation 2 Headless Browser Tests13 4
Datev Coding Festival, 29.7.2021Rainer HahnekampPuppetteer● Inkludiert Headless Browser● Spezielle Jest Konfiguration notwendig○ Kein TestBed○ Komplett isoliert von Anwendung● Debug Modus möglich● PlayWright als mögliche Alternative
Datev Coding Festival, 29.7.2021Rainer HahnekampHerausforderungen1. Pixelabgleich2. Komponentenisolation
Datev Coding Festival, 29.7.2021Rainer HahnekampFinde den Unterschied
Datev Coding Festival, 29.7.2021Rainer HahnekampKomponenten Isolation
Datev Coding Festival, 29.7.2021Rainer HahnekampStorybook
Datev Coding Festival, 29.7.2021Rainer Hahnekamp2 Headless Browser Tests13 4StorybookCode(Komponenten)
Datev Coding Festival, 29.7.2021Rainer HahnekampStorybook● Rendert Komponenten in Isolation● Nicht Angular spezifisch● Konfiguration von Komponenten in verschiedenen Ausprägungen● Kann auch als "Komponentengallerie" verwendet werden
Datev Coding Festival, 29.7.2021Rainer HahnekampStorybook Setup - "Modul" Konfiguration - 1/3export default {title: 'Eternal/HolidayCard',component: HolidayCardComponent,decorators: [moduleMetadata({ imports: [MatButtonModule, MatCardModule] })],argTypes: { holiday: { name: 'Urlaub', description: 'Urlaubsdaten' } }} as Meta;
Datev Coding Festival, 29.7.2021Rainer HahnekampStorybook Setup - Template - 2/3const Template: Story = (args: HolidayCardComponent) => ({component: HolidayCardComponent,props: args});
Datev Coding Festival, 29.7.2021Rainer HahnekampStorybook Setup - Variation - 3/3export const Default = () => {props: {holiday: {id: 1,title: 'Holiday',description: 'A holiday',imageUrl: 'https://eternal-app.s3.eu-central-1.amazonaws.com/assets/AngkorWatSmall.jpg'}}}
Datev Coding Festival, 29.7.2021Rainer HahnekampPixel Matching
Datev Coding Festival, 29.7.2021Rainer Hahnekamp2 Headless Browser Test Specs13 4StorybookApplication Code(Components)
Datev Coding Festival, 29.7.2021Rainer HahnekampCloudanbieter
Datev Coding Festival, 29.7.2021Rainer HahnekampTestbare Architektur
Datev Coding Festival, 29.7.2021Rainer HahnekampSharedForms GridErrorHandlingWidgetsBackendMiddleware...App ShellDomäne Domäne Domäne Domäne
Datev Coding Festival, 29.7.2021Rainer HahnekampDomäneFeature (Container Kmp.)Data UI (Presentational Kmp.)Domain ModelsKomponentServiceModul
Datev Coding Festival, 29.7.2021Rainer HahnekampContainerKomponenten● Minimales HTML/CSS● Viel DI● Vermittlerrolle● Minimales Typescript● Keine DI● @Input & @Output● Keine Observables@Input@OutputPresentationalKomponentenData(ngrx)selectorsactionsContainer & Presentational Komponenten
Datev Coding Festival, 29.7.2021Rainer HahnekampZusammenfassung● Visuelle Regression als wichtige Testmethode● Spezielle Anforderungen an Infrastruktur○ Docker○ Cloudanbieter● Storybook für Komponenten Isolation bzw. Widget Gallerie● Kinderkrankheiten Storybook + Angular + Puppeteer○ StoryShots○ Storybook mit Webpack○ Alternative Cypress● Architektur auf Testen ausrichten