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
540
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
53
Uncharted packages (Laravel Live Denmark)
freekmurze
0
240
I shall define this only once
freekmurze
0
460
Event Sourcing In Laravel
freekmurze
0
280
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
770
Highlights Flare codebase (Laracon online)
freekmurze
0
570
Other Decks in Technology
See All in Technology
ブログの作成に音声AIツールを使って音声入力しようとした話
smt7174
1
170
ソフトウェアアーキテクトのための意思決定術: Create Decision Readiness—The Real Skill Behind Architectural Decision
snoozer05
PRO
5
510
primeNumber DATA MANAGEMENT CAMP #2:
masatoshi0205
1
440
社内ワークショップで終わらせない 業務改善AIエージェント開発
lycorptech_jp
PRO
1
340
技術書を出版するまでの1161時間50分38秒
kakeami
0
160
なぜAIは組織を速くしないのか 令和の腑分け
sugino
9
3.6k
サイボウズ 開発本部採用ピッチ / Cybozu Engineer Recruit
cybozuinsideout
PRO
10
74k
「使いにくい」も「運用疲れ」も卒業する UIデザイナーとエンジニアが創る持続可能な内製開発
nrinetcom
PRO
0
190
APMの世界から見るOpenTelemetryのTraceの世界 / OpenTelemetry in the Java
soudai
PRO
0
140
生成AI素人でも玄人でもない私がセイセイAIチョットワカルために勉強したこと
wkm2
2
310
作るべきものと向き合う - ecspresso 8年間の開発史から学ぶ技術選定 / 技術選定con findy 2026
fujiwara3
4
540
Oracle Base Database Service 技術詳細
oracle4engineer
PRO
15
94k
Featured
See All Featured
More Than Pixels: Becoming A User Experience Designer
marktimemedia
3
340
Rebuilding a faster, lazier Slack
samanthasiow
85
9.4k
Fashionably flexible responsive web design (full day workshop)
malarkey
408
66k
Beyond borders and beyond the search box: How to win the global "messy middle" with AI-driven SEO
davidcarrasco
1
63
AI in Enterprises - Java and Open Source to the Rescue
ivargrimstad
0
1.2k
The browser strikes back
jonoalderson
0
730
Applied NLP in the Age of Generative AI
inesmontani
PRO
4
2.1k
Large-scale JavaScript Application Architecture
addyosmani
515
110k
svc-hook: hooking system calls on ARM64 by binary rewriting
retrage
1
130
Primal Persuasion: How to Engage the Brain for Learning That Lasts
tmiket
0
270
Getting science done with accelerated Python computing platforms
jacobtomlinson
2
130
Amusing Abliteration
ianozsvald
0
120
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