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
490
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
200
I shall define this only once
freekmurze
0
400
Event Sourcing In Laravel
freekmurze
0
250
Building a realtime dashboard with Laravel Livewire (PHPKonf)
freekmurze
0
800
A tour behind the scenes of Oh Dear (PHP Benelux)
freekmurze
2
850
A practical look at multitenancy in Laravel
freekmurze
1
350
A practical look at multitenancy in Laravel (Laracon US)
freekmurze
0
720
Highlights Flare codebase (Laracon online)
freekmurze
0
500
Introducing Mailcoach
freekmurze
1
620
Other Decks in Technology
See All in Technology
Agentic Workflowという選択肢を考える
tkikuchi1002
1
290
AWS CDK 実践的アプローチ N選 / aws-cdk-practical-approaches
gotok365
4
400
VCpp Link and Library - C++ breaktime 2025 Summer
harukasao
0
220
Кто отправит outbox? Валентин Удальцов, автор канала Пых
lamodatech
0
250
CIでのgolangci-lintの実行を約90%削減した話
kazukihayase
0
340
~宇宙最速~2025年AWS Summit レポート
satodesu
1
840
比起獨自升級 我更喜歡 DevOps 文化 <3
line_developers_tw
PRO
0
1.1k
キャディでのApache Iceberg, Trino採用事例 -Apache Iceberg and Trino Usecase in CADDi--
caddi_eng
0
170
ObsidianをMCP連携させてみる
ttnyt8701
2
140
ハノーバーメッセ2025座談会.pdf
iotcomjpadmin
0
140
成立するElixirの再束縛(再代入)可という選択
kubell_hr
0
540
Amazon S3標準/ S3 Tables/S3 Express One Zoneを使ったログ分析
shigeruoda
2
350
Featured
See All Featured
Practical Tips for Bootstrapping Information Extraction Pipelines
honnibal
PRO
20
1.3k
Building an army of robots
kneath
306
45k
Documentation Writing (for coders)
carmenintech
71
4.9k
Side Projects
sachag
455
42k
Raft: Consensus for Rubyists
vanstee
140
7k
Why You Should Never Use an ORM
jnunemaker
PRO
56
9.4k
Facilitating Awesome Meetings
lara
54
6.4k
Gamification - CAS2011
davidbonilla
81
5.3k
Creating an realtime collaboration tool: Agile Flush - .NET Oxford
marcduiker
30
2.1k
GitHub's CSS Performance
jonrohan
1031
460k
Designing for Performance
lara
609
69k
Code Review Best Practice
trishagee
68
18k
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