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
An Introduction to Snapshot testing
Search
Freek Van der Herten
September 01, 2021
Technology
580
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
An Introduction to Snapshot testing
Freek Van der Herten
September 01, 2021
More Decks by Freek Van der Herten
See All by Freek Van der Herten
Uncharted packages (ode aan de code)
freekmurze
0
72
Uncharted packages (Laravel Live Denmark)
freekmurze
0
270
I shall define this only once
freekmurze
0
490
Event Sourcing In Laravel
freekmurze
0
290
Building a realtime dashboard with Laravel Livewire (PHPKonf)
freekmurze
0
890
A tour behind the scenes of Oh Dear (PHP Benelux)
freekmurze
2
930
A practical look at multitenancy in Laravel
freekmurze
1
410
A practical look at multitenancy in Laravel (Laracon US)
freekmurze
0
800
Highlights Flare codebase (Laracon online)
freekmurze
0
600
Other Decks in Technology
See All in Technology
Model Studio CLI × Token Plan
maigo999
0
180
Breaking the Seal: Static Deobfuscation of Compiled V8 JavaScript Bytecode Malware
hshrzd
0
810
同じWAFが、攻撃の“形”は弾く── 正当な“形”の不正は通す
kuroneko13
0
210
修正PRを食べてレビュースキルが賢くなる:Claude Codeによる自己改善サイクル
yuyaumetsu
6
1.5k
【CEDEC2026】Creative Approaches to Localizing the Dialects and Unique Speech of Umamusume: Pretty Derby Characters in English
cygames
PRO
3
24k
DatadogのBits Chatが開発組織にもたらしたもの / What Bits Chat Has Brought Us
sms_tech
1
270
Kiro Crew入門 - 常駐エージェントの仕組みと使いどころ / Intro to Kiro Crew
k_adachi_01
1
150
ブラウザ研修 2026
recruitengineers
PRO
6
1k
事業価値と Engineering 2026年度版
recruitengineers
PRO
50
24k
Bill One 開発エンジニア 紹介資料
sansan33
PRO
7
19k
Bits Agent Builder の⼊⾨と活⽤事例
nulabinc
PRO
0
160
Master Dataグループ紹介資料
sansan33
PRO
1
4.8k
Featured
See All Featured
Gemini Prompt Engineering: Practical Techniques for Tangible AI Outcomes
mfonobong
2
490
HTML-Aware ERB: The Path to Reactive Rendering @ RubyCon 2026, Rimini, Italy
marcoroth
3
430
XXLCSS - How to scale CSS and keep your sanity
sugarenia
249
1.3M
The Power of CSS Pseudo Elements
geoffreycrofte
82
6.5k
Bridging the Design Gap: How Collaborative Modelling removes blockers to flow between stakeholders and teams @FastFlow conf
baasie
0
640
How to Grow Your eCommerce with AI & Automation
katarinadahlin
PRO
1
240
Imperfection Machines: The Place of Print at Facebook
scottboms
270
14k
Balancing Empowerment & Direction
lara
6
1.2k
We Have a Design System, Now What?
morganepeng
55
8.3k
Leading Effective Engineering Teams in the AI Era
addyosmani
9
2.3k
What does AI have to do with Human Rights?
axbom
PRO
1
2.3k
YesSQL, Process and Tooling at Scale
rocio
174
15k
Transcript
AN INTRODUCTION TO SNAPSHOT TESTING Freek Van der Herten
About me Freek Van der Herten Developer at SPATIE @freekmurze
freek.dev spatie.be/products ohdear.app
spatie.be/open-source 300+ open source packages PHP & Laravel 175 million
downloads total 9 million downloads per month
LET’S TALK ABOUT SNAPSHOT TESTING
What? A file on disk – let’s call it a
snapshot Test succeeds if the output matches the snapshot If not, the test will fail
Where does it come from? Characterisation testing Popularized by Facebook
Jest Testing interfaces
How can we do it in PHP? github.com/spatie/phpunit-snapshot-assertions github.com/spatie/pest-plugin-snapshots assertMatchesSnapshot
assertMatchesJsonSnapshot assertMatchesXmlSnapshot
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
Interesting links github.com/spatie/phpunit-snapshot-assertions github.com/spatie/pest-plugin-snapshots github.com/spatie/shiki-php github.com/spatie/laravel-markdown torchlight.dev
ONE MORE THING
testing-laravel.com Premium video course, 6+ hours of video Learn how
to tests a Laravel app from scratch Tips and tricks to sharpen your skills Two courses in one: Pest & PHPUnit 10 % discount with SPATIE-LOVES-LARACON
Thank you! spatie.be spatie.be/products spatie.be/open-source testing-laravel.com freek.dev