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
850
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
Cultivate Excellence In Engineering Teams through Continuous Software Engineering
sebarmeli
1
170
From Strategy Definition to Execution with OKRs and Roadmap
sebarmeli
0
170
From Mission to Strategy: going over OKRs and Roadmap
sebarmeli
0
290
Managing a software engineering team
sebarmeli
1
610
Enforcing coding standards in a JS project
sebarmeli
0
590
Enforcing Coding Standards
sebarmeli
1
120
ES6: The future is now
sebarmeli
2
490
EcmaScript 6 - the future is here
sebarmeli
5
7.3k
Dependency management and Package management in JavaScript
sebarmeli
0
750
Other Decks in Programming
See All in Programming
Duke on CRaC with Jakarta EE
ivargrimstad
0
170
30分でDoctrineの仕組みと使い方を完全にマスターする / phpconkagawa 2025 Doctrine
ttskch
2
220
歴史から学ぶ「Why PHP?」 PHPを書く理由を改めて理解する / Learning from History: “Why PHP?” Rediscovering the Reasons for Writing PHP
seike460
PRO
0
160
AIの弱点、やっぱりプログラミングは人間が(も)勉強しよう / YAPC AI and Programming
kishida
10
5.2k
関数の挙動書き換える
takatofukui
4
750
Nitro v3
kazupon
2
320
Micro Frontendsで築いた 共通基盤と運用の試行錯誤 / Building a Shared Platform with Micro Frontends: Operational Learnings
kyntk
0
110
Microservices Platforms: When Team Topologies Meets Microservices Patterns
cer
PRO
0
220
競馬で学ぶ機械学習の基本と実践 / Machine Learning with Horse Racing
shoheimitani
14
13k
Promise.tryで実現する新しいエラーハンドリング New error handling with Promise try
bicstone
3
960
GeistFabrik and AI-augmented software development
adewale
PRO
0
130
JEP 496 と JEP 497 から学ぶ耐量子計算機暗号入門 / Learning Post-Quantum Crypto Basics from JEP 496 & 497
mackey0225
2
460
Featured
See All Featured
Helping Users Find Their Own Way: Creating Modern Search Experiences
danielanewman
31
3k
GraphQLの誤解/rethinking-graphql
sonatard
73
11k
Evolution of real-time – Irina Nazarova, EuRuKo, 2024
irinanazarova
9
1k
10 Git Anti Patterns You Should be Aware of
lemiorhan
PRO
659
61k
Become a Pro
speakerdeck
PRO
29
5.6k
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
31
2.6k
Fireside Chat
paigeccino
41
3.7k
Embracing the Ebb and Flow
colly
88
4.9k
How Fast Is Fast Enough? [PerfNow 2025]
tammyeverts
3
340
Building a Modern Day E-commerce SEO Strategy
aleyda
45
8.1k
Measuring & Analyzing Core Web Vitals
bluesmoon
9
680
Learning to Love Humans: Emotional Interface Design
aarron
274
41k
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!