Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
Treinamento de testes em JavaScript :: Parte 1
Search
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
Eduardo Matos
August 22, 2019
Technology
270
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Treinamento de testes em JavaScript :: Parte 1
Eduardo Matos
August 22, 2019
Transcript
23 slides
PASS ./treinamento.test.js Parte 1 ✓ Basics (6ms) Encontros: 1 passed,
4 total Realização: Guilda de Front Apoio: Marcelo Fraga Autor: Eduardo Matos Ran all test suites.
O que são testes automatizados?
Sabe quando você... 1. console.log 2. debugger 3. $ myFunction(a
,b) === 7; 4. browser > click > verify
Você está testando, mas você joga fora todos os testes
depois de ver que o código está ok
Como guardar isso tudo então? R: Automatizando essas verificações, isto
é, escrevendo testes automatizados
Qual a vantagem em relação aos testes manuais? 1. Mais
rápidos (centenas* de testes por minuto) 2. Consistentes (não cometem erros) 3. Abrangentes (sempre roda todos os cenários)
Por que testar? 1. Torna software mais soft 2. Evita
bugs 3. Melhora a qualidade do código 4. Documenta o código
O que testar?
Pirâmide de testes
Troféu de testes
TDD Test Driven Development
None
None
[Intencionalmente deixado em branco]
Iremos criar um parser de URL
Cenário 1 Extrair o protocolo. Ex.: http://this.is.my.site.com/spam https://another.web.site.com/baz ftp://file.sharing.site.com/spam
Cenário 2 Extrair hostname. Ex.: http://localhost http://localhost/ http://site.com/ http://www.stuff.com/spam https://really.long.hostname.dot.com/spam
Cenário 3 Extrair path. Ex.: http://spam/foo http://site.com/foo/ http://site.com/foo/bar https://poxa.vida/hein/wow/
Cenário 4 Extrair querystring. Ex.: http://localhost ({}) http://localhost?foo ({ foo:
“” }) http://site.com/?foo=bar ({ foo: “bar” }) http://www.stuff.com/spam?foo=1&bar=2 ({ foo: “1”, bar: “2” }) https://dot.com/?yay=a&yay=b ({ yay: [“a”, “b”] }) https://que.bo?name=Jo%C3%A3o ({ name: “João”}) https://sai.te?caf%C3%A9=please ({ café: “please”})
Cenário 5 Extrair hash. Ex.: http://localhost (“”) http://localhost#yay http://site.com/#/some/hash http://que.ro?#caf%C3%A9%C3%A9
Cenário 6 Extrair porta. Ex.: http://localhost (80) http://localhost:3000
Cenário 7 Extrair autenticação. Ex.: http://localhost ({user: “”, pass: “”
}) http://user:pass@localhost http://z%C3%A9:man%C3%A9@localhost ({user: “zé”, pass: “mané” })
Cenário 8 Juntando tudo. Ex.: sftp://poxa:
[email protected]
:3000/yay/wow/?spam=egg&spam=r%C3%A3&pat%C3%AA=cream#something
More Decks by Eduardo Matos
See All by Eduardo Matos
Innovation and Leadership: Two sides of the same coin
eduardomatos
0
72
Como se tornar o líder que sua equipe precisa e merece
eduardomatos
0
37
Oito Habilidades do(a) dev indispensável
eduardomatos
2
110
Retrospectivas Eficazes
eduardomatos
0
35
Treinamento de testes em JavaScript :: Parte 4
eduardomatos
2
47
Treinamento de testes em JavaScript :: Parte 3
eduardomatos
0
42
Treinamento de testes em JavaScript :: Parte 2
eduardomatos
0
37
Introdução Ao Kubernetes Para Devs
eduardomatos
0
40
10 Formas De Voltar No Tempo Sem Quebrar As Leis Da Física
eduardomatos
0
58
Other Decks in Technology
See All in Technology
IVRy における AI 時代のデータプロダクトと事業開発
ivry_presentationmaterials
0
100
2026-11-16 JAWS-UG コンテナ支部 #31 ゆるLT大会 ECR のライフサイクルポリシーを いい感じに設定したい / ECR Lifecycle policy
masasuzu
3
620
フロントエンドのテストカバレッジは 100%強制がいい
bengo4com
5
1.7k
AWS Client VPNの設定でハマったポイントとその過程での気づき
amarelo_n24
1
440
OCI Artifact による自動運転タクシーに向けた OTA 基盤の構築
biwashi
1
300
個人ASを取得して、自宅Kubernetes上のVMをグローバルIPで公開した話
munenick
0
230
Terraform 0 to 100:100個以上のリポジトリを常に最新にし続けるための自動化
sue445
3
1.4k
OpenTelemetryで変わった 新時代のCloudWatchメトリクス監視
tsukuboshi
0
500
メルカリの小規模チーム「Pod」で、 エンジニアがデータアナリストなしで、 AIを使ってデータ分析の自走を目指す取り組み
jackojacko_
1
350
AI-Ready なデータ基盤ってなに? & 新卒未経験が、いま考えていること
imuta
0
1.1k
プラガブルで宣言的なソフトウェアファクトリーを支えるTypeScript
timakin
2
570
おうち環境でも「なるべく止めたくない!」 ― おうち環境の機器冗長化の理想と現実
yuutosi
1
700
Featured
See All Featured
How to Build an AI Search Optimization Roadmap - Criteria and Steps to Take #SEOIRL
aleyda
1
2.3k
Accessibility Awareness
sabderemane
1
310
The Art of Delivering Value - GDevCon NA Keynote
reverentgeek
16
2.2k
Jamie Indigo - Trashchat’s Guide to Black Boxes: Technical SEO Tactics for LLMs
techseoconnect
PRO
0
760
The Curious Case for Waylosing
cassininazir
1
630
Site-Speed That Sticks
csswizardry
13
1.6k
Utilizing Notion as your number one productivity tool
mfonobong
4
650
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
31
3k
Automating Front-end Workflow
addyosmani
1370
210k
The Power of CSS Pseudo Elements
geoffreycrofte
82
6.7k
It's Worth the Effort
3n
188
29k
Understanding Cognitive Biases in Performance Measurement
bluesmoon
32
3.1k