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
Freek Van der Herten
August 29, 2017
Programming
0
130
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 (Laravel Live Denmark)
freekmurze
0
200
I shall define this only once
freekmurze
0
400
An Introduction to Snapshot testing
freekmurze
0
490
Event Sourcing In Laravel
freekmurze
0
240
Building a realtime dashboard with Laravel Livewire (PHPKonf)
freekmurze
0
800
A tour behind the scenes of Oh Dear (PHP Benelux)
freekmurze
2
850
A practical look at multitenancy in Laravel
freekmurze
1
350
A practical look at multitenancy in Laravel (Laracon US)
freekmurze
0
720
Highlights Flare codebase (Laracon online)
freekmurze
0
500
Other Decks in Programming
See All in Programming
実践ArchUnit ~実例による検証パターンの紹介~
ogiwarat
2
250
プロダクト開発でも使おう 関数のオーバーロード
yoiwamoto
0
150
Datadog RUM 本番導入までの道
shinter61
1
260
從零到一:搭建你的第一個 Observability 平台
blueswen
1
890
eBPFを用いたAIネットワーク監視システム論文の実装 / eBPF Japan Meetup #4
yuukit
3
750
ASP.NETアプリケーションのモダナイズ インフラ編
tomokusaba
1
210
AIエージェントによるテストフレームワーク Arbigent
takahirom
0
370
Cursor AI Agentと伴走する アプリケーションの高速リプレイス
daisuketakeda
1
110
Gleamという選択肢
comamoca
6
700
Enterprise Web App. Development (2): Version Control Tool Training Ver. 5.1
knakagawa
1
110
iOSアプリ開発で 関数型プログラミングを実現する The Composable Architectureの紹介
yimajo
2
210
ワンバイナリWebサービスのススメ
mackee
10
7.7k
Featured
See All Featured
The Illustrated Children's Guide to Kubernetes
chrisshort
48
50k
The Cost Of JavaScript in 2023
addyosmani
50
8.3k
Navigating Team Friction
lara
186
15k
Imperfection Machines: The Place of Print at Facebook
scottboms
267
13k
Fashionably flexible responsive web design (full day workshop)
malarkey
407
66k
Cheating the UX When There Is Nothing More to Optimize - PixelPioneers
stephaniewalter
281
13k
It's Worth the Effort
3n
184
28k
Adopting Sorbet at Scale
ufuk
77
9.4k
Side Projects
sachag
454
42k
Art, The Web, and Tiny UX
lynnandtonic
299
21k
Done Done
chrislema
184
16k
The Psychology of Web Performance [Beyond Tellerrand 2023]
tammyeverts
47
2.8k
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?