A practical intro tosnapshot testing
View Slide
Pronouncing DutchMichael 3/10Jacob 1/10
Pronouncing DutchMichael 9/10Jacob 9/10
Drake
Frake
Pronouncing Dutch: SpatieSpa Sea
LET’S TALK SNAPSHOT TESTING
A file on disk, let’s call in snapshotTest succeeds if output matches snapshotIf not, test will failWhat?
Old name: characterization testingPopularized by FacebookJestTesting interfacesWhere does it come from?
https://github.com/spatie/phpunit-snapshot-assertionsassertMatchesSnapshotassertMatchesJsonSnapshotassertMatchesXmlSnapshotHow can we do it in PHP?
DEMO
WRAPPING UP
AdvantagesVery easy to get started withCan be used to validate complex outputEasily update all the tests in one go
DisadvantagesBrittleHard to pinpoint exact point of failureBugs can be easily written in the snapshots
https://github.com/spatie/phpunit-snapshot-assertionshttps://sebastiandedeyne.com/posts/2017/a-package-for-snapshot-testing-in-phpunithttps://murze.be/2017/04/practical-introduction-snapshot-testing/https://www.sitepoint.com/snapshot-testing-viable-php/https://facebook.github.io/jest/docs/snapshot-testing.htmlInteresting links
Thank you!https://speakerdeck.com/freekmurze/snapshot-testing-laraconushttps://spatie.be/opensourcehttps://murze.behttps://murze.be/newsletter/
QUESTIONS?