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
34
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
49
Tech Track - Angular 2 (Part 3)
chrisgfortes
0
29
Tech Track - Angular 2 (Part 1)
chrisgfortes
0
50
Uma breve introdução sobre AngularJS 1.x
chrisgfortes
0
26
Other Decks in Programming
See All in Programming
為你自己學 Python - 冷知識篇
eddie
1
350
はじめてのMaterial3 Expressive
ym223
2
900
Performance for Conversion! 分散トレーシングでボトルネックを 特定せよ
inetand
0
2.4k
そのAPI、誰のため? Androidライブラリ設計における利用者目線の実践テクニック
mkeeda
2
1.8k
go test -json そして testing.T.Attr / Kyoto.go #63
utgwkk
3
310
Navigating Dependency Injection with Metro
zacsweers
3
2.5k
Deep Dive into Kotlin Flow
jmatsu
1
370
「手軽で便利」に潜む罠。 Popover API を WCAG 2.2の視点で安全に使うには
taitotnk
0
870
Processing Gem ベースの、2D レトロゲームエンジンの開発
tokujiros
2
130
さようなら Date。 ようこそTemporal! 3年間先行利用して得られた知見の共有
8beeeaaat
3
1.5k
Testing Trophyは叫ばない
toms74209200
0
890
Amazon RDS 向けに提供されている MCP Server と仕組みを調べてみた/jawsug-okayama-2025-aurora-mcp
takahashiikki
1
120
Featured
See All Featured
Context Engineering - Making Every Token Count
addyosmani
3
59
Measuring & Analyzing Core Web Vitals
bluesmoon
9
580
個人開発の失敗を避けるイケてる考え方 / tips for indie hackers
panda_program
113
20k
Why Our Code Smells
bkeepers
PRO
339
57k
The Web Performance Landscape in 2024 [PerfNow 2024]
tammyeverts
9
810
Responsive Adventures: Dirty Tricks From The Dark Corners of Front-End
smashingmag
252
21k
Thoughts on Productivity
jonyablonski
70
4.8k
How GitHub (no longer) Works
holman
315
140k
Balancing Empowerment & Direction
lara
3
620
Building Applications with DynamoDB
mza
96
6.6k
Product Roadmaps are Hard
iamctodd
PRO
54
11k
YesSQL, Process and Tooling at Scale
rocio
173
14k
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