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
0
350
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
I shall define this only once
freekmurze
0
320
Event Sourcing In Laravel
freekmurze
0
190
Building a realtime dashboard with Laravel Livewire (PHPKonf)
freekmurze
0
660
A tour behind the scenes of Oh Dear (PHP Benelux)
freekmurze
2
680
A practical look at multitenancy in Laravel
freekmurze
1
280
A practical look at multitenancy in Laravel (Laracon US)
freekmurze
0
610
Highlights Flare codebase (Laracon online)
freekmurze
0
330
Introducing Mailcoach
freekmurze
1
510
Highlights from the Flare codebase (Full Stack Ghent)
freekmurze
0
530
Other Decks in Technology
See All in Technology
どう買う?Azure
kuniteru
1
190
Tohoku.Tech #1 「EC-CUBE/AWSの構築をChatGPTに相談してみました」by テンダ
jun2882
0
140
.NETの非同期戦略とUnityとの相互運用
neuecc
2
2.4k
Elementaryを用いたデータ品質の可視化とデータ基盤の運用改善
10xinc
6
1.4k
なんで私に登壇依頼が?! ~頼られるエンジニアになるためには~ /
mixi_engineers
PRO
2
200
技育祭2024春 LT Finatextホールディングス
kevinrobot34
1
160
Autify Company Deck
autifyhq
1
30k
TypeScript Quiz (Encraft #12 Frontend Quiz Night)
uhyo
2
320
オブジェクト指向宗教史
tanakahisateru
13
12k
複数の LLM モデルを扱う上で直面した辛みまとめ
kazuyaseki
1
230
XRミーティング 2024-03-20
1ftseabass
PRO
0
100
オブジェクトのおしゃべり大失敗 メッセージングアンチパターン集 / messaging anti-pattern collection
ytake
0
330
Featured
See All Featured
[RailsConf 2023] Rails as a piece of cake
palkan
21
3.8k
WebSockets: Embracing the real-time Web
robhawkes
59
6.9k
Cheating the UX When There Is Nothing More to Optimize - PixelPioneers
stephaniewalter
272
12k
"I'm Feeling Lucky" - Building Great Search Experiences for Today's Users (#IAC19)
danielanewman
219
21k
Documentation Writing (for coders)
carmenintech
59
3.8k
Adopting Sorbet at Scale
ufuk
66
8.5k
The Brand Is Dead. Long Live the Brand.
mthomps
48
21k
Practical Orchestrator
shlominoach
180
9.7k
Learning to Love Humans: Emotional Interface Design
aarron
266
39k
The Psychology of Web Performance [Beyond Tellerrand 2023]
tammyeverts
5
1.4k
How To Stay Up To Date on Web Technology
chriscoyier
781
250k
個人開発の失敗を避けるイケてる考え方 / tips for indie hackers
panda_program
57
14k
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