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
The (quest for the) Holy Grail
Search
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
James Ford
October 02, 2013
Programming
67
0
Share
The (quest for the) Holy Grail
Cross-browser JavaScript Unit Testing with Code Coverage Metrics
James Ford
October 02, 2013
More Decks by James Ford
See All by James Ford
ES6; // WTF?
psyked
0
230
Virtualisation - Vagrant and Docker
psyked
0
120
The Magic of Charts - Data Visualisation in JavaScript
psyked
0
54
Telling Tales & Solving Crimes with New Relic
psyked
0
71
What I learned at the Edge conference 2015
psyked
0
64
Web Fonts FTW
psyked
0
140
Git 101: Force-sensitive to Jedi padawan
psyked
0
120
Responsive Images in 10 minutes
psyked
0
98
Hack to the Future
psyked
0
98
Other Decks in Programming
See All in Programming
10年分の技術的負債、完済へ ― Claude Code主導のAI駆動開発でスポーツブルを丸ごとリプレイスした話
takuya_houshima
0
2.5k
CursorとClaudeCodeとCodexとOpenCodeを実際に比較してみた
terisuke
1
440
PCOVから学ぶコードカバレッジ #phpcon_odawara
o0h
PRO
0
260
Vibe하게 만드는 Flutter GenUI App With ADK , 박제창, BWAI Incheon 2026
itsmedreamwalker
0
550
YJITとZJITにはイカなる違いがあるのか?
nakiym
0
210
SkillがSkillを生む:QA観点出しを自動化した
sontixyou
6
3.3k
UIの境界線をデザインする | React Tokyo #15 メイントーク
sasagar
2
290
AI時代の脳疲弊と向き合う ~言語学としてのPHP~
sakuraikotone
1
1.9k
AIエージェントで業務改善してみた
taku271
0
520
의존성 주입과 모듈화
fornewid
0
130
「接続」—パフォーマンスチューニングの最後の一手 〜点と点を結ぶ、その一瞬のために〜
kentaroutakeda
5
2.5k
RSAが破られる前に知っておきたい 耐量子計算機暗号(PQC)入門 / Intro to PQC: Preparing for the Post-RSA Era
mackey0225
3
130
Featured
See All Featured
BBQ
matthewcrist
89
10k
Bioeconomy Workshop: Dr. Julius Ecuru, Opportunities for a Bioeconomy in West Africa
akademiya2063
PRO
1
93
Producing Creativity
orderedlist
PRO
348
40k
Jess Joyce - The Pitfalls of Following Frameworks
techseoconnect
PRO
1
130
Kristin Tynski - Automating Marketing Tasks With AI
techseoconnect
PRO
0
220
We Are The Robots
honzajavorek
0
210
Building Applications with DynamoDB
mza
96
7k
Mozcon NYC 2025: Stop Losing SEO Traffic
samtorres
0
200
I Don’t Have Time: Getting Over the Fear to Launch Your Podcast
jcasabona
34
2.7k
It's Worth the Effort
3n
188
29k
The MySQL Ecosystem @ GitHub 2015
samlambert
251
13k
Imperfection Machines: The Place of Print at Facebook
scottboms
270
14k
Transcript
None
None
None
None
Documents & Defines the expected input and output of your
code Makes it Easier to Refactor. Helps you write Better, re-usable code. Enables Automated testing.
Unit Testing requires you change the way you write your
code. (But this is good);
JavaScript is interpreted at runtime. Across a variety of different
browsers. Mutable , Loosely-typed ,, Global scope. SUDDEN DEATH Mode
Tests should:: • Run in a real browser environment •
Run in any & all browsers • Integrate with our CI setup • Output code coverage metrics • Easy to write • Be reliable, execute fast
None
http://karma-runner.github.io/.
http://pivotal.github.io/jasmine/.
1. Karma runs a server 2. Real-world browsers connect 3.
Karma serves your tests 4. Browsers execute tests 5. Karma collates the output
> karma init karma.config.js > karma start
• Tests written in JavaScript • BDD syntax • Anything
you can do with JavaScript, you can test with JavaScript
describe("A suite", function() { it("contains spec with an expectation", function()
{ expect(true).toBe(true); expect(true).not.toBe(false); }); });
• describe(name, function) • it(name, function) • beforeEach(function) / afterEach(function)
• expect(condition).toBe(value); • expect(condition).not.toBe(value); • .toEqual() / .toBeTruthy() / .toBeFalsy() • waitsFor(function) / runs(function) Writing tests in Jasmine
it('checks that the Quicknav control navigates to a page', function()
{ loadFixtures('simple-fixture.html'); var activeTextInstance = new ActiveText(...); waitsFor(function() { return activeTextInstance.ready; }, 500); runs(function() { var element = $('.quicknav input'); element.focus(); element.val("5"); var e = jQuery.Event("keydown"); e.which = ActiveText.Keymap.ENTER; $(element).trigger(e); e = jQuery.Event("keyup"); e.which = ActiveText.Keymap.ENTER; $(element).trigger(e); expect(element.val()).toBe("Pages 4–5 of 26"); expect(activeTextInstance.model.getCurrentIndex()).toBe(3); expect(activeTextInstance.model.getCurrentPageNumber()).toBe(4); }); });
Console Output;
CI Integration;
LCOV Output;
None