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
39
0
Share
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
54
Tech Track - Angular 2 (Part 3)
chrisgfortes
0
33
Tech Track - Angular 2 (Part 1)
chrisgfortes
0
54
Uma breve introdução sobre AngularJS 1.x
chrisgfortes
0
28
Other Decks in Programming
See All in Programming
Swiftのレキシカルスコープ管理
kntkymt
0
210
気づいたらRubyで100作品 ー クリエイティブコーディングが生活の一部になるまで / 100 Ruby Sketches Later: How Creative Coding Became Part of My Life
chobishiba
3
530
RTSPクライアントを自作してみた話
simotin13
0
420
Technical Debt: Understanding it Rightly, Engaging it Rightly #LaravelLiveJP
shogogg
0
190
軽量Java基盤の設計 DIコンテナに頼らない、長期保守と1秒起動の実現 JJUG CCC 2026 Spring
macha64
0
400
Composerを使ったサプライチェーン攻撃の様子を眺めてみる #phpstudy
o0h
PRO
2
210
PHPで使える日時の表現と、その知り方 #frontend_phpcon_do
o0h
PRO
0
180
次世代リンターで探る、tsgo 時代における型認識カスタムルールの現実解
ytakahashii
3
1.4k
CLIであることを活かしたGitHub Copilot CLI活用術 / GitHub Copilot CLI Pro Tips & Tricks
nao_mk2
1
1.2k
初めてのRubyKaigiはこう見えた
jellyfish700
0
400
JJUG CCC 2026 Spring: JSpecify で実現する Kotlin フレンドリーな Java API 設計
ternbusty
1
130
Make SRE Operations Easier with Azure SRE Agent
kkamegawa
0
3k
Featured
See All Featured
Sam Torres - BigQuery for SEOs
techseoconnect
PRO
0
280
Optimising Largest Contentful Paint
csswizardry
37
3.7k
Why Our Code Smells
bkeepers
PRO
340
58k
Everyday Curiosity
cassininazir
0
220
Balancing Empowerment & Direction
lara
6
1.1k
Beyond borders and beyond the search box: How to win the global "messy middle" with AI-driven SEO
davidcarrasco
3
150
Scaling GitHub
holman
464
140k
Conquering PDFs: document understanding beyond plain text
inesmontani
PRO
4
2.8k
ラッコキーワード サービス紹介資料
rakko
1
3.5M
Unlocking the hidden potential of vector embeddings in international SEO
frankvandijk
0
830
Are puppies a ranking factor?
jonoalderson
1
3.5k
Rebuilding a faster, lazier Slack
samanthasiow
85
9.5k
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