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
0
470
An Introduction to Snapshot testing
Freek Van der Herten
September 01, 2021
Tweet
Share
More Decks by Freek Van der Herten
See All by Freek Van der Herten
Uncharted packages (Laravel Live Denmark)
freekmurze
0
190
I shall define this only once
freekmurze
0
390
Event Sourcing In Laravel
freekmurze
0
230
Building a realtime dashboard with Laravel Livewire (PHPKonf)
freekmurze
0
780
A tour behind the scenes of Oh Dear (PHP Benelux)
freekmurze
2
830
A practical look at multitenancy in Laravel
freekmurze
1
340
A practical look at multitenancy in Laravel (Laracon US)
freekmurze
0
710
Highlights Flare codebase (Laracon online)
freekmurze
0
480
Introducing Mailcoach
freekmurze
1
610
Other Decks in Technology
See All in Technology
開発現場とセキュリティ担当をつなぐ脅威モデリング
cloudace
0
140
30 代子育て SRE が考える SRE ナレッジマネジメントの現在と将来
kworkdev
PRO
0
180
大規模アジャイル開発のリアル!コミュニケーション×進捗管理×高品質
findy_eventslides
0
700
MCP Documentation Server @AI Coding Meetup #1
yyoshiki41
1
2.2k
アプリケーション固有の「ロジックの脆弱性」を防ぐ開発者のためのセキュリティ観点
flatt_security
40
15k
20250328_RubyKaigiで出会い鯛_____RubyKaigiから始まったはじめてのOSSコントリビュート.pdf
mterada1228
0
420
テキスト解析で見る PyCon APAC 2025 セッション&スピーカートレンド分析
negi111111
0
260
AIエージェント開発における「攻めの品質改善」と「守りの品質保証」 / 2024.04.09 GPU UNITE 新年会 2025
smiyawaki0820
0
250
50人の組織でAIエージェントを使う文化を作るためには / How to Create a Culture of Using AI Agents in a 50-Person Organization
yuitosato
4
1.8k
Tirez profit de Messenger pour améliorer votre architecture
tucksaun
1
210
Enterprise AI in 2025?
pamelafox
0
130
SaaSプロダクト開発におけるバグの早期検出のためのAcceptance testの取り組み
kworkdev
PRO
0
550
Featured
See All Featured
Fashionably flexible responsive web design (full day workshop)
malarkey
407
66k
The Straight Up "How To Draw Better" Workshop
denniskardys
232
140k
Faster Mobile Websites
deanohume
306
31k
Stop Working from a Prison Cell
hatefulcrawdad
268
20k
RailsConf 2023
tenderlove
29
1k
Understanding Cognitive Biases in Performance Measurement
bluesmoon
28
1.6k
GitHub's CSS Performance
jonrohan
1030
460k
The Illustrated Children's Guide to Kubernetes
chrisshort
48
49k
Intergalactic Javascript Robots from Outer Space
tanoku
270
27k
Why Our Code Smells
bkeepers
PRO
336
57k
What's in a price? How to price your products and services
michaelherold
245
12k
BBQ
matthewcrist
88
9.6k
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