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
580
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
An Introduction to Snapshot testing
Freek Van der Herten
September 01, 2021
More Decks by Freek Van der Herten
See All by Freek Van der Herten
Uncharted packages (ode aan de code)
freekmurze
0
70
Uncharted packages (Laravel Live Denmark)
freekmurze
0
260
I shall define this only once
freekmurze
0
480
Event Sourcing In Laravel
freekmurze
0
290
Building a realtime dashboard with Laravel Livewire (PHPKonf)
freekmurze
0
880
A tour behind the scenes of Oh Dear (PHP Benelux)
freekmurze
2
930
A practical look at multitenancy in Laravel
freekmurze
1
410
A practical look at multitenancy in Laravel (Laracon US)
freekmurze
0
790
Highlights Flare codebase (Laracon online)
freekmurze
0
590
Other Decks in Technology
See All in Technology
レガシーな広告配信システムでのAI駆動開発/運用の挑戦
i16fujimoto
0
110
ACE-Step-1.5で見る 音楽生成AIのしくみと“破綻だけ直す”Retake機能の開発【zennfes spring 2026 登壇資料】
personabb
1
550
クレデンシャル流出 ― 攻撃 3 時間 vs 復旧 10 時間。この非対称性にどう備えるか
kazzpapa3
3
480
WebGIS AI Agentの紹介
_shimizu
0
500
Flow 不死:AI 時代 DevOps 的不變本質
cheng_wei_chen
2
460
あなたの知らないPDFのアクセシビリティ
lycorptech_jp
PRO
0
230
AWS Security Agent といっしょに脅威モデリングをやってみよう
amarelo_n24
1
200
AIチャット検索改善の3週間
kworkdev
PRO
2
160
MUSUBI 田中裕一『AIと共に行う「しごとのリデザイン」- スモールバックオフィス編』AI Ops Lab #4
musubi
0
290
コミュニティの有益性 ~JAWS Days 2026 での体験を通して~ / The Benefits of a Community ~Through My Experience at JAWS Days 2026~
seike460
PRO
0
260
從開發到部署全都交給 AI:實作 AI 驅動的自動化流程
appleboy
0
110
自宅LLMの話
jacopen
1
700
Featured
See All Featured
Ethics towards AI in product and experience design
skipperchong
2
310
A Soul's Torment
seathinner
6
3k
Building the Perfect Custom Keyboard
takai
2
800
JAMstack: Web Apps at Ludicrous Speed - All Things Open 2022
reverentgeek
1
480
Utilizing Notion as your number one productivity tool
mfonobong
4
320
The B2B funnel & how to create a winning content strategy
katarinadahlin
PRO
1
390
Why Our Code Smells
bkeepers
PRO
340
58k
Site-Speed That Sticks
csswizardry
13
1.2k
The Curse of the Amulet
leimatthew05
1
13k
Getting science done with accelerated Python computing platforms
jacobtomlinson
2
240
Visualization
eitanlees
152
17k
The Organizational Zoo: Understanding Human Behavior Agility Through Metaphoric Constructive Conversations (based on the works of Arthur Shelley, Ph.D)
kimpetersen
PRO
0
360
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