Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
snapshot testing (phplimburg)
Search
Freek Van der Herten
September 07, 2017
Programming
1
320
snapshot testing (phplimburg)
Freek Van der Herten
September 07, 2017
Tweet
Share
More Decks by Freek Van der Herten
See All by Freek Van der Herten
Uncharted packages (Laravel Live Denmark)
freekmurze
0
180
I shall define this only once
freekmurze
0
380
An Introduction to Snapshot testing
freekmurze
0
460
Event Sourcing In Laravel
freekmurze
0
230
Building a realtime dashboard with Laravel Livewire (PHPKonf)
freekmurze
0
770
A tour behind the scenes of Oh Dear (PHP Benelux)
freekmurze
2
820
A practical look at multitenancy in Laravel
freekmurze
1
330
A practical look at multitenancy in Laravel (Laracon US)
freekmurze
0
700
Highlights Flare codebase (Laracon online)
freekmurze
0
460
Other Decks in Programming
See All in Programming
良いコードレビューとは
danimal141
1
140
Generating OpenAPI schema from serializers throughout the Rails stack - Kyobashi.rb #5
envek
1
390
Rubyで始める関数型ドメインモデリング
shogo_tksk
0
140
コミュニティ駆動 AWS CDK ライブラリ「Open Constructs Library」 / community-cdk-library
gotok365
2
250
AWS Step Functions は CDK で書こう!
konokenj
4
480
iOSでQRコード生成奮闘記
ktcryomm
2
110
Jakarta EE meets AI
ivargrimstad
0
460
Datadog DBMでなにができる? JDDUG Meetup#7
nealle
0
150
How mixi2 Uses TiDB for SNS Scalability and Performance
kanmo
41
16k
Kotlinの開発でも AIをいい感じに使いたい / Making the Most of AI in Kotlin Development
kohii00
5
1.4k
PHPカンファレンス名古屋2025 タスク分解の試行錯誤〜レビュー負荷を下げるために〜
soichi
1
720
Ça bouge du côté des animations CSS !
goetter
2
150
Featured
See All Featured
The Psychology of Web Performance [Beyond Tellerrand 2023]
tammyeverts
46
2.3k
How to Create Impact in a Changing Tech Landscape [PerfNow 2023]
tammyeverts
49
2.3k
Mobile First: as difficult as doing things right
swwweet
223
9.5k
Intergalactic Javascript Robots from Outer Space
tanoku
270
27k
Fantastic passwords and where to find them - at NoRuKo
philnash
51
3k
The Art of Programming - Codeland 2020
erikaheidi
53
13k
Distributed Sagas: A Protocol for Coordinating Microservices
caitiem20
330
21k
Speed Design
sergeychernyshev
27
810
Site-Speed That Sticks
csswizardry
4
410
The Cult of Friendly URLs
andyhume
78
6.2k
Making Projects Easy
brettharned
116
6k
Rebuilding a faster, lazier Slack
samanthasiow
80
8.9k
Transcript
A practical intro to snapshot testing and PHPUnit-watcher
About me Freek Van der Herten Partner & developer at
SPATIE Blogging at https://murze.be https://murze.be/newsletter
OPEN SOURCE SOFTWARE
https://spatie.be/en/opensource/laravel
Open source software ± 160 public repositories on GitHub August
2016: ± 800 000 downloads August 2017: ± 5 000 000 downloads ± 500 000 downloads a month
LET’S TALK SNAPSHOT TESTING
A file on disk, let’s call in snapshot Test succeeds
if output matches snapshot If not, test will fail What?
Another name: characterization testing Popularized by Facebook Jest Testing interfaces
Where does it come from?
https://github.com/spatie/phpunit-snapshot-assertions assertMatchesSnapshot assertMatchesJsonSnapshot assertMatchesXmlSnapshot How can we do it in
PHP?
DEMO
WRAPPING UP
Advantages Very easy to get started with Can be used
to validate complex output Easily update all the tests in one go
Disadvantages Brittle Hard to pinpoint exact point of failure Bugs
can be easily written in the snapshots
https://github.com/spatie/phpunit-snapshot-assertions https://sebastiandedeyne.com/posts/2017/a-package-for-snapshot- testing-in-phpunit https://murze.be/2017/04/practical-introduction-snapshot-testing/ https://www.sitepoint.com/snapshot-testing-viable-php/ https://facebook.github.io/jest/docs/snapshot-testing.html https://github.com/spatie/phpunit-watcher Interesting links
Thank you! https://speakerdeck.com/freekmurze/snapshot-testing-phplimburg https://spatie.be/opensource https://murze.be https://murze.be/newsletter/
QUESTIONS?