code for article pfeilbr/karma-playground
Project to learn and experiment with the Karma javascript test runner. Karma runs your javascript tests in multiple browsers.
Quickstart Tutorial
Change to project directory
$ cd ~/projects/karma-playground
New NPM project
$ npm init
accept all defaults
Install karma
# Install Karma: $ npm install karma --save-dev # Install plugins that your project needs: $ npm install karma-jasmine karma-chrome-launcher --save-dev
Install global karma cli so we can type
karma
without the full path from anywhere.$ npm install -g karma-cli
Create sample test.
Using Jasmine for our example.
$ mkdir test $ touch test/sample1.js
// test/sample1.js describe("A suite", function() { it("contains spec with an expectation", function() { expect(true).toBe(true); }); });
Generate the karma configuration file
$ karma init my.conf.js
Start karma
# Start Karma using your configuration: $ karma start my.conf.js
You’ll see Chrome or the browsers you chose start
Twitter • Reddit