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 (dpc)
Search
Freek Van der Herten
June 30, 2017
Technology
0
150
Snapshot testing (dpc)
Freek Van der Herten
June 30, 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
30
Uncharted packages (Laravel Live Denmark)
freekmurze
0
220
I shall define this only once
freekmurze
0
440
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
880
A practical look at multitenancy in Laravel
freekmurze
1
370
A practical look at multitenancy in Laravel (Laracon US)
freekmurze
0
750
Other Decks in Technology
See All in Technology
Flutterコントリビューションのススメ
d_r_1009
1
400
Proxmox × HCP Terraformで始めるお家プライベートクラウド
lamaglama39
1
200
マイクロリブート ~ACEマインドセットで実現するアジャイル~
sony
1
370
Introducing RFC9111 / YAPC::Fukuoka 2025
k1low
1
240
QAエンジニアがプロダクト専任で チームの中に入ると。。。?/登壇資料(杉森 太樹)
hacobu
PRO
1
620
これからアウトプットする人たちへ - アウトプットを支える技術 / that support output
soudai
PRO
18
5.5k
データとAIで未来を創るDatabricks - 君の可能性を加速させるプラットフォーム
taka_aki
0
110
自己的售票系統自己做!
eddie
0
450
Datadog On-Call と Cloud SIEM で作る SOC 基盤
kuriyosh
0
180
機密情報の漏洩を防げ! Webフロントエンド開発で意識すべき漏洩パターンとその対策
mizdra
PRO
9
3.4k
QAを"自動化する"ことの本質
kshino
1
120
なぜインフラコードのモジュール化は難しいのか - アプリケーションコードとの本質的な違いから考える
mizzy
52
17k
Featured
See All Featured
Measuring & Analyzing Core Web Vitals
bluesmoon
9
670
No one is an island. Learnings from fostering a developers community.
thoeni
21
3.5k
Music & Morning Musume
bryan
46
6.9k
Visualizing Your Data: Incorporating Mongo into Loggly Infrastructure
mongodb
48
9.8k
Mobile First: as difficult as doing things right
swwweet
225
10k
The World Runs on Bad Software
bkeepers
PRO
72
12k
Why You Should Never Use an ORM
jnunemaker
PRO
60
9.6k
Dealing with People You Can't Stand - Big Design 2015
cassininazir
367
27k
GitHub's CSS Performance
jonrohan
1032
470k
It's Worth the Effort
3n
187
28k
[RailsConf 2023] Rails as a piece of cake
palkan
57
6.1k
Sharpening the Axe: The Primacy of Toolmaking
bcantrill
46
2.6k
Transcript
A practical intro to snapshot testing
About me Freek Van der Herten Partner & developer at
SPATIE @freekmurze https://murze.be
About me phpantwerp.be Dries Vints @driesvints Frederick Vanbrabant @TheEdonian
Since 2003 Websites, applications and webshops Team 4 developers, 1
manager Specialization Laravel development
OPEN SOURCE SOFTWARE
± 120 packages on Packagist Laravel, Framework agnostic PHP ±
4 000 000 downloads in total, growing ±450 000 a month We create a lot of it Open source software
http://github-awards.com/users?type=world&language=php Open source software
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?
Old 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 Interesting links
QUESTIONS?
Thank you! https://speakerdeck.com/freekmurze/snapshot-testing-dpc https://spatie.be/opensource https://murze.be https://murze.be/newsletter/