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 (phplimburg)
Search
Freek Van der Herten
September 07, 2017
Programming
1
360
snapshot testing (phplimburg)
Freek Van der Herten
September 07, 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
31
Uncharted packages (Laravel Live Denmark)
freekmurze
0
230
I shall define this only once
freekmurze
0
440
An Introduction to Snapshot testing
freekmurze
0
510
Event Sourcing In Laravel
freekmurze
0
260
Building a realtime dashboard with Laravel Livewire (PHPKonf)
freekmurze
0
830
A tour behind the scenes of Oh Dear (PHP Benelux)
freekmurze
2
880
A practical look at multitenancy in Laravel
freekmurze
1
370
A practical look at multitenancy in Laravel (Laracon US)
freekmurze
0
750
Other Decks in Programming
See All in Programming
The Missing Link in Angular's Signal Story: Resource API and httpResource
manfredsteyer
PRO
0
140
高単価案件で働くための心構え
nullnull
0
150
PyCon mini 東海 2025「個人ではじめるマルチAIエージェント入門 〜LangChain × LangGraphでアイデアを形にするステップ〜」
komofr
3
1.1k
スタートアップを支える技術戦略と組織づくり
pospome
7
6.8k
Querying Design System デザインシステムの意思決定を支える構造検索
ikumatadokoro
1
1.2k
[堅牢.py #1] テストを書かない研究者に送る、最初にテストを書く実験コード入門 / Let's start your ML project by writing tests
shunk031
10
4.7k
Honoを技術選定したAI要件定義プラットフォームAcsimでの意思決定
codenote
0
250
Flutterアプリ運用の現場で役立った監視Tips 5選
ostk0069
1
480
Phronetic Team with AI - Agile Japan 2025 closing
hiranabe
2
640
関数の挙動書き換える
takatofukui
4
730
Web エンジニアが JavaScript で AI Agent を作る / JSConf JP 2025 sponsor session
izumin5210
4
1.9k
Developing Specifications - Jakarta EE: a Real World Example
ivargrimstad
0
110
Featured
See All Featured
GraphQLの誤解/rethinking-graphql
sonatard
73
11k
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
234
17k
Creating an realtime collaboration tool: Agile Flush - .NET Oxford
marcduiker
34
2.3k
Intergalactic Javascript Robots from Outer Space
tanoku
273
27k
Building Applications with DynamoDB
mza
96
6.8k
How to train your dragon (web standard)
notwaldorf
97
6.4k
CSS Pre-Processors: Stylus, Less & Sass
bermonpainter
359
30k
Code Reviewing Like a Champion
maltzj
527
40k
Typedesign – Prime Four
hannesfritz
42
2.9k
Art, The Web, and Tiny UX
lynnandtonic
303
21k
[RailsConf 2023 Opening Keynote] The Magic of Rails
eileencodes
31
9.7k
Dealing with People You Can't Stand - Big Design 2015
cassininazir
367
27k
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-phplimburg https://spatie.be/opensource https://murze.be https://murze.be/newsletter/
QUESTIONS?