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
Sebastiano Armeli
August 14, 2013
Programming
860
1
Share
Karma - JS Test Runner
Talk given at MelbJS - August 2013
Sebastiano Armeli
August 14, 2013
More Decks by Sebastiano Armeli
See All by Sebastiano Armeli
Cultivate Excellence In Engineering Teams through Continuous Software Engineering
sebarmeli
1
200
From Strategy Definition to Execution with OKRs and Roadmap
sebarmeli
0
200
From Mission to Strategy: going over OKRs and Roadmap
sebarmeli
0
310
Managing a software engineering team
sebarmeli
1
640
Enforcing coding standards in a JS project
sebarmeli
0
610
Enforcing Coding Standards
sebarmeli
1
130
ES6: The future is now
sebarmeli
2
500
EcmaScript 6 - the future is here
sebarmeli
5
7.5k
Dependency management and Package management in JavaScript
sebarmeli
0
770
Other Decks in Programming
See All in Programming
見せてもらおうか、 OpenSearchの性能とやらを!
shunta27
1
170
Symfonyの特性(設計思想)を手軽に活かす特性(trait)
ickx
0
120
仕様漏れ実装漏れをなくすトレーサビリティAI基盤のご紹介
orgachem
PRO
8
4.5k
今こそ押さえておきたい アマゾンウェブサービス(AWS)の データベースの基礎 おもクラ #6版
satoshi256kbyte
1
230
GoのDB アクセスにおける 「型安全」と「柔軟性」の両立 - Bob という選択肢
tak848
0
310
へんな働き方
yusukebe
6
2.9k
「接続」—パフォーマンスチューニングの最後の一手 〜点と点を結ぶ、その一瞬のために〜
kentaroutakeda
5
2.4k
PHP でエミュレータを自作して Ubuntu を動かそう
m3m0r7
PRO
2
170
レガシーPHP転生 〜父がドメインエキスパートだったのでDDD+Claude Codeでチート開発します〜
panda_program
0
230
Coding as Prompting Since 2025
ragingwind
0
680
AIエージェントで業務改善してみた
taku271
0
410
「速くなった気がする」をデータで疑う
senleaf24
0
140
Featured
See All Featured
The AI Search Optimization Roadmap by Aleyda Solis
aleyda
1
5.6k
Mind Mapping
helmedeiros
PRO
1
140
How to train your dragon (web standard)
notwaldorf
97
6.6k
Have SEOs Ruined the Internet? - User Awareness of SEO in 2025
akashhashmi
0
310
My Coaching Mixtape
mlcsv
0
92
JAMstack: Web Apps at Ludicrous Speed - All Things Open 2022
reverentgeek
1
410
Practical Orchestrator
shlominoach
191
11k
AI: The stuff that nobody shows you
jnunemaker
PRO
4
520
Are puppies a ranking factor?
jonoalderson
1
3.2k
How to build an LLM SEO readiness audit: a practical framework
nmsamuel
1
700
A brief & incomplete history of UX Design for the World Wide Web: 1989–2019
jct
1
340
Building an army of robots
kneath
306
46k
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!