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
590
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
74
Uncharted packages (Laravel Live Denmark)
freekmurze
0
270
I shall define this only once
freekmurze
0
490
Event Sourcing In Laravel
freekmurze
0
290
Building a realtime dashboard with Laravel Livewire (PHPKonf)
freekmurze
0
890
A tour behind the scenes of Oh Dear (PHP Benelux)
freekmurze
2
940
A practical look at multitenancy in Laravel
freekmurze
1
410
A practical look at multitenancy in Laravel (Laracon US)
freekmurze
0
800
Highlights Flare codebase (Laracon online)
freekmurze
0
610
Other Decks in Technology
See All in Technology
生成AI時代の クレデンシャルとパーミッション設計
nrinetcom
PRO
3
1.5k
どんな手を使っても絶対間に合わせるスケジューラ
asari194617
0
1.5k
Benchmarking Vector Databases: pgvector vs. LanceDB
tsho
0
130
【視聴者参加型!】AWSセキュリティアンチパターンクイズ
syoshie
0
290
プロダクト思考 × 基盤思考を AIで実現する Compound Engineering
tkc66buzz
1
240
20260906 「AWS運用入門」著者が教える、運用業務への生成AI活用入門
masaruogura
0
220
データエンジニアリングワークショップ:Auto LoaderとSparkで学ぶデータパイプライン構築
databricksjapan
PRO
0
140
AndroidでHDRメディアを「壊さずに」扱う
chigichan24
0
380
【試作】IoT x AIエージェント
happysamurai294
0
120
Webとヘルスデータ
yukukotani
0
170
Azure App Service / Container Apps の組み込み認証
kuniteru
0
190
こんなアーキテクチャ図は嫌だ BEYOND THE TIME: 半年後の自分へ贈る15のメッセージ / 15 of Anti-pattern in AWS Architecture Diagrams
naospon
3
220
Featured
See All Featured
Visualization
eitanlees
152
17k
<Decoding/> the Language of Devs - We Love SEO 2024
nikkihalliwell
1
310
Chasing Engaging Ingredients in Design
codingconduct
0
300
Getting science done with accelerated Python computing platforms
jacobtomlinson
2
470
AI: The stuff that nobody shows you
jnunemaker
PRO
9
970
Leveraging LLMs for student feedback in introductory data science courses - posit::conf(2025)
minecr
1
370
Speed Design
sergeychernyshev
33
2.1k
How to Build an AI Search Optimization Roadmap - Criteria and Steps to Take #SEOIRL
aleyda
1
2.2k
Intergalactic Javascript Robots from Outer Space
tanoku
273
27k
Impact Scores and Hybrid Strategies: The future of link building
tamaranovitovic
0
430
How to optimise 3,500 product descriptions for ecommerce in one day using ChatGPT
katarinadahlin
PRO
2
3.8k
Docker and Python
trallard
47
4.2k
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