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
280
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
I shall define this only once
freekmurze
0
340
An Introduction to Snapshot testing
freekmurze
0
390
Event Sourcing In Laravel
freekmurze
0
200
Building a realtime dashboard with Laravel Livewire (PHPKonf)
freekmurze
0
690
A tour behind the scenes of Oh Dear (PHP Benelux)
freekmurze
2
730
A practical look at multitenancy in Laravel
freekmurze
1
290
A practical look at multitenancy in Laravel (Laracon US)
freekmurze
0
640
Highlights Flare codebase (Laracon online)
freekmurze
0
370
Introducing Mailcoach
freekmurze
1
550
Other Decks in Programming
See All in Programming
CSC307 Lecture 12
javiergs
PRO
0
220
CSC307 Lecture 10
javiergs
PRO
0
310
Introduction to GitOps
hwchiu
0
110
生成AIをkintoneに連携してみた
hideg
0
230
Rustのweb開発を助ける 便利なツール紹介
yuki0418
1
190
Async Await: Mastering Python's Time-Bending Tricks - EuroPython2024
yanbo
1
290
Prompt FlowによるLLMアプリケーション開発
yuto2000
1
1k
CSC307 Lecture 08
javiergs
PRO
0
330
「2024年版 Kotlin サーバーサイドプログラミング実践開発」の補講 〜O/Rマッパー編〜
n_takehata
2
260
継続的な活動で築く地方エンジニアの道
myamashii
2
350
SRE チーム立ち上げ前に考えたこと・取り組んだこと / Considerations and Preparations Before Establishing an SRE Team
mackey0225
3
320
実用的かつリーズナブルな 「Azure × Gemini × LINE」~キャラクターBot 実装ライブデモ~
tomodo_ysys
1
170
Featured
See All Featured
GraphQLの誤解/rethinking-graphql
sonatard
59
9.6k
Web development in the modern age
philhawksworth
203
10k
RailsConf & Balkan Ruby 2019: The Past, Present, and Future of Rails at GitHub
eileencodes
129
32k
Happy Clients
brianwarren
94
6.5k
Making the Leap to Tech Lead
cromwellryan
127
8.7k
Making Projects Easy
brettharned
111
5.7k
The Psychology of Web Performance [Beyond Tellerrand 2023]
tammyeverts
24
1.8k
Refactoring Trust on Your Teams (GOTO; Chicago 2020)
rmw
29
2.5k
jQuery: Nuts, Bolts and Bling
dougneiner
61
7.4k
A Tale of Four Properties
chriscoyier
155
22k
Art, The Web, and Tiny UX
lynnandtonic
291
20k
Git: the NoSQL Database
bkeepers
PRO
423
64k
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?