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 (laraconus)
Search
Freek Van der Herten
July 25, 2017
Programming
0
120
snapshot testing (laraconus)
Freek Van der Herten
July 25, 2017
Tweet
Share
More Decks by Freek Van der Herten
See All by Freek Van der Herten
Uncharted packages (Laravel Live Denmark)
freekmurze
0
200
I shall define this only once
freekmurze
0
410
An Introduction to Snapshot testing
freekmurze
0
490
Event Sourcing In Laravel
freekmurze
0
250
Building a realtime dashboard with Laravel Livewire (PHPKonf)
freekmurze
0
800
A tour behind the scenes of Oh Dear (PHP Benelux)
freekmurze
2
850
A practical look at multitenancy in Laravel
freekmurze
1
350
A practical look at multitenancy in Laravel (Laracon US)
freekmurze
0
720
Highlights Flare codebase (Laracon online)
freekmurze
0
510
Other Decks in Programming
See All in Programming
アンドパッドの Go 勉強会「 gopher 会」とその内容の紹介
andpad
0
270
「Cursor/Devin全社導入の理想と現実」のその後
saitoryc
0
340
Cursor AI Agentと伴走する アプリケーションの高速リプレイス
daisuketakeda
1
130
Team topologies and the microservice architecture: a synergistic relationship
cer
PRO
0
1.1k
明示と暗黙 ー PHPとGoの インターフェイスの違いを知る
shimabox
2
380
C++20 射影変換
faithandbrave
0
540
Team operations that are not burdened by SRE
kazatohiei
1
260
たった 1 枚の PHP ファイルで実装する MCP サーバ / MCP Server with Vanilla PHP
okashoi
1
200
Result型で“失敗”を型にするPHPコードの書き方
kajitack
4
510
What Spring Developers Should Know About Jakarta EE
ivargrimstad
0
300
システム成長を止めない!本番無停止テーブル移行の全貌
sakawe_ee
1
150
ASP.NETアプリケーションのモダナイズ インフラ編
tomokusaba
1
420
Featured
See All Featured
A Tale of Four Properties
chriscoyier
160
23k
BBQ
matthewcrist
89
9.7k
Balancing Empowerment & Direction
lara
1
380
Raft: Consensus for Rubyists
vanstee
140
7k
The Psychology of Web Performance [Beyond Tellerrand 2023]
tammyeverts
48
2.8k
The Myth of the Modular Monolith - Day 2 Keynote - Rails World 2024
eileencodes
26
2.9k
Into the Great Unknown - MozCon
thekraken
39
1.9k
GraphQLの誤解/rethinking-graphql
sonatard
71
11k
Gamification - CAS2011
davidbonilla
81
5.3k
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
31
2.4k
Designing Experiences People Love
moore
142
24k
Responsive Adventures: Dirty Tricks From The Dark Corners of Front-End
smashingmag
252
21k
Transcript
A practical intro to snapshot testing
Pronouncing Dutch Michael 3/10 Jacob 1/10
Pronouncing Dutch Michael 9/10 Jacob 9/10
Drake
Frake
Pronouncing Dutch: Spatie Spa Sea
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
Thank you! https://speakerdeck.com/freekmurze/snapshot-testing-laraconus https://spatie.be/opensource https://murze.be https://murze.be/newsletter/
QUESTIONS?