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
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
Freek Van der Herten
September 01, 2021
Technology
0
530
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 (ode aan de code)
freekmurze
0
48
Uncharted packages (Laravel Live Denmark)
freekmurze
0
240
I shall define this only once
freekmurze
0
460
Event Sourcing In Laravel
freekmurze
0
270
Building a realtime dashboard with Laravel Livewire (PHPKonf)
freekmurze
0
850
A tour behind the scenes of Oh Dear (PHP Benelux)
freekmurze
2
890
A practical look at multitenancy in Laravel
freekmurze
1
390
A practical look at multitenancy in Laravel (Laracon US)
freekmurze
0
760
Highlights Flare codebase (Laracon online)
freekmurze
0
560
Other Decks in Technology
See All in Technology
Azure SRE Agent x PagerDutyによる近未来インシデント対応への期待 / The Future of Incident Response: Azure SRE Agent x PagerDuty
aeonpeople
0
230
ZOZOにおけるAI活用の現在 ~開発組織全体での取り組みと試行錯誤~
zozotech
PRO
1
580
書籍執筆での生成AIの活用
sat
PRO
1
230
Amazon Bedrock AgentCore EvaluationsでAIエージェントを評価してみよう!
yuu551
0
190
ファシリテーション勉強中 その場に何が求められるかを考えるようになるまで / 20260123 Naoki Takahashi
shift_evolve
PRO
3
410
全員が「作り手」になる。職能の壁を溶かすプロトタイプ開発。
hokuo
1
630
Agentic Coding 実践ワークショップ
watany
41
28k
Claude Codeベストプラクティスまとめ
minorun365
53
30k
AI開発をスケールさせるデータ中心の仕組みづくり
kzykmyzw
0
180
Web Intelligence and Visual Media Analytics
weblyzard
PRO
1
6.8k
VRTと真面目に向き合う
hiragram
1
510
日本語テキストと音楽の対照学習の技術とその応用
lycorptech_jp
PRO
1
370
Featured
See All Featured
Imperfection Machines: The Place of Print at Facebook
scottboms
269
14k
Rebuilding a faster, lazier Slack
samanthasiow
85
9.4k
Why Mistakes Are the Best Teachers: Turning Failure into a Pathway for Growth
auna
0
48
Mozcon NYC 2025: Stop Losing SEO Traffic
samtorres
0
130
We Are The Robots
honzajavorek
0
150
What’s in a name? Adding method to the madness
productmarketing
PRO
24
3.9k
Why You Should Never Use an ORM
jnunemaker
PRO
61
9.7k
Side Projects
sachag
455
43k
A brief & incomplete history of UX Design for the World Wide Web: 1989–2019
jct
1
290
Exploring the Power of Turbo Streams & Action Cable | RailsConf2023
kevinliebholz
37
6.2k
Thoughts on Productivity
jonyablonski
74
5k
Heart Work Chapter 1 - Part 1
lfama
PRO
5
35k
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