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
コマンドとリード間の連携に対する脅威分析フレームワーク
pandayumi
1
460
要求定義・仕様記述・設計・検証の手引き - 理論から学ぶ明確で統一された成果物定義
orgachem
PRO
1
160
CSC307 Lecture 06
javiergs
PRO
0
690
HTTPプロトコル正しく理解していますか? 〜かわいい猫と共に学ぼう。ฅ^•ω•^ฅ ニャ〜
hekuchan
2
690
CSC307 Lecture 08
javiergs
PRO
0
670
Package Management Learnings from Homebrew
mikemcquaid
0
230
AI巻き込み型コードレビューのススメ
nealle
2
420
AIで開発はどれくらい加速したのか?AIエージェントによるコード生成を、現場の評価と研究開発の評価の両面からdeep diveしてみる
daisuketakeda
1
2.5k
Rust 製のコードエディタ “Zed” を使ってみた
nearme_tech
PRO
0
190
Fluid Templating in TYPO3 14
s2b
0
130
AIエージェントのキホンから学ぶ「エージェンティックコーディング」実践入門
masahiro_nishimi
5
470
CSC307 Lecture 03
javiergs
PRO
1
490
Featured
See All Featured
Keith and Marios Guide to Fast Websites
keithpitt
413
23k
Color Theory Basics | Prateek | Gurzu
gurzu
0
200
Organizational Design Perspectives: An Ontology of Organizational Design Elements
kimpetersen
PRO
1
200
The #1 spot is gone: here's how to win anyway
tamaranovitovic
2
940
Highjacked: Video Game Concept Design
rkendrick25
PRO
1
290
Applied NLP in the Age of Generative AI
inesmontani
PRO
4
2k
Believing is Seeing
oripsolob
1
56
Build your cross-platform service in a week with App Engine
jlugia
234
18k
Evolution of real-time – Irina Nazarova, EuRuKo, 2024
irinanazarova
9
1.2k
Heart Work Chapter 1 - Part 1
lfama
PRO
5
35k
Scaling GitHub
holman
464
140k
Redefining SEO in the New Era of Traffic Generation
szymonslowik
1
220
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