SlideShare a Scribd company logo
Karma
JS Test Runner
Sebastiano Armeli
@sebarmeli14/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!

More Related Content

PPTX
AngularJS Unit Testing
PDF
Angularjs - Unit testing introduction
PDF
AngularJS Unit Testing w/Karma and Jasmine
PPTX
Unit testing of java script and angularjs application using Karma Jasmine Fra...
PPTX
Unit testing in JavaScript with Jasmine and Karma
PDF
AngularJS Unit Test
PDF
Intro to testing Javascript with jasmine
PPT
Testing in AngularJS
AngularJS Unit Testing
Angularjs - Unit testing introduction
AngularJS Unit Testing w/Karma and Jasmine
Unit testing of java script and angularjs application using Karma Jasmine Fra...
Unit testing in JavaScript with Jasmine and Karma
AngularJS Unit Test
Intro to testing Javascript with jasmine
Testing in AngularJS

What's hot (20)

PDF
JavaScript Test-Driven Development with Jasmine 2.0 and Karma
PDF
Angular testing
PDF
Test-Driven Development of AngularJS Applications
ODP
Unit Testing and Coverage for AngularJS
ODP
Angular JS Unit Testing - Overview
PDF
Intro to Unit Testing in AngularJS
PPTX
Unit testing JavaScript: Jasmine & karma intro
PDF
Quick tour to front end unit testing using jasmine
PDF
JavaScript TDD with Jasmine and Karma
PDF
Advanced Jasmine - Front-End JavaScript Unit Testing
PDF
Jasmine BDD for Javascript
PPTX
Angular Unit Testing
ODP
Jquery- One slide completing all JQuery
PDF
Quick tour to front end unit testing using jasmine
PDF
Painless JavaScript Testing with Jest
PPTX
RSpec and Rails
PPTX
Angular Unit Testing
PPTX
Testing Ansible
PDF
Intro to JavaScript
PDF
Writing Custom Puppet Types and Providers to Manage Web-Based Applications
JavaScript Test-Driven Development with Jasmine 2.0 and Karma
Angular testing
Test-Driven Development of AngularJS Applications
Unit Testing and Coverage for AngularJS
Angular JS Unit Testing - Overview
Intro to Unit Testing in AngularJS
Unit testing JavaScript: Jasmine & karma intro
Quick tour to front end unit testing using jasmine
JavaScript TDD with Jasmine and Karma
Advanced Jasmine - Front-End JavaScript Unit Testing
Jasmine BDD for Javascript
Angular Unit Testing
Jquery- One slide completing all JQuery
Quick tour to front end unit testing using jasmine
Painless JavaScript Testing with Jest
RSpec and Rails
Angular Unit Testing
Testing Ansible
Intro to JavaScript
Writing Custom Puppet Types and Providers to Manage Web-Based Applications
Ad

Similar to Karma - JS Test Runner (20)

PPTX
Cpsc 473 01 lightning talk
PPTX
Decapitating Selenium with JavaScript
PPT
Sauce Labs Beta Program Overview
PPTX
Protractor for angularJS
ODP
RichFaces - Testing on Mobile Devices
KEY
Intro to java
PDF
Mobile Development integration tests
PPTX
Configure jasmine and karma for code coverage
PPTX
Capybara and cucumber with DSL using ruby
KEY
Deploying JRuby Web Applications
PDF
Automate your Kamailio Test Calls - Kamailio World 2024
PDF
JRuby on Rails Deployment: What They Didn't Tell You
KEY
Socket applications
KEY
A rough guide to JavaScript Performance
PDF
Building a platform with Django, Docker and Salt | Djangocon lightning talk
PDF
Building a Platform with Django, Docker and Salt
PDF
Testing Your APIs: Postman, Newman, and Beyond
PDF
Belvedere
PDF
Faster Data Integration Pipeline Execution using Spark-Jobserver
ODP
ATDD with Behat and Selenium (LDNSE6)
Cpsc 473 01 lightning talk
Decapitating Selenium with JavaScript
Sauce Labs Beta Program Overview
Protractor for angularJS
RichFaces - Testing on Mobile Devices
Intro to java
Mobile Development integration tests
Configure jasmine and karma for code coverage
Capybara and cucumber with DSL using ruby
Deploying JRuby Web Applications
Automate your Kamailio Test Calls - Kamailio World 2024
JRuby on Rails Deployment: What They Didn't Tell You
Socket applications
A rough guide to JavaScript Performance
Building a platform with Django, Docker and Salt | Djangocon lightning talk
Building a Platform with Django, Docker and Salt
Testing Your APIs: Postman, Newman, and Beyond
Belvedere
Faster Data Integration Pipeline Execution using Spark-Jobserver
ATDD with Behat and Selenium (LDNSE6)
Ad

More from Sebastiano Armeli (12)

PDF
Managing a software engineering team
PDF
Enforcing coding standards in a JS project
PDF
Enforcing coding standards
PDF
ES6: The future is now
PDF
EcmaScript 6 - The future is here
PDF
Dependency management & Package management in JavaScript
PDF
KEY
Lazy load Everything!
KEY
MVC on the server and on the client
KEY
Backbone.js in a real-life application
KEY
Getting started with Selenium 2
PDF
Web Storage
Managing a software engineering team
Enforcing coding standards in a JS project
Enforcing coding standards
ES6: The future is now
EcmaScript 6 - The future is here
Dependency management & Package management in JavaScript
Lazy load Everything!
MVC on the server and on the client
Backbone.js in a real-life application
Getting started with Selenium 2
Web Storage

Recently uploaded (20)

PDF
Machine learning based COVID-19 study performance prediction
PDF
KodekX | Application Modernization Development
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PPTX
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
PPTX
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
PDF
Encapsulation_ Review paper, used for researhc scholars
PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PDF
Approach and Philosophy of On baking technology
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PDF
NewMind AI Monthly Chronicles - July 2025
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PPTX
PA Analog/Digital System: The Backbone of Modern Surveillance and Communication
PDF
cuic standard and advanced reporting.pdf
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PDF
CIFDAQ's Market Insight: SEC Turns Pro Crypto
PPTX
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
PDF
Modernizing your data center with Dell and AMD
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
Machine learning based COVID-19 study performance prediction
KodekX | Application Modernization Development
Reach Out and Touch Someone: Haptics and Empathic Computing
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
20250228 LYD VKU AI Blended-Learning.pptx
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
Encapsulation_ Review paper, used for researhc scholars
“AI and Expert System Decision Support & Business Intelligence Systems”
Approach and Philosophy of On baking technology
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
NewMind AI Monthly Chronicles - July 2025
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PA Analog/Digital System: The Backbone of Modern Surveillance and Communication
cuic standard and advanced reporting.pdf
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
Digital-Transformation-Roadmap-for-Companies.pptx
CIFDAQ's Market Insight: SEC Turns Pro Crypto
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
Modernizing your data center with Dell and AMD
Diabetes mellitus diagnosis method based random forest with bat algorithm

Karma - JS Test Runner