In Class
we'll do this part together
sudo npm install -g karma
sudo npm install -g karma-jasmine karma-requirejs
sudo npm install -g karma-chrome-launcher karma-phantomjs-launcher
- Clone this repository
- Run
karma init
- Choose "Jasmine"
- Choose yes to use RequireJS
- Choose Chrome
- Locations of the source files:
*
js/vendors/**/*.js
*js/app/**/*.js
*js/tests/**/*Spec.js
- Jasmine should be excluded
js/vendors/jasmine-core
- Choose yes to get a sample config file
- Choose yes to watch all the files
this is something you'll do
- Split your screen so you can see the editor and the console at the same time
- Add a new spec file for the Song model
- Add a test that makes sure the first character is uppercase
- Add that functionality to the Song constructor, just make sure the first character is uppercase
- Watch the magic!
this is something you'll do
- Change the default running browser to PhantomJS
- you'll need to
npm install karma-phantomjs
I'd suggest doing it globally
- Comment out the jasmine exclude and restart karma
- Turn off autowatch
- Restart karma:
karma start
- Open a different terminal window
- Run
karma run
, the tests should have run, and you'll see the results in the other window * We don't always want Karma to control when the tests are run, like next week