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
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
Sebastiano Armeli
August 14, 2013
Programming
880
1
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
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
220
From Strategy Definition to Execution with OKRs and Roadmap
sebarmeli
0
230
From Mission to Strategy: going over OKRs and Roadmap
sebarmeli
0
320
Managing a software engineering team
sebarmeli
1
660
Enforcing coding standards in a JS project
sebarmeli
0
620
Enforcing Coding Standards
sebarmeli
1
140
ES6: The future is now
sebarmeli
2
520
EcmaScript 6 - the future is here
sebarmeli
5
7.6k
Dependency management and Package management in JavaScript
sebarmeli
0
790
Other Decks in Programming
See All in Programming
技術的負債解消で開発者の未来を開く- AIの力でコード刷新
kmd2kmd
0
110
Creating Composable Callables in Contemporary C++
rollbear
0
150
Observability in Practice:Grafana 與 Edge Device SRE 的那些事
blueswen
0
170
コンテキストの使い捨てをやめる — ビジネスルール駆動開発と miko —
ioki
0
210
Spring Security 実践 ─ GraphQL APIで実務に役立つ 認証・認可 を学ぶ
wagyu
0
250
肥大化するレガシーコードに立ち向かうためのインターフェース分離と依存の逆転 / JJUG CCC 2026 Spring
hirokunimaeta
0
580
Contextとはなにか
chiroruxx
1
340
正しくソフトウェアを作る、前提を疑うための認知の視点 / doubt-premise
minodriven
21
6.8k
New "Type" system on PicoRuby
pocke
1
980
C# and C++ Interoperability - cho-dotnetnew
harukasao
0
290
Dataformのリポジトリを立ち上げるときにまずやること / dataform-day0-2026
snhryt
0
170
技術記事、 専門家としてのプログラマ、 言語化
mizchi
13
6.3k
Featured
See All Featured
A Modern Web Designer's Workflow
chriscoyier
698
190k
The Success of Rails: Ensuring Growth for the Next 100 Years
eileencodes
47
8.2k
4 Signs Your Business is Dying
shpigford
187
22k
Code Reviewing Like a Champion
maltzj
528
40k
Writing Fast Ruby
sferik
630
63k
[RailsConf 2023] Rails as a piece of cake
palkan
59
6.7k
Designing Experiences People Love
moore
143
24k
Intergalactic Javascript Robots from Outer Space
tanoku
273
27k
Dominate Local Search Results - an insider guide to GBP, reviews, and Local SEO
greggifford
PRO
0
200
Visual Storytelling: How to be a Superhuman Communicator
reverentgeek
2
560
SEOcharity - Dark patterns in SEO and UX: How to avoid them and build a more ethical web
sarafernandez
0
210
Neural Spatial Audio Processing for Sound Field Analysis and Control
skoyamalab
0
340
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!