/spa-course

Primary LanguageJavaScript

Notes during course

Course site: http://http://acorp.oortcode.com

Download the start.zip from the course site and unzip it.

Add missing js/vendor/ and (minified) require.js library.

NPM

Add 'node_modules/' to your (global) git ignore patterns.

RequireJS

JSHint and Grunt

Install NPM modules for JSHint and Grunt

  • using '-g' for global to put the executables on the PATH.
sudo npm install jshint -g
sudo npm install grunt -g
sudo npm install grunt-cli -g

sudo necessary on Mac's, mostly...

Create a Gruntfile.js

Also, install grunt locally for use in your current project:

npm install grunt

Testing

"use script";

Enforce ES6: As we control browser versions and fairly greenfield, we can probably put at the top of every file, but do per module too / instead...

Install karma:

sudo npm install karma -g

Use Karma's init to create the karma.conf.js config file: karma init

Choices: Jasmine PhantomJS js//*.js test//*Spec.js test-main.js

Then, review start/karma.conf.js because you probably made a mistake... Note the 'reporters' section: has code coverage options etc.

(The karma.conf.js looks very like a Gruntfile.js config file...)

Note that karma has relatively expensive startup costs => use karma's autowatch to avoid spin-up/down costs. But might be ok with high-spec dev machines, more of a laptop pain.

sudo karma start if trying to start headless PhantomJS. Possibly.

Can use karma start if you alter karma.conf.js to use Chrome rather than Phantom (e.g. to debug).

Ignore:

ERROR: 'There is no timestamp for base/js/lib/route.js!'

HTML Partials

Promises for JS: https://github.com/kriskowal/q RequireJS compatible version: https://raw.github.com/kriskowal/q/v0.9/q.js