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
360
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 (ode aan de code)
freekmurze
0
26
Uncharted packages (Laravel Live Denmark)
freekmurze
0
220
I shall define this only once
freekmurze
0
420
An Introduction to Snapshot testing
freekmurze
0
510
Event Sourcing In Laravel
freekmurze
0
260
Building a realtime dashboard with Laravel Livewire (PHPKonf)
freekmurze
0
830
A tour behind the scenes of Oh Dear (PHP Benelux)
freekmurze
2
860
A practical look at multitenancy in Laravel
freekmurze
1
360
A practical look at multitenancy in Laravel (Laracon US)
freekmurze
0
740
Other Decks in Programming
See All in Programming
アメ車でサンノゼを走ってきたよ!
s_shimotori
0
220
The Past, Present, and Future of Enterprise Java
ivargrimstad
0
340
あなたとKaigi on Rails / Kaigi on Rails + You
shimoju
0
160
monorepo の Go テストをはやくした〜い!~最小の依存解決への道のり~ / faster-testing-of-monorepos
convto
2
490
Claude Agent SDK を使ってみよう
hyshu
0
290
XP, Testing and ninja testing ZOZ5
m_seki
3
670
バッチ処理を「状態の記録」から「事実の記録」へ
panda728
PRO
0
160
10年もののAPIサーバーにおけるCI/CDの改善の奮闘
mbook
0
830
チームの境界をブチ抜いていけ
tokai235
0
180
20251016_Rails News ~Rails 8.1の足音を聴く~
morimorihoge
1
340
CSC305 Lecture 05
javiergs
PRO
0
210
Building, Deploying, and Monitoring Ruby Web Applications with Falcon (Kaigi on Rails 2025)
ioquatix
4
2.2k
Featured
See All Featured
Cheating the UX When There Is Nothing More to Optimize - PixelPioneers
stephaniewalter
285
14k
Building Applications with DynamoDB
mza
96
6.7k
The Art of Programming - Codeland 2020
erikaheidi
56
14k
For a Future-Friendly Web
brad_frost
180
9.9k
Into the Great Unknown - MozCon
thekraken
40
2.1k
XXLCSS - How to scale CSS and keep your sanity
sugarenia
248
1.3M
Principles of Awesome APIs and How to Build Them.
keavy
127
17k
The Language of Interfaces
destraynor
162
25k
Done Done
chrislema
185
16k
Connecting the Dots Between Site Speed, User Experience & Your Business [WebExpo 2025]
tammyeverts
9
590
Building an army of robots
kneath
306
46k
A Modern Web Designer's Workflow
chriscoyier
697
190k
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?