Upgrade to PRO for Only $50/Year—Limited-Time Offer! 🔥
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
520
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
32
Uncharted packages (Laravel Live Denmark)
freekmurze
0
230
I shall define this only once
freekmurze
0
450
Event Sourcing In Laravel
freekmurze
0
260
Building a realtime dashboard with Laravel Livewire (PHPKonf)
freekmurze
0
840
A tour behind the scenes of Oh Dear (PHP Benelux)
freekmurze
2
880
A practical look at multitenancy in Laravel
freekmurze
1
370
A practical look at multitenancy in Laravel (Laracon US)
freekmurze
0
750
Highlights Flare codebase (Laracon online)
freekmurze
0
530
Other Decks in Technology
See All in Technology
AI エージェントを評価するための温故知新と Spec Driven Evaluation
icoxfog417
PRO
2
950
Symfony AI in Action
el_stoffel
1
160
『ソフトウェア』で『リアル』を動かす:クレーンゲームからデータ基盤までの統一アーキテクチャ / アーキテクチャConference 2025
genda
0
1.8k
Eight Engineering Unit 紹介資料
sansan33
PRO
0
5.6k
ローカルLLM基礎知識 / local LLM basics 2025
kishida
25
11k
組織の“見えない壁”を越えよ!エンタープライズシフトに必須な3つのPMの「在り方」変革 #pmconf2025
masakazu178
1
1k
Master Dataグループ紹介資料
sansan33
PRO
1
4k
pmconf 2025 大阪「生成AI時代に未来を切り開くためのプロダクト戦略:圧倒的生産性を実現するためのプロダクトサイクロン」 / The Product Cyclone for Outstanding Productivity
yamamuteki
3
2.9k
SRE視点で振り返るメルカリのアーキテクチャ変遷と普遍的な考え
foostan
2
2.8k
命名から始めるSpec Driven
kuruwic
1
590
AIで加速する次世代のBill Oneアーキテクチャ〜成長の先にある軌道修正〜
sansantech
PRO
1
140
AS59105におけるFreeBSD EtherIPの運用と課題
x86taka
0
300
Featured
See All Featured
Become a Pro
speakerdeck
PRO
30
5.6k
The Cult of Friendly URLs
andyhume
79
6.7k
The Pragmatic Product Professional
lauravandoore
36
7k
How to train your dragon (web standard)
notwaldorf
97
6.4k
The Success of Rails: Ensuring Growth for the Next 100 Years
eileencodes
46
7.8k
Mobile First: as difficult as doing things right
swwweet
225
10k
Making Projects Easy
brettharned
120
6.5k
Statistics for Hackers
jakevdp
799
230k
The Power of CSS Pseudo Elements
geoffreycrofte
80
6.1k
CoffeeScript is Beautiful & I Never Want to Write Plain JavaScript Again
sstephenson
162
15k
10 Git Anti Patterns You Should be Aware of
lemiorhan
PRO
659
61k
A Modern Web Designer's Workflow
chriscoyier
697
190k
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