Lock in $30 Savings on PRO—Offer Ends Soon! ⏳
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
440
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 (Laravel Live Denmark)
freekmurze
0
160
I shall define this only once
freekmurze
0
360
Event Sourcing In Laravel
freekmurze
0
220
Building a realtime dashboard with Laravel Livewire (PHPKonf)
freekmurze
0
740
A tour behind the scenes of Oh Dear (PHP Benelux)
freekmurze
2
790
A practical look at multitenancy in Laravel
freekmurze
1
310
A practical look at multitenancy in Laravel (Laracon US)
freekmurze
0
680
Highlights Flare codebase (Laracon online)
freekmurze
0
440
Introducing Mailcoach
freekmurze
1
580
Other Decks in Technology
See All in Technology
Explain EXPLAIN
keiko713
2
160
リモートだからこそ 懸念だし1on1
jimpei
2
380
[GDG DevFest Bangkok 2024] - The Future of Retail E-commerce with Gemini AI
punsiriboo
0
240
Empowering Customer Decisions with Elasticsearch: From Search to Answer Generation
hinatades
PRO
0
210
ONNX推論クレートの比較と実装奮闘記
emergent
0
280
プロセス改善とE2E自動テストによる、プロダクトの品質向上事例
tomasagi
1
1.4k
40歲的我會給20歲的自己,關於軟體開發的7個建議
line_developers_tw
PRO
0
120
クラウドネイティブなNewSQLで実現するミッションクリティカルなアプリケーションの運用
yuyu_hf
PRO
1
160
Oracle Database 23c新機能 #5 データベース・パフォーマンス関連新機能前半
oracle4engineer
PRO
1
130
専門領域に特化したチームの挑戦
leveragestech
0
250
pmconf2024_UPSIDER
upsider_tech
0
3.2k
突き破って学ぶコンテナセキュリティ/container-breakout-cncj-lt
mochizuki875
6
930
Featured
See All Featured
Into the Great Unknown - MozCon
thekraken
33
1.5k
It's Worth the Effort
3n
183
27k
How To Stay Up To Date on Web Technology
chriscoyier
789
250k
Testing 201, or: Great Expectations
jmmastey
40
7.1k
VelocityConf: Rendering Performance Case Studies
addyosmani
326
24k
Bash Introduction
62gerente
608
210k
実際に使うSQLの書き方 徹底解説 / pgcon21j-tutorial
soudai
169
50k
Code Reviewing Like a Champion
maltzj
520
39k
Writing Fast Ruby
sferik
627
61k
Building an army of robots
kneath
302
43k
Understanding Cognitive Biases in Performance Measurement
bluesmoon
26
1.4k
Evolution of real-time – Irina Nazarova, EuRuKo, 2024
irinanazarova
4
410
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