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-playgroundNew NPM project
$ npm initaccept 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-devInstall global karma cli so we can type
karmawithout the full path from anywhere.$ npm install -g karma-cliCreate 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.jsStart karma
# Start Karma using your configuration: $ karma start my.conf.jsYou’ll see Chrome or the browsers you chose start
Twitter • Reddit