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
510
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
28
Uncharted packages (Laravel Live Denmark)
freekmurze
0
220
I shall define this only once
freekmurze
0
440
Event Sourcing In Laravel
freekmurze
0
260
Building a realtime dashboard with Laravel Livewire (PHPKonf)
freekmurze
0
830
A tour behind the scenes of Oh Dear (PHP Benelux)
freekmurze
2
870
A practical look at multitenancy in Laravel
freekmurze
1
360
A practical look at multitenancy in Laravel (Laracon US)
freekmurze
0
740
Highlights Flare codebase (Laracon online)
freekmurze
0
530
Other Decks in Technology
See All in Technology
The Twin Mandate of Observability
charity
1
360
JAWS UG AI/ML #32 Amazon BedrockモデルのライフサイクルとEOL対応/How Amazon Bedrock Model Lifecycle Works
quiver
1
830
InsightX 会社説明資料/ Company deck
insightx
0
200
CloudComposerによる大規模ETL 「制御と実行の分離」の実践
leveragestech
0
190
最近読んで良かった本 / Yokohama North Meetup #10
mktakuya
0
880
ソフトウェアエンジニアとデータエンジニアの違い・キャリアチェンジ
mtpooh
0
130
[re:Inent2025事前勉強会(有志で開催)] re:Inventで見つけた人生をちょっと変えるコツ
sh_fk2
2
1.3k
激動の2025年、Modern Data Stackの最新技術動向
sagara
0
820
AWSが好きすぎて、41歳でエンジニアになり、AAIを経由してAWSパートナー企業に入った話
yama3133
2
230
日本のソブリンAIを支えるエヌビディアの生成AIエコシステム
acceleratedmu3n
0
130
30分でわかる!!『OCI で学ぶクラウドネイティブ実践 X 理論ガイド』
oracle4engineer
PRO
1
110
re:Invent 2025の見どころと便利アイテムをご紹介 / Highlights and Useful Items for re:Invent 2025
yuj1osm
0
690
Featured
See All Featured
Documentation Writing (for coders)
carmenintech
76
5.1k
Chrome DevTools: State of the Union 2024 - Debugging React & Beyond
addyosmani
9
950
Building an army of robots
kneath
306
46k
Java REST API Framework Comparison - PWX 2021
mraible
34
8.9k
Embracing the Ebb and Flow
colly
88
4.9k
Measuring & Analyzing Core Web Vitals
bluesmoon
9
650
Keith and Marios Guide to Fast Websites
keithpitt
412
23k
Principles of Awesome APIs and How to Build Them.
keavy
127
17k
The MySQL Ecosystem @ GitHub 2015
samlambert
251
13k
Code Review Best Practice
trishagee
72
19k
No one is an island. Learnings from fostering a developers community.
thoeni
21
3.5k
Product Roadmaps are Hard
iamctodd
PRO
55
11k
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