Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Speaker Deck
PRO
Sign in
Sign up for free
Karma - JS Test Runner
Sebastiano Armeli-Battana
August 14, 2013
Programming
1
590
Karma - JS Test Runner
Talk given at MelbJS - August 2013
Sebastiano Armeli-Battana
August 14, 2013
Tweet
Share
More Decks by Sebastiano Armeli-Battana
See All by Sebastiano Armeli-Battana
Managing a software engineering team
sebarmeli
1
270
Enforcing coding standards in a JS project
sebarmeli
0
390
Enforcing Coding Standards
sebarmeli
1
89
ES6: The future is now
sebarmeli
2
410
EcmaScript 6 - the future is here
sebarmeli
5
6.6k
Dependency management and Package management in JavaScript
sebarmeli
0
450
RequireJS
sebarmeli
5
280
Lazy Load Everything!
sebarmeli
3
240
MVC on the server and on the client
sebarmeli
0
51
Other Decks in Programming
See All in Programming
OSS Forward Workshop
giginet
2
480
アプリのログをチーム外で活用してもらうためにやったこと
shotakashihara
0
200
Cloud-Conference-Day-Spring Cloud + Spring Webflux: como desenvolver seu primeiro microsserviço reativo em Java?
kamilahsantos
1
170
roadmap to rust 2024
matsu7874
1
920
Let's build components, not layers
thombergs
1
280
Raspberry Pi Picoデバッガ使用のすすめ
ciniml
0
120
NieR Re[in]carnationにおけるUnityアニメーション活用術
applibot
1
980
[RailsConf 2022] The pitfalls of realtime-ification
palkan
0
380
マイクロインタラクション入門〜ディテイルにこだわるエンジニアリング〜
swimmyxox
0
130
競プロへの誘 -いざな-
u76ner
0
380
カラーミーショップは私たちが作っています
kenchan
0
130
tfcon2022_Web3Dひとめぐり.pdf
emadurandal
0
1.1k
Featured
See All Featured
GitHub's CSS Performance
jonrohan
1020
410k
Side Projects
sachag
449
37k
実際に使うSQLの書き方 徹底解説 / pgcon21j-tutorial
soudai
38
12k
Embracing the Ebb and Flow
colly
73
3.3k
Scaling GitHub
holman
451
140k
Refactoring Trust on Your Teams (GOTO; Chicago 2020)
rmw
19
1.4k
Cheating the UX When There Is Nothing More to Optimize - PixelPioneers
stephaniewalter
268
11k
How New CSS Is Changing Everything About Graphic Design on the Web
jensimmons
212
11k
Building an army of robots
kneath
299
40k
Six Lessons from altMBA
skipperchong
14
1.3k
How To Stay Up To Date on Web Technology
chriscoyier
780
250k
Thoughts on Productivity
jonyablonski
43
2.2k
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!