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
180
I shall define this only once
freekmurze
0
380
An Introduction to Snapshot testing
freekmurze
0
460
Event Sourcing In Laravel
freekmurze
0
230
Building a realtime dashboard with Laravel Livewire (PHPKonf)
freekmurze
0
770
A tour behind the scenes of Oh Dear (PHP Benelux)
freekmurze
2
820
A practical look at multitenancy in Laravel
freekmurze
1
330
A practical look at multitenancy in Laravel (Laracon US)
freekmurze
0
700
Highlights Flare codebase (Laracon online)
freekmurze
0
460
Other Decks in Programming
See All in Programming
もう僕は OpenAPI を書きたくない
sgash708
5
1.9k
責務と認知負荷を整える! 抽象レベルを意識した関心の分離
yahiru
8
1.3k
負債になりにくいCSSをデザイナとつくるには?
fsubal
10
2.6k
Introduction to kotlinx.rpc
arawn
0
760
推しメソッドsource_locationのしくみを探る - はじめてRubyのコードを読んでみた
nobu09
2
230
Bedrock Agentsレスポンス解析によるAgentのOps
licux
3
920
バッチを作らなきゃとなったときに考えること
irof
2
520
Honoとフロントエンドの 型安全性について
yodaka
7
1.4k
Visual StudioのGitHub Copilotでいろいろやってみる
tomokusaba
1
210
自力でTTSモデルを作った話
zgock999
0
100
クリーンアーキテクチャから見る依存の向きの大切さ
shimabox
5
960
Jakarta EE meets AI
ivargrimstad
0
320
Featured
See All Featured
RailsConf 2023
tenderlove
29
1k
The Psychology of Web Performance [Beyond Tellerrand 2023]
tammyeverts
46
2.3k
Side Projects
sachag
452
42k
How GitHub (no longer) Works
holman
314
140k
Why You Should Never Use an ORM
jnunemaker
PRO
55
9.2k
Put a Button on it: Removing Barriers to Going Fast.
kastner
60
3.7k
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
233
17k
10 Git Anti Patterns You Should be Aware of
lemiorhan
PRO
656
59k
XXLCSS - How to scale CSS and keep your sanity
sugarenia
248
1.3M
個人開発の失敗を避けるイケてる考え方 / tips for indie hackers
panda_program
100
18k
Practical Orchestrator
shlominoach
186
10k
The Myth of the Modular Monolith - Day 2 Keynote - Rails World 2024
eileencodes
21
2.5k
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?