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
snapshot testing (laraconeu)
Search
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
Freek Van der Herten
August 29, 2017
Programming
0
140
snapshot testing (laraconeu)
Freek Van der Herten
August 29, 2017
Tweet
Share
More Decks by Freek Van der Herten
See All by Freek Van der Herten
Uncharted packages (ode aan de code)
freekmurze
0
51
Uncharted packages (Laravel Live Denmark)
freekmurze
0
240
I shall define this only once
freekmurze
0
460
An Introduction to Snapshot testing
freekmurze
0
530
Event Sourcing In Laravel
freekmurze
0
270
Building a realtime dashboard with Laravel Livewire (PHPKonf)
freekmurze
0
850
A tour behind the scenes of Oh Dear (PHP Benelux)
freekmurze
2
890
A practical look at multitenancy in Laravel
freekmurze
1
390
A practical look at multitenancy in Laravel (Laracon US)
freekmurze
0
770
Other Decks in Programming
See All in Programming
FOSDEM 2026: STUNMESH-go: Building P2P WireGuard Mesh Without Self-Hosted Infrastructure
tjjh89017
0
170
AtCoder Conference 2025
shindannin
0
1.1k
SourceGeneratorのススメ
htkym
0
200
Oxlint JS plugins
kazupon
1
970
Best-Practices-for-Cortex-Analyst-and-AI-Agent
ryotaroikeda
1
110
「ブロックテーマでは再現できない」は本当か?
inc2734
0
1k
16年目のピクシブ百科事典を支える最新の技術基盤 / The Modern Tech Stack Powering Pixiv Encyclopedia in its 16th Year
ahuglajbclajep
5
1k
Rust 製のコードエディタ “Zed” を使ってみた
nearme_tech
PRO
0
190
Oxlintはいいぞ
yug1224
5
1.3k
The Past, Present, and Future of Enterprise Java
ivargrimstad
0
590
例外処理とどう使い分ける?Result型を使ったエラー設計 #burikaigi
kajitack
16
6.1k
AgentCoreとHuman in the Loop
har1101
5
240
Featured
See All Featured
The #1 spot is gone: here's how to win anyway
tamaranovitovic
2
940
Helping Users Find Their Own Way: Creating Modern Search Experiences
danielanewman
31
3.1k
How to Talk to Developers About Accessibility
jct
2
130
Thoughts on Productivity
jonyablonski
74
5k
Efficient Content Optimization with Google Search Console & Apps Script
katarinadahlin
PRO
1
320
Neural Spatial Audio Processing for Sound Field Analysis and Control
skoyamalab
0
170
Evolution of real-time – Irina Nazarova, EuRuKo, 2024
irinanazarova
9
1.2k
Between Models and Reality
mayunak
1
190
<Decoding/> the Language of Devs - We Love SEO 2024
nikkihalliwell
1
130
Why Mistakes Are the Best Teachers: Turning Failure into a Pathway for Growth
auna
0
53
The Cost Of JavaScript in 2023
addyosmani
55
9.5k
Unsuck your backbone
ammeep
671
58k
Transcript
A practical intro to snapshot testing and PHPUnit-watcher
About me Freek Van der Herten Partner & developer at
SPATIE Blogging at https://murze.be https://murze.be/newsletter
OPEN SOURCE SOFTWARE
https://spatie.be/en/opensource/laravel
Open source software ± 160 public repositories on GitHub August
2016: ± 800 000 downloads August 2017: ± 5 000 000 downloads ± 500 000 downloads a month
LET’S TALK SNAPSHOT TESTING
A file on disk, let’s call in snapshot Test succeeds
if output matches snapshot If not, test will fail What?
Another name: characterization testing Popularized by Facebook Jest Testing interfaces
Where does it come from?
https://github.com/spatie/phpunit-snapshot-assertions assertMatchesSnapshot assertMatchesJsonSnapshot assertMatchesXmlSnapshot How can we do it in
PHP?
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
https://github.com/spatie/phpunit-snapshot-assertions https://sebastiandedeyne.com/posts/2017/a-package-for-snapshot- testing-in-phpunit https://murze.be/2017/04/practical-introduction-snapshot-testing/ https://www.sitepoint.com/snapshot-testing-viable-php/ https://facebook.github.io/jest/docs/snapshot-testing.html https://github.com/spatie/phpunit-watcher Interesting links
Thank you! https://speakerdeck.com/freekmurze/snapshot-testing-laraconeu https://spatie.be/opensource https://murze.be https://murze.be/newsletter/
QUESTIONS?