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
480
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
240
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
SnowflakeとDatabricks両方でRAGを構築してみた
kameitomohiro
1
420
バクラクの認証基盤の成長と現在地 / bakuraku-authn-platform
convto
1
610
持続可能なドキュメント運用のリアル: 1年間の成果とこれから
akitok_
1
190
Automatically generating types by running tests
sinsoku
2
3.3k
地味にいろいろあった! 2025春のAmazon Bedrockアップデートおさらい
minorun365
PRO
1
260
Cross Data Platforms Meetup LT 20250422
tarotaro0129
1
690
AIでめっちゃ便利になったけど、結局みんなで学ぶよねっていう話
kakehashi
PRO
0
180
コスト最適重視でAurora PostgreSQLのログ分析基盤を作ってみた #jawsug_tokyo
non97
0
340
Road to Go Gem #rubykaigi
sue445
0
680
クォータ監視、AWS Organizations環境でも楽勝です✌️
iwamot
PRO
1
320
AI AgentOps LT大会(2025/04/16) Algomatic伊藤発表資料
kosukeito
0
140
Making a MIDI controller device with PicoRuby/R2P2 (RubyKaigi 2025 LT)
risgk
1
250
Featured
See All Featured
The Psychology of Web Performance [Beyond Tellerrand 2023]
tammyeverts
47
2.6k
Rails Girls Zürich Keynote
gr2m
94
13k
Producing Creativity
orderedlist
PRO
344
40k
Six Lessons from altMBA
skipperchong
27
3.7k
Measuring & Analyzing Core Web Vitals
bluesmoon
7
390
Faster Mobile Websites
deanohume
306
31k
Facilitating Awesome Meetings
lara
54
6.3k
Mobile First: as difficult as doing things right
swwweet
223
9.6k
Understanding Cognitive Biases in Performance Measurement
bluesmoon
29
1.6k
Writing Fast Ruby
sferik
628
61k
Visualizing Your Data: Incorporating Mongo into Loggly Infrastructure
mongodb
45
9.5k
Why You Should Never Use an ORM
jnunemaker
PRO
55
9.3k
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