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
ノイジーネイバー問題を解決する 公平なキューイング
occhi
0
110
開発者から情シスまで - 多様なユーザー層に届けるAPI提供戦略 / Postman API Night Okinawa 2026 Winter
tasshi
0
200
AgentCoreとHuman in the Loop
har1101
5
240
20260127_試行錯誤の結晶を1冊に。著者が解説 先輩データサイエンティストからの指南書 / author's_commentary_ds_instructions_guide
nash_efp
1
980
MDN Web Docs に日本語翻訳でコントリビュート
ohmori_yusuke
0
650
Amazon Bedrockを活用したRAGの品質管理パイプライン構築
tosuri13
5
760
今こそ知るべき耐量子計算機暗号(PQC)入門 / PQC: What You Need to Know Now
mackey0225
3
380
AI & Enginnering
codelynx
0
110
インターン生でもAuth0で認証基盤刷新が出来るのか
taku271
0
190
AI Agent の開発と運用を支える Durable Execution #AgentsInProd
izumin5210
7
2.3k
OCaml 5でモダンな並列プログラミングを Enjoyしよう!
haochenx
0
140
CSC307 Lecture 08
javiergs
PRO
0
670
Featured
See All Featured
Stop Working from a Prison Cell
hatefulcrawdad
273
21k
Believing is Seeing
oripsolob
1
56
RailsConf 2023
tenderlove
30
1.3k
Building Adaptive Systems
keathley
44
2.9k
ReactJS: Keep Simple. Everything can be a component!
pedronauck
666
130k
Claude Code のすすめ
schroneko
67
210k
Color Theory Basics | Prateek | Gurzu
gurzu
0
200
Evolving SEO for Evolving Search Engines
ryanjones
0
130
The Psychology of Web Performance [Beyond Tellerrand 2023]
tammyeverts
49
3.3k
Site-Speed That Sticks
csswizardry
13
1.1k
Testing 201, or: Great Expectations
jmmastey
46
8k
Performance Is Good for Brains [We Love Speed 2024]
tammyeverts
12
1.4k
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