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
Signal Forms: Beyond the Basics @ngBaguette 2026 in Paris
manfredsteyer
PRO
0
210
運用エージェントは "作る" から "育てる" へ - 記憶と自己進化の3層設計パターン / self-evolving-agents-three-layer-agent-design
gawa
12
3.4k
Oxcを導入して開発体験が向上した話
yug1224
4
270
関係性から理解する"同一性"の型用語たち
pvcresin
2
630
Spec Driven Development | AI Summit Lisbon
danielsogl
PRO
0
120
New "Type" system on PicoRuby
pocke
1
420
ふつうのFeature Flag実践入門
irof
7
3.5k
ビジネスモデルから紐解く、AI+型駆動開発
hirokiomote
2
5.2k
Transactional Change Stream Processing With Debezium and Apache Flink
gunnarmorling
1
150
AI時代のUIはどこへ行く?その2!
yusukebe
19
6.3k
The Arts and Crafts of Work in the AI Era — Toward Mastery in Software Development
kuranuki
1
700
AIチームを指揮するOSS「TAKT」活用術 / How to Use “TAKT,” an OSS Tool for Orchestrating AI Teams
nrslib
6
780
Featured
See All Featured
AI: The stuff that nobody shows you
jnunemaker
PRO
7
680
Designing Dashboards & Data Visualisations in Web Apps
destraynor
231
55k
Let's Do A Bunch of Simple Stuff to Make Websites Faster
chriscoyier
508
140k
Self-Hosted WebAssembly Runtime for Runtime-Neutral Checkpoint/Restore in Edge–Cloud Continuum
chikuwait
0
560
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
234
17k
How STYLIGHT went responsive
nonsquared
100
6.2k
Building an army of robots
kneath
306
46k
ピンチをチャンスに:未来をつくるプロダクトロードマップ #pmconf2020
aki_iinuma
128
55k
A better future with KSS
kneath
240
18k
What does AI have to do with Human Rights?
axbom
PRO
1
2.2k
The Power of CSS Pseudo Elements
geoffreycrofte
82
6.3k
The World Runs on Bad Software
bkeepers
PRO
72
12k
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