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
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
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
54
Uncharted packages (Laravel Live Denmark)
freekmurze
0
250
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
900
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
入門DBSC
ynojima
0
120
Digitization部 紹介資料
sansan33
PRO
1
7k
技術的負債の泥沼から組織を救う3つの転換点
nwiizo
4
870
Security Diaries of an Open Source IAM
ahus1
0
190
WBCの解説は生成AIにやらせよう - 生成AIで野球解説者AI Agentを実現する / Baseball Commentator AI Agent for Gemini
shinyorke
PRO
0
320
型を書かないRuby開発への挑戦
riseshia
0
140
Claude Cowork Plugins を読む - Skills駆動型業務エージェント設計の実像と構造
knishioka
0
240
クラウド時代における一時権限取得
krrrr38
1
150
問い合わせ自動化の技術的挑戦
recruitengineers
PRO
2
120
社内ワークショップで終わらせない 業務改善AIエージェント開発
lycorptech_jp
PRO
1
450
DX Improvement at Scale
ntk1000
2
170
「データとの対話」の現在地と未来
kobakou
0
1.3k
Featured
See All Featured
Design and Strategy: How to Deal with People Who Don’t "Get" Design
morganepeng
133
19k
What Being in a Rock Band Can Teach Us About Real World SEO
427marketing
0
180
WCS-LA-2024
lcolladotor
0
470
StorybookのUI Testing Handbookを読んだ
zakiyama
31
6.6k
A Modern Web Designer's Workflow
chriscoyier
698
190k
Navigating Team Friction
lara
192
16k
Why You Should Never Use an ORM
jnunemaker
PRO
61
9.8k
Fantastic passwords and where to find them - at NoRuKo
philnash
52
3.6k
Highjacked: Video Game Concept Design
rkendrick25
PRO
1
300
Rebuilding a faster, lazier Slack
samanthasiow
85
9.4k
DevOps and Value Stream Thinking: Enabling flow, efficiency and business value
helenjbeal
1
140
Understanding Cognitive Biases in Performance Measurement
bluesmoon
32
2.8k
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