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
470
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
190
I shall define this only once
freekmurze
0
390
Event Sourcing In Laravel
freekmurze
0
230
Building a realtime dashboard with Laravel Livewire (PHPKonf)
freekmurze
0
780
A tour behind the scenes of Oh Dear (PHP Benelux)
freekmurze
2
830
A practical look at multitenancy in Laravel
freekmurze
1
340
A practical look at multitenancy in Laravel (Laracon US)
freekmurze
0
710
Highlights Flare codebase (Laracon online)
freekmurze
0
470
Introducing Mailcoach
freekmurze
1
610
Other Decks in Technology
See All in Technology
React Server Componentは 何を解決し何を解決しないのか / What do React Server Components solve, and what do they not solve?
kaminashi
6
1.3k
[CATS]Amazon Bedrock GenUハンズオン座学資料 #2 GenU環境でRAGを体験してみよう
tsukuboshi
0
150
Restarting_SRE_Road_to_SRENext_.pdf
_awache
1
200
Cline、めっちゃ便利、お金が飛ぶ💸
iwamot
20
19k
OCI見積もり入門セミナー
oracle4engineer
PRO
0
130
3/26 クラウド食堂LT #2 GenU案件を通して学んだ教訓 登壇資料
ymae
1
220
入社後SREチームのミッションや課題の整理をした話
morix1500
1
150
Vision Language Modelを活用した メルカリの類似画像レコメンドの性能改善
yadayuki
9
1.3k
Proxmox VE超入門 〜 無料で作れるご自宅仮想化プラットフォームブックマークする
devops_vtj
0
210
数百台のオンプレミスのサーバーをEKSに移行した話
yukiteraoka
0
740
年末調整プロダクトの内部品質改善活動について
kaomi_wombat
0
210
Agile TPIを活用した品質改善事例
tomasagi
0
370
Featured
See All Featured
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
233
17k
GraphQLとの向き合い方2022年版
quramy
45
14k
Code Review Best Practice
trishagee
67
18k
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
30
2.3k
How STYLIGHT went responsive
nonsquared
99
5.4k
The Pragmatic Product Professional
lauravandoore
33
6.5k
A Tale of Four Properties
chriscoyier
158
23k
How to Think Like a Performance Engineer
csswizardry
22
1.5k
Refactoring Trust on Your Teams (GOTO; Chicago 2020)
rmw
34
2.9k
What's in a price? How to price your products and services
michaelherold
245
12k
How to train your dragon (web standard)
notwaldorf
91
5.9k
CoffeeScript is Beautiful & I Never Want to Write Plain JavaScript Again
sstephenson
160
15k
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