Code example to go with Den Odell's presentation on High Quality JavaScript Code: https://www.slideshare.net/denodell/highquality-javascript-code
dates.js
- Simple script showing module pattern, dependencies, ECMAScript 5 strict mode, and documentation in YUIDoc formatdates-spec.js
- Simple Jasmine unit tests for testing the methods exposed fromdates.js
GruntFile.js
andpackage.json
- Configure Grunt task runner with JSHint, Jasmine, and Istanbul
- Install Node.js
- Install Grunt-CLI
- Open command prompt/terminal and
cd
to this project folder - Execute
npm install
on the command line to download all the dependencies and plugins for Grunt (first time only) - Execute
grunt
on the command line - this will run JSHint, Jasmine, Istanbul, complexityReport.js and YUIDoc, feeding back results to the command prompt window - Check the generated
reports
folder for the code coverage report generated by Istanbul after running the Jasmine unit tests, and details of any issues running the cyclomatic complexity report - Check the YUIDoc generated HTML documentation extracted from your code by looking in the
docs
folder - If you want to have Grunt running all the time, listening for file changes and auto-running, then execute
grunt watch
at the command line
- Node.js - http://nodejs.org
- Grunt - http://gruntjs.com
- Jasmine - https://jasmine.github.io/
- Istanbul - http://gotwarlost.github.io/istanbul/
- complexityReport.js - https://github.com/philbooth/complexityReport.js