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
Christian Fortes
April 02, 2018
Programming
0
36
Jest - Do more, spend less time
Christian Fortes
April 02, 2018
Tweet
Share
More Decks by Christian Fortes
See All by Christian Fortes
Tech Track - Angular 2 (Part 2)
chrisgfortes
0
51
Tech Track - Angular 2 (Part 3)
chrisgfortes
0
31
Tech Track - Angular 2 (Part 1)
chrisgfortes
0
52
Uma breve introdução sobre AngularJS 1.x
chrisgfortes
0
28
Other Decks in Programming
See All in Programming
責任感のあるCloudWatchアラームを設計しよう
akihisaikeda
3
180
コマンドとリード間の連携に対する脅威分析フレームワーク
pandayumi
1
460
Automatic Grammar Agreementと Markdown Extended Attributes について
kishikawakatsumi
0
200
疑似コードによるプロンプト記述、どのくらい正確に実行される?
kokuyouwind
0
390
Grafana:建立系統全知視角的捷徑
blueswen
0
330
例外処理とどう使い分ける?Result型を使ったエラー設計 #burikaigi
kajitack
16
6.1k
HTTPプロトコル正しく理解していますか? 〜かわいい猫と共に学ぼう。ฅ^•ω•^ฅ ニャ〜
hekuchan
2
690
インターン生でもAuth0で認証基盤刷新が出来るのか
taku271
0
190
CSC307 Lecture 07
javiergs
PRO
1
550
AtCoder Conference 2025
shindannin
0
1.1k
それ、本当に安全? ファイルアップロードで見落としがちなセキュリティリスクと対策
penpeen
7
3.9k
CSC307 Lecture 01
javiergs
PRO
0
690
Featured
See All Featured
Documentation Writing (for coders)
carmenintech
77
5.3k
We Analyzed 250 Million AI Search Results: Here's What I Found
joshbly
1
730
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
31
2.7k
Large-scale JavaScript Application Architecture
addyosmani
515
110k
Building an army of robots
kneath
306
46k
Building a Scalable Design System with Sketch
lauravandoore
463
34k
How To Speak Unicorn (iThemes Webinar)
marktimemedia
1
380
KATA
mclloyd
PRO
34
15k
How to Grow Your eCommerce with AI & Automation
katarinadahlin
PRO
1
110
Exploring the relationship between traditional SERPs and Gen AI search
raygrieselhuber
PRO
2
3.6k
Typedesign – Prime Four
hannesfritz
42
2.9k
How To Stay Up To Date on Web Technology
chriscoyier
791
250k
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