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
Karma - JS Test Runner
Search
Sponsored
·
SiteGround - Reliable hosting with speed, security, and support you can count on.
→
Sebastiano Armeli
August 14, 2013
Programming
1
860
Karma - JS Test Runner
Talk given at MelbJS - August 2013
Sebastiano Armeli
August 14, 2013
Tweet
Share
More Decks by Sebastiano Armeli
See All by Sebastiano Armeli
Cultivate Excellence In Engineering Teams through Continuous Software Engineering
sebarmeli
1
190
From Strategy Definition to Execution with OKRs and Roadmap
sebarmeli
0
180
From Mission to Strategy: going over OKRs and Roadmap
sebarmeli
0
300
Managing a software engineering team
sebarmeli
1
620
Enforcing coding standards in a JS project
sebarmeli
0
600
Enforcing Coding Standards
sebarmeli
1
120
ES6: The future is now
sebarmeli
2
500
EcmaScript 6 - the future is here
sebarmeli
5
7.4k
Dependency management and Package management in JavaScript
sebarmeli
0
760
Other Decks in Programming
See All in Programming
今こそ知るべき耐量子計算機暗号(PQC)入門 / PQC: What You Need to Know Now
mackey0225
3
370
AI Schema Enrichment for your Oracle AI Database
thatjeffsmith
0
260
ThorVG Viewer In VS Code
nors
0
770
AI前提で考えるiOSアプリのモダナイズ設計
yuukiw00w
0
220
AIフル活用時代だからこそ学んでおきたい働き方の心得
shinoyu
0
130
AI時代の認知負荷との向き合い方
optfit
0
150
Patterns of Patterns
denyspoltorak
0
1.4k
例外処理とどう使い分ける?Result型を使ったエラー設計 #burikaigi
kajitack
16
6k
CSC307 Lecture 09
javiergs
PRO
1
830
CSC307 Lecture 06
javiergs
PRO
0
680
360° Signals in Angular: Signal Forms with SignalStore & Resources @ngLondon 01/2026
manfredsteyer
PRO
0
120
CSC307 Lecture 02
javiergs
PRO
1
770
Featured
See All Featured
Digital Ethics as a Driver of Design Innovation
axbom
PRO
1
170
Principles of Awesome APIs and How to Build Them.
keavy
128
17k
Exploring the Power of Turbo Streams & Action Cable | RailsConf2023
kevinliebholz
37
6.3k
Performance Is Good for Brains [We Love Speed 2024]
tammyeverts
12
1.4k
Amusing Abliteration
ianozsvald
0
97
We Are The Robots
honzajavorek
0
160
Information Architects: The Missing Link in Design Systems
soysaucechin
0
770
How to Think Like a Performance Engineer
csswizardry
28
2.4k
Practical Orchestrator
shlominoach
191
11k
Distributed Sagas: A Protocol for Coordinating Microservices
caitiem20
333
22k
[RailsConf 2023 Opening Keynote] The Magic of Rails
eileencodes
31
9.9k
SERP Conf. Vienna - Web Accessibility: Optimizing for Inclusivity and SEO
sarafernandez
1
1.3k
Transcript
Karma JS Test Runner Sebastiano Armeli @sebarmeli 14/8/2013 - MelbJS
Karma JS Test Runner Sebastiano Armeli @sebarmeli
Karma JS Test Runner Sebastiano Armeli @sebarmeli
Test Framework How you write your tests
Test Environment Where you execute your tests
Test Runner How you run your test
What do we need from a Test Runner?
it (‘should be fast’)
it (‘should use real browsers’)
it (‘should be reliable’)
it (‘should be reliable’)
Karma
Client socket.io Client Client socket.io socket.io watcher reporter manager web
server preprocessor Server
Client socket.io Client Client socket.io socket.io watcher reporter manager web
server http http http preprocessor Server
Domain Specific Language (DSL) for defining tests npm install -g
karma // Ready to use
Domain Specific Language (DSL) for defining tests npm install -g
karma karma init // Create config file
Domain Specific Language (DSL) for defining tests npm install -g
karma karma init karma start // Karma starts listening
Domain Specific Language (DSL) for defining tests npm install -g
karma karma init karma start karma run // Karma runs the tests
module.exports = function(config) { config.set({ basePath: './../..', frameworks: ['jasmine', ‘requirejs’],
files: [ ‘spec/javascripts/test-main.js’, {pattern: 'spec/javascripts/fixtures/**/*.html', watched: false}, {pattern: 'app/assets/javascripts/**/*.js'}, {pattern: 'spec/javascripts/**/*.js'} ], port: 9876, //default browsers: ['Chrome’, ‘ChromeCanary’], singleRun: false, autoWatch: true }); }
Plugins Browser Launchers Test Framework Reporters Preprocessors
karma-!refox-launcher karma-safari-launcher karma-opera-launcher karma-ie-launcher
Plugins Browser Launchers Test Framework Reporters Preprocessors
karma-jasmine karma-mocha karma-qunit karma-requirejs
Plugins Browser Launchers Test Framework Reporters Preprocessors
karma-junit-reporter karma-coverage reporters: [‘junit’], junitReporter : { outputFile: 'test-reports.xml', suite:
'My Suite' } reporters: [‘coverage’], coverageReporter: { type : 'html', dir : 'coverage/' }
Plugins Browser Launchers Test Framework Reporters Preprocessors
karma-coverage preprocessors: { './app/assets/javascripts/**/*.js': 'coverage' } preprocessors: { '**/*.handlebars': 'ember'
} karma-ember-preprocessor
Running just one spec?
Running just one spec? iit(“should do something”, function(){}); ddescribe(“component”, function(){});
Debug http://localhost:9876/debug.html
Grunt-Karma karma: { ci: { configFile: 'karma.conf.js', singleRun: true, browsers:
['PhantomJS'] } }
Running on CI?
Running on CI? karma start --singleRun=true --browsers PhantomJS --reporters junit
Karma!