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
Jest - Do more, spend less time
Search
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
Christian Fortes
April 02, 2018
Programming
40
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Jest - Do more, spend less time
Christian Fortes
April 02, 2018
More Decks by Christian Fortes
See All by Christian Fortes
Tech Track - Angular 2 (Part 2)
chrisgfortes
0
55
Tech Track - Angular 2 (Part 3)
chrisgfortes
0
34
Tech Track - Angular 2 (Part 1)
chrisgfortes
0
55
Uma breve introdução sobre AngularJS 1.x
chrisgfortes
0
29
Other Decks in Programming
See All in Programming
ソフトウェア設計に溶けるインフラ ― AWS CDK のインフラ認識論
konokenj
3
780
為什麼你並不需要ViewModel / No, you don't need a ViewModel
lovee
1
490
Laravel Boostに学ぶ、AIにPHPを書かせる技術 〜OSSの実装から蒸留するエージェント制御の王道〜
kentaroutakeda
3
690
今さら聞けない .NET CLI
htkym
0
190
夏だ!祭りだ!祭りとはドメインモデリングでは?
ryugen04
0
260
Google Apps Script で Ruby を動かす
kawahara
0
220
OpenSpecのproposalにbrainstormingを持たせてみた
tigertora7571
1
220
jsmini JavaScript Engine を作ってみた話
yosuke_furukawa
PRO
0
320
TSX の <Hoge<Fuga>> という構文に驚いた話 / tsx-type-argument-syntax
kanaru0928
0
230
PHP初心者セッション2026 〜生成AIでは見えない裏側を知る:今だからLAMPを通して仕組みを学ぶ〜
kashioka
0
910
属人化した知識を、 AIが辿れる地図にする
pkshadeck
PRO
1
170
運用ダッシュボードの設計を誰も教えてくれないのだけどみなさんどうしてるんですか? - チームに監視するという文化を根付かせるための第一歩を踏みたい -
satoshi256kbyte
1
110
Featured
See All Featured
The untapped power of vector embeddings
frankvandijk
2
1.8k
Leo the Paperboy
mayatellez
8
2.1k
Art, The Web, and Tiny UX
lynnandtonic
304
22k
DBのスキルで生き残る技術 - AI時代におけるテーブル設計の勘所
soudai
PRO
68
56k
CSS Pre-Processors: Stylus, Less & Sass
bermonpainter
360
30k
XXLCSS - How to scale CSS and keep your sanity
sugarenia
249
1.3M
B2B Lead Gen: Tactics, Traps & Triumph
marketingsoph
0
200
Getting science done with accelerated Python computing platforms
jacobtomlinson
2
430
AI: The stuff that nobody shows you
jnunemaker
PRO
9
910
We Analyzed 250 Million AI Search Results: Here's What I Found
joshbly
1
1.8k
Odyssey Design
rkendrick25
PRO
2
750
GitHub's CSS Performance
jonrohan
1033
470k
Transcript
Jest Do more, spend less time
Jest @chrisgfortes Jest? O que é? - Delightful JavaScript Testing
- Designed for React / ES6 - Developed by Facebook
Jest @chrisgfortes - Easy setup - Built-in code coverage reports
- Powerful mocking library - Snapshot Testing - Works with TypeScript - Complete library (No dependencies) Mas por que usar?
Jest @chrisgfortes Exemplo
Jest @chrisgfortes Código function sum(a, b) { return a +
b; } module.exports = sum; sum.js
Jest @chrisgfortes Escrevendo o teste const sum = require('./sum'); test('adds
1 + 2 to equal 3', () => { expect(sum(1, 2)).toBe(3); }); sum.test.js
Jest @chrisgfortes Install and Run console$ npm install --save-dev jest
console$ jest
Jest @chrisgfortes Result PASS ./sum.test.js ✓ adds 1 + 2
to equal 3 (5ms)
Jest @chrisgfortes Mas cadê a configuração????
Jest @chrisgfortes Zero configuration!!!!!!
Jest @chrisgfortes - sum.js (write a code js) - sum.test.js
(write your test) - Run a command (jest) Configuração é:
Jest @chrisgfortes Coverage console$ jest --coverage --collectCoverageFrom=[src/**/*.js]
Jest @chrisgfortes Coverage result:
Jest @chrisgfortes Reports (Istanbul) Jest use the report of Istanbul
https://github.com/gotwarlost/istanbul
Jest @chrisgfortes config.json { "verbose": true, "rootDir": "../../", "coverageDirectory": "test/coverage/",
"coverageReporters": [ "html" ], "collectCoverage": true, "collectCoverageFrom": [ "src/**/*.js", "!**/node_modules/**" ] }
Jest @chrisgfortes Usando config.json console$ jest -c ./config.json console$ jest
-c ./config.json --watchAll (Watch mode)
Jest Thanks! @chrisgfortes