Isit322 Week06

Elvenware Logo




Add Chai to Karma

In bower.json, add chai, probably by typing bower install chai --save-dev. I'm include angular mocks and scenario for context, but you only need to add chai:

"devDependencies": {  
  "angular-mocks": "~1.3.0",  
  "angular-scenario": "~1.3.0",  
  "chai": "~1.10.0"  

In karma.conf.js add chai. I'm including jquery only for context. It is not needed for chaI:

files: [  

And in your test:

describe('Controller: StatePop', function () {  

  var expect = chai.expect;

Spec Reporter

This is the tool that gives us fancy output when we run our tests. Like having the browser, but at the command line.

To get started:

npm install karma-spec-reporter --save-dev

In karma.conf.js add a reporters property. I include exclude and port for context and to help you find where to insert it. (Of course, within reason, it doesn't really matter where you put it, but for consistency then):

exclude: [],  

reporters: ['spec'],  

// web server port  
port: 8080,

We need to reference it also in the plugins section near the bottom of karma.conf.js. I've included phantomjs, chrome and jasmine for context, but all you should have to add is karma-spec-reporter:

plugins: [