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
The (quest for the) Holy Grail
Search
James Ford
October 02, 2013
Programming
73
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
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
250
Virtualisation - Vagrant and Docker
psyked
0
130
The Magic of Charts - Data Visualisation in JavaScript
psyked
0
62
Telling Tales & Solving Crimes with New Relic
psyked
0
79
What I learned at the Edge conference 2015
psyked
0
76
Web Fonts FTW
psyked
0
140
Git 101: Force-sensitive to Jedi padawan
psyked
0
140
Responsive Images in 10 minutes
psyked
0
100
Hack to the Future
psyked
0
110
Other Decks in Programming
See All in Programming
「AI時代、配布するPythonコードをどう守るか: 難読化の実験と判断軸」 #PyconJP2026
pkshadeck
PRO
2
190
AIエージェント時代のコードレビューを設計する
nogu66
6
2.6k
RSSとCodexを使ってX投稿自動化してみた
ochtum
0
110
AI に Inclusive UI を書かせよう — Design Rules Skill で Compose UI を作り直す
theoriatec2024
1
470
PHPプロジェクトの結合バランスを可視化する #php_night
kajitack
0
230
XHTMLが残したもの
yosuke_furukawa
PRO
2
680
GKE アップグレード前に知っておきたい Blue/Green と PDB の関係
stkk
0
160
How I Stole PSI from Android Studio - DroidKaigi2026
worker8
0
100
フロントエンドUIフレームワークのこれまでとこれから
ssssota
5
2.3k
自分的「カンファレンスの楽しみ方」
syumai
0
200
Security issues being discussed on Web Platforms
petamoriken
0
650
Seeing Through Serverless: Observability for AWS Lambda with ADOT and CloudWatch Application Signals
seike460
PRO
1
130
Featured
See All Featured
Lightning Talk: Beautiful Slides for Beginners
inesmontani
PRO
2
680
Digital Ethics as a Driver of Design Innovation
axbom
PRO
1
420
Context Engineering - Making Every Token Count
addyosmani
9
1.1k
GraphQLとの向き合い方2022年版
quramy
50
15k
The Cult of Friendly URLs
andyhume
79
7k
Design and Strategy: How to Deal with People Who Don’t "Get" Design
morganepeng
133
19k
The Impact of AI in SEO - AI Overviews June 2024 Edition
aleyda
6
1.2k
How to build a perfect <img>
jonoalderson
1
6k
Why Our Code Smells
bkeepers
PRO
340
58k
Fantastic passwords and where to find them - at NoRuKo
philnash
52
3.8k
The Director’s Chair: Orchestrating AI for Truly Effective Learning
tmiket
1
290
Stop Working from a Prison Cell
hatefulcrawdad
274
21k
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