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
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
James Ford
October 02, 2013
Programming
69
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
240
Virtualisation - Vagrant and Docker
psyked
0
120
The Magic of Charts - Data Visualisation in JavaScript
psyked
0
58
Telling Tales & Solving Crimes with New Relic
psyked
0
73
What I learned at the Edge conference 2015
psyked
0
74
Web Fonts FTW
psyked
0
140
Git 101: Force-sensitive to Jedi padawan
psyked
0
130
Responsive Images in 10 minutes
psyked
0
99
Hack to the Future
psyked
0
110
Other Decks in Programming
See All in Programming
例外の正しい扱い方 そのエラー try-catchして大丈夫?
jinwatanabe
0
130
コンテキストの使い捨てをやめる — ビジネスルール駆動開発と miko —
ioki
0
170
ローカルLLMを使ってB2Bサービスを作っていての学び
yaotti
0
150
3Dシーンの圧縮
fadis
1
670
AIエージェントの隔離技術の徹底比較
kawayu
0
470
肥大化するレガシーコードに立ち向かうためのインターフェース分離と依存の逆転 / JJUG CCC 2026 Spring
hirokunimaeta
0
510
代数的データ型って何が嬉しいの? #frontend_phpcon_do
kajitack
8
3.3k
生成AI時代にこそ効くGo | Why Go Works in the Age of Generative AI
mom0tomo
8
3.2k
These Five Tricks Can Make Your Apps Greener, Cheaper, & Nicer
hollycummins
0
280
Spec Driven Development | AI Summit Lisbon
danielsogl
PRO
0
170
フロントエンドとバックエンドで「1文字」を揃えよう
youkidearitai
PRO
0
220
Composerを使ったサプライチェーン攻撃の様子を眺めてみる #phpstudy
o0h
PRO
2
230
Featured
See All Featured
Reflections from 52 weeks, 52 projects
jeffersonlam
356
21k
Put a Button on it: Removing Barriers to Going Fast.
kastner
60
4.3k
Leading Effective Engineering Teams in the AI Era
addyosmani
9
2k
B2B Lead Gen: Tactics, Traps & Triumph
marketingsoph
0
140
HTML-Aware ERB: The Path to Reactive Rendering @ RubyCon 2026, Rimini, Italy
marcoroth
1
160
The Art of Programming - Codeland 2020
erikaheidi
57
14k
Building an army of robots
kneath
306
46k
Building a Scalable Design System with Sketch
lauravandoore
463
34k
[RailsConf 2023 Opening Keynote] The Magic of Rails
eileencodes
31
10k
Odyssey Design
rkendrick25
PRO
2
690
[Rails World 2023 - Day 1 Closing Keynote] - The Magic of Rails
eileencodes
38
2.9k
KATA
mclloyd
PRO
35
15k
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