$30 off During Our Annual Pro Sale. View Details »
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
36
Uncharted packages (Laravel Live Denmark)
freekmurze
0
230
I shall define this only once
freekmurze
0
450
Event Sourcing In Laravel
freekmurze
0
270
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
380
A practical look at multitenancy in Laravel (Laracon US)
freekmurze
0
760
Highlights Flare codebase (Laracon online)
freekmurze
0
550
Other Decks in Technology
See All in Technology
「図面」から「法則」へ 〜メタ視点で読み解く現代のソフトウェアアーキテクチャ〜
scova0731
0
350
年間40件以上の登壇を続けて見えた「本当の発信力」/ 20251213 Masaki Okuda
shift_evolve
PRO
1
140
mairuでつくるクレデンシャルレス開発環境 / Credential-less development environment using Mailru
mirakui
5
550
Kiro を用いたペアプロのススメ
taikis
1
270
WordPress は終わったのか ~今のWordPress の制作手法ってなにがあんねん?~ / Is WordPress Over? How We Build with WordPress Today
tbshiki
2
820
AlmaLinux + KVM + Cockpit で始めるお手軽仮想化基盤 ~ 開発環境などでの利用を想定して ~
koedoyoshida
0
110
日本Rubyの会: これまでとこれから
snoozer05
PRO
3
150
SQLだけでマイグレーションしたい!
makki_d
0
1k
AWS運用を効率化する!AWS Organizationsを軸にした一元管理の実践/nikkei-tech-talk-202512
nikkei_engineer_recruiting
0
110
Lookerで実現するセキュアな外部データ提供
zozotech
PRO
0
170
[デモです] NotebookLM で作ったスライドの例
kongmingstrap
0
160
JEDAI認定プログラム JEDAI Order 2026 エントリーのご案内 / JEDAI Order 2026 Entry
databricksjapan
0
140
Featured
See All Featured
Automating Front-end Workflow
addyosmani
1371
200k
Building Experiences: Design Systems, User Experience, and Full Site Editing
marktimemedia
0
310
[Rails World 2023 - Day 1 Closing Keynote] - The Magic of Rails
eileencodes
37
2.7k
Context Engineering - Making Every Token Count
addyosmani
9
540
Visualization
eitanlees
150
16k
Art, The Web, and Tiny UX
lynnandtonic
304
21k
コードの90%をAIが書く世界で何が待っているのか / What awaits us in a world where 90% of the code is written by AI
rkaga
57
37k
Designing Dashboards & Data Visualisations in Web Apps
destraynor
231
54k
Connecting the Dots Between Site Speed, User Experience & Your Business [WebExpo 2025]
tammyeverts
10
740
Building a Modern Day E-commerce SEO Strategy
aleyda
45
8.3k
Docker and Python
trallard
47
3.7k
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
234
17k
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