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
Amazon Bedrockを活用したRAGの品質管理パイプライン構築
tosuri13
5
760
Architectural Extensions
denyspoltorak
0
290
Automatic Grammar Agreementと Markdown Extended Attributes について
kishikawakatsumi
0
200
ノイジーネイバー問題を解決する 公平なキューイング
occhi
0
110
高速開発のためのコード整理術
sutetotanuki
1
400
OCaml 5でモダンな並列プログラミングを Enjoyしよう!
haochenx
0
140
AI によるインシデント初動調査の自動化を行う AI インシデントコマンダーを作った話
azukiazusa1
1
740
Apache Iceberg V3 and migration to V3
tomtanaka
0
160
AIと一緒にレガシーに向き合ってみた
nyafunta9858
0
250
QAフローを最適化し、品質水準を満たしながらリリースまでの期間を最短化する #RSGT2026
shibayu36
2
4.4k
CSC307 Lecture 02
javiergs
PRO
1
780
AI & Enginnering
codelynx
0
110
Featured
See All Featured
Making the Leap to Tech Lead
cromwellryan
135
9.7k
<Decoding/> the Language of Devs - We Love SEO 2024
nikkihalliwell
1
130
Making Projects Easy
brettharned
120
6.6k
The #1 spot is gone: here's how to win anyway
tamaranovitovic
2
940
The Power of CSS Pseudo Elements
geoffreycrofte
80
6.2k
A Soul's Torment
seathinner
5
2.3k
The Art of Programming - Codeland 2020
erikaheidi
57
14k
Marketing to machines
jonoalderson
1
4.6k
The browser strikes back
jonoalderson
0
390
Cheating the UX When There Is Nothing More to Optimize - PixelPioneers
stephaniewalter
287
14k
Context Engineering - Making Every Token Count
addyosmani
9
660
Paper Plane (Part 1)
katiecoart
PRO
0
4.3k
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