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 (ode aan de code)
freekmurze
0
27
Uncharted packages (Laravel Live Denmark)
freekmurze
0
220
I shall define this only once
freekmurze
0
420
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
870
A practical look at multitenancy in Laravel
freekmurze
1
360
A practical look at multitenancy in Laravel (Laracon US)
freekmurze
0
740
Other Decks in Programming
See All in Programming
CSC509 Lecture 08
javiergs
PRO
0
270
CSC305 Lecture 10
javiergs
PRO
0
320
Claude Agent SDK を使ってみよう
hyshu
0
1.4k
React Nativeならぬ"Vue Native"が実現するかも?_新世代マルチプラットフォーム開発フレームワークのLynxとLynxのVue.js対応を追ってみよう_Vue Lynx
yut0naga1_fa
2
1.9k
バッチ処理を「状態の記録」から「事実の記録」へ
panda728
PRO
0
210
品質ワークショップをやってみた
nealle
0
660
AI 駆動開発におけるコミュニティと AWS CDK の価値
konokenj
5
300
他言語経験者が Golangci-lint を最初のコーディングメンターにした話 / How Golangci-lint Became My First Coding Mentor: A Story from a Polyglot Programmer
uma31
0
480
Software Architecture
hschwentner
6
2.4k
CSC305 Lecture 09
javiergs
PRO
0
330
contribution to astral-sh/uv
shunsock
0
560
Developer Joy - The New Paradigm
hollycummins
1
380
Featured
See All Featured
Optimising Largest Contentful Paint
csswizardry
37
3.5k
Understanding Cognitive Biases in Performance Measurement
bluesmoon
31
2.7k
Designing for humans not robots
tammielis
254
26k
StorybookのUI Testing Handbookを読んだ
zakiyama
31
6.3k
Code Reviewing Like a Champion
maltzj
526
40k
How To Stay Up To Date on Web Technology
chriscoyier
791
250k
VelocityConf: Rendering Performance Case Studies
addyosmani
333
24k
Into the Great Unknown - MozCon
thekraken
40
2.1k
A better future with KSS
kneath
239
18k
The Illustrated Children's Guide to Kubernetes
chrisshort
51
51k
Practical Tips for Bootstrapping Information Extraction Pipelines
honnibal
PRO
23
1.5k
Music & Morning Musume
bryan
46
6.9k
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?