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
650
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
From Mission to Strategy: going over OKRs and Roadmap
sebarmeli
0
44
Managing a software engineering team
sebarmeli
1
330
Enforcing coding standards in a JS project
sebarmeli
0
430
Enforcing Coding Standards
sebarmeli
1
94
ES6: The future is now
sebarmeli
2
420
EcmaScript 6 - the future is here
sebarmeli
5
6.7k
Dependency management and Package management in JavaScript
sebarmeli
0
520
RequireJS
sebarmeli
5
320
Lazy Load Everything!
sebarmeli
3
280
Other Decks in Programming
See All in Programming
TokyoR#103_DataProcessing
kilometer
0
540
Hasura の Relationship と権限管理
karszawa
0
180
(新米)エンジニアリングマネージャーのしごと #RSGT2023
murabayashi
9
5.9k
23年のJavaトレンドは?Quarkusで理解するコンテナネイティブJava
tatsuya1bm
1
130
良質な技術記事を量産する秘訣 / #MeetsPro
jnchito
16
4.6k
An Advanced Introduction to R
nicetak
0
1.8k
LIFFで動く割り勘アプリTATEKAをリリースしてみた話
inoue2002
0
260
TypeScript 4.9のas const satisfiesが便利
tonkotsuboy_com
9
2.3k
Remote SSHで行うVS Codeリモートホスト開発とトラブルシューティング
smt7174
1
510
Amebaブログの会員画面システム刷新の道程
ryotasugawara
1
250
なぜRubyコミュニティにコミットするのか?
luccafort
0
320
量子コンピュータ時代のプログラミングセミナー / 20221222_Amplify_seminar _route_optimization
fixstars
0
250
Featured
See All Featured
Pencils Down: Stop Designing & Start Developing
hursman
114
10k
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
15
1.2k
Easily Structure & Communicate Ideas using Wireframe
afnizarnur
182
15k
Into the Great Unknown - MozCon
thekraken
2
300
jQuery: Nuts, Bolts and Bling
dougneiner
57
6.6k
Stop Working from a Prison Cell
hatefulcrawdad
263
18k
Visualization
eitanlees
128
12k
It's Worth the Effort
3n
177
26k
For a Future-Friendly Web
brad_frost
166
7.8k
A Modern Web Designer's Workflow
chriscoyier
689
180k
Agile that works and the tools we love
rasmusluckow
320
20k
How To Stay Up To Date on Web Technology
chriscoyier
779
250k
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!