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
340
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 (Laravel Live Denmark)
freekmurze
0
190
I shall define this only once
freekmurze
0
390
An Introduction to Snapshot testing
freekmurze
0
480
Event Sourcing In Laravel
freekmurze
0
240
Building a realtime dashboard with Laravel Livewire (PHPKonf)
freekmurze
0
790
A tour behind the scenes of Oh Dear (PHP Benelux)
freekmurze
2
840
A practical look at multitenancy in Laravel
freekmurze
1
340
A practical look at multitenancy in Laravel (Laracon US)
freekmurze
0
720
Highlights Flare codebase (Laracon online)
freekmurze
0
490
Other Decks in Programming
See All in Programming
AIコーディングエージェントを 「使いこなす」ための実践知と現在地 in ログラス / How to Use AI Coding Agent in Loglass
rkaga
4
1.4k
Duke on CRaC with Jakarta EE
ivargrimstad
1
180
Designing Your Organization's Test Pyramid ( #scrumniigata )
teyamagu
PRO
5
1.6k
状態と共に暮らす:ステートフルへの挑戦
ypresto
3
1.3k
파급효과: From AI to Android Development
l2hyunwoo
0
170
fieldalignmentから見るGoの構造体
kuro_kurorrr
0
140
Browser and UI #2 HTML/ARIA
ken7253
2
180
医療系ソフトウェアのAI駆動開発
koukimiura
1
140
Storybookの情報をMCPサーバー化する
shota_tech
3
1.3k
ドメイン駆動設計とXPで支える子どもの未来 / Domain-Driven Design and XP Supporting Children's Future
nrslib
0
320
クラス設計の手順
akikogoto
0
120
Embracing Ruby magic
vinistock
2
270
Featured
See All Featured
Fontdeck: Realign not Redesign
paulrobertlloyd
84
5.5k
Bash Introduction
62gerente
613
210k
Optimising Largest Contentful Paint
csswizardry
37
3.2k
How STYLIGHT went responsive
nonsquared
100
5.5k
CSS Pre-Processors: Stylus, Less & Sass
bermonpainter
357
30k
The Success of Rails: Ensuring Growth for the Next 100 Years
eileencodes
45
7.2k
Design and Strategy: How to Deal with People Who Don’t "Get" Design
morganepeng
129
19k
How to Ace a Technical Interview
jacobian
276
23k
Building Better People: How to give real-time feedback that sticks.
wjessup
368
19k
[RailsConf 2023] Rails as a piece of cake
palkan
54
5.5k
Building Adaptive Systems
keathley
41
2.5k
RailsConf 2023
tenderlove
30
1.1k
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?