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
74
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
SREの越境 / SRE Collaboration
y0hgi
2
300
半永久的に提供し続けられるプライベートクラウドを目指して ― 利用者の認知負荷を抑えるAPI抽象化とハードウェア世代交代の基盤設計
tomokon
0
480
動作中のプログラムの中身をリアルタイムに覗く / Realtime Debugger for CSharp with Roslyn
prota
1
1.8k
[ハンズオン]AIへの指示だけで「五目並べ」を作ってみよう
satoshi256kbyte
1
370
【加筆修正版】Laravel のアプリケーションをどこにデプロイするか #phpcon_ehime
akase244
0
150
速く作れる。その次は、速く確かめられる開発へ 〜AIネイティブ開発を支える、Shift Down〜 / Can build fast. Next, moving to development where we can verify fast.
rkaga
8
5.7k
UPDATE をやめる — EF Core でマスタをバージョン管理する
panda728
PRO
0
1.2k
パーソナライズPodcastを作った話
repunit11
0
130
Domain-Driven Transformation
hschwentner
2
2.3k
contenteditable と日本語入力に向き合う
colorful12
0
190
mrbgem 三角測量 開発
ogom
0
230
HTML-in-Canvasで作る未来のWeb UI表現
clockmaker
3
4.2k
Featured
See All Featured
HU Berlin: Industrial-Strength Natural Language Processing with spaCy and Prodigy
inesmontani
PRO
0
740
Test your architecture with Archunit
thirion
2
2.4k
Building the Perfect Custom Keyboard
takai
2
900
ラッコキーワード サービス紹介資料
rakko
1
5.3M
Designing for Timeless Needs
cassininazir
1
520
Become a Pro
speakerdeck
PRO
31
6.3k
Leveraging LLMs for student feedback in introductory data science courses - posit::conf(2025)
minecr
1
430
Bash Introduction
62gerente
615
220k
WENDY [Excerpt]
tessaabrams
14
40k
What’s in a name? Adding method to the madness
productmarketing
PRO
24
4.2k
30 Presentation Tips
portentint
PRO
1
430
Mobile First: as difficult as doing things right
swwweet
225
10k
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