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
1
760
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
From Strategy Definition to Execution with OKRs and Roadmap
sebarmeli
0
77
From Mission to Strategy: going over OKRs and Roadmap
sebarmeli
0
220
Managing a software engineering team
sebarmeli
1
490
Enforcing coding standards in a JS project
sebarmeli
0
540
Enforcing Coding Standards
sebarmeli
1
100
ES6: The future is now
sebarmeli
2
460
EcmaScript 6 - the future is here
sebarmeli
5
6.9k
Dependency management and Package management in JavaScript
sebarmeli
0
630
RequireJS
sebarmeli
5
420
Other Decks in Programming
See All in Programming
Goのmultiple errorsについて (2024年4月版)
syumai
4
1.1k
大規模Reactアプリのリアーキテクチャ~8万行のTanStack Query移行の軌跡~
kj455
4
1k
MicrosoftのPlatform Engineeringガイドを読んで実際になにかやってみた
ymd65536
1
490
冗長なエラーログを削減し、スタックトレースを手に入れる / Reducing Verbose Error Logs and Obtaining Stack Traces
upamune
0
970
Try creating your own orderedmap
kazamori
1
170
Let's learn code review
riofujimon
2
570
Milestoner
bkuhlmann
1
410
Elm Form Validation
bkuhlmann
0
510
DMMプラットフォームがTiDB Cloudを採用した背景
pospome
9
4.2k
VS Code をプロダクトにどう取り込むか
onomax
1
640
デフォルトにして至高、RubyMineの大好きな所
ruzia
0
660
ServerAction で Progressive Enhancement はどこまで頑張れるか? / progressive-enhancement-with-server-action
takefumiyoshii
6
380
Featured
See All Featured
Intergalactic Javascript Robots from Outer Space
tanoku
266
26k
CoffeeScript is Beautiful & I Never Want to Write Plain JavaScript Again
sstephenson
155
14k
The Mythical Team-Month
searls
216
42k
Statistics for Hackers
jakevdp
790
220k
What's in a price? How to price your products and services
michaelherold
238
11k
Happy Clients
brianwarren
92
6.4k
Making the Leap to Tech Lead
cromwellryan
125
8.5k
YesSQL, Process and Tooling at Scale
rocio
165
13k
Fantastic passwords and where to find them - at NoRuKo
philnash
38
2.5k
The Invisible Customer
myddelton
114
12k
The MySQL Ecosystem @ GitHub 2015
samlambert
244
12k
Documentation Writing (for coders)
carmenintech
61
4k
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!