quality assurance for javascript
TRANSCRIPT
![Page 2: Quality assurance for javascript](https://reader031.vdocuments.net/reader031/viewer/2022013121/554c0ea7b4c905ec518b46da/html5/thumbnails/2.jpg)
Outline
Server Side Javascript Environment Preparation Static Check & Unit Test
![Page 3: Quality assurance for javascript](https://reader031.vdocuments.net/reader031/viewer/2022013121/554c0ea7b4c905ec518b46da/html5/thumbnails/3.jpg)
NodeJs
Javascript is a frontend programming language, but things have changed...
![Page 4: Quality assurance for javascript](https://reader031.vdocuments.net/reader031/viewer/2022013121/554c0ea7b4c905ec518b46da/html5/thumbnails/4.jpg)
Server Side Javascript
Server Side Javascript needs: Package management and Modular Task Management Tools, like maven in java; Quality Assurance Utilities
− Static Check − Unit Test
![Page 5: Quality assurance for javascript](https://reader031.vdocuments.net/reader031/viewer/2022013121/554c0ea7b4c905ec518b46da/html5/thumbnails/5.jpg)
Writing Modular JavaScript
Modularity AMD: Asynchronous Module Definition
define(
module_id /*optional*/,
[dependencies] /*optional*/,
definition function /*function for instantiating the module or object*/
);
![Page 6: Quality assurance for javascript](https://reader031.vdocuments.net/reader031/viewer/2022013121/554c0ea7b4c905ec518b46da/html5/thumbnails/6.jpg)
Package Management
NPM is short for Node Packaged Modules.
![Page 7: Quality assurance for javascript](https://reader031.vdocuments.net/reader031/viewer/2022013121/554c0ea7b4c905ec518b46da/html5/thumbnails/7.jpg)
Grunt.js
Why a build tool is needed for CI ? Why Grunt.js
![Page 8: Quality assurance for javascript](https://reader031.vdocuments.net/reader031/viewer/2022013121/554c0ea7b4c905ec518b46da/html5/thumbnails/8.jpg)
Basic Grunt.js tasks
init Generate project scaffolding from a predefined template
lint validate files with jshint
min minify files with UglifyJS
server Start a static node web server
test Run unit tests with nodeunit. (Jasmine support)
![Page 9: Quality assurance for javascript](https://reader031.vdocuments.net/reader031/viewer/2022013121/554c0ea7b4c905ec518b46da/html5/thumbnails/9.jpg)
Outline
Server Side Javascript Environment Preparation Static Check & Unit Test
![Page 10: Quality assurance for javascript](https://reader031.vdocuments.net/reader031/viewer/2022013121/554c0ea7b4c905ec518b46da/html5/thumbnails/10.jpg)
Install NodeJs
Install via source code Download from
nodejs.org/download ./configure & make & make install
Install via package manager su -c 'yum install npm'
Dependencies V8 Javascript Engine
![Page 11: Quality assurance for javascript](https://reader031.vdocuments.net/reader031/viewer/2022013121/554c0ea7b4c905ec518b46da/html5/thumbnails/11.jpg)
Install Related Modules
npm install -g grunt-cli npm install -g grunt-contrib-jshint npm install -g grunt-mocha-
phantomjs
![Page 12: Quality assurance for javascript](https://reader031.vdocuments.net/reader031/viewer/2022013121/554c0ea7b4c905ec518b46da/html5/thumbnails/12.jpg)
Grunt Configuration
![Page 13: Quality assurance for javascript](https://reader031.vdocuments.net/reader031/viewer/2022013121/554c0ea7b4c905ec518b46da/html5/thumbnails/13.jpg)
Outline
Server Side Javascript Environment Preparation Static Check & Unit Test
![Page 14: Quality assurance for javascript](https://reader031.vdocuments.net/reader031/viewer/2022013121/554c0ea7b4c905ec518b46da/html5/thumbnails/14.jpg)
Static Check via JSHint
![Page 15: Quality assurance for javascript](https://reader031.vdocuments.net/reader031/viewer/2022013121/554c0ea7b4c905ec518b46da/html5/thumbnails/15.jpg)
mpt comes from
Gruntfile.js
![Page 16: Quality assurance for javascript](https://reader031.vdocuments.net/reader031/viewer/2022013121/554c0ea7b4c905ec518b46da/html5/thumbnails/16.jpg)
Unit Test via
![Page 17: Quality assurance for javascript](https://reader031.vdocuments.net/reader031/viewer/2022013121/554c0ea7b4c905ec518b46da/html5/thumbnails/17.jpg)
Mocha
Feature Rich Runs on node + the browser Simplifies async testing Growl notifications Choose your own assertion library
![Page 18: Quality assurance for javascript](https://reader031.vdocuments.net/reader031/viewer/2022013121/554c0ea7b4c905ec518b46da/html5/thumbnails/18.jpg)
Chai
BDD / TDD For node + the browser Three assertion styles
should - foo.should.be.a('string') expect - expect(foo).to.be.a('string') assert - assert.typeOf(foo,'string')
![Page 19: Quality assurance for javascript](https://reader031.vdocuments.net/reader031/viewer/2022013121/554c0ea7b4c905ec518b46da/html5/thumbnails/19.jpg)
Sample: TableRender.html
![Page 20: Quality assurance for javascript](https://reader031.vdocuments.net/reader031/viewer/2022013121/554c0ea7b4c905ec518b46da/html5/thumbnails/20.jpg)
Sample: TableRender.js (1)
![Page 21: Quality assurance for javascript](https://reader031.vdocuments.net/reader031/viewer/2022013121/554c0ea7b4c905ec518b46da/html5/thumbnails/21.jpg)
Sample: TableRender.js (2)
![Page 22: Quality assurance for javascript](https://reader031.vdocuments.net/reader031/viewer/2022013121/554c0ea7b4c905ec518b46da/html5/thumbnails/22.jpg)
Unit Tests via Grunt
![Page 23: Quality assurance for javascript](https://reader031.vdocuments.net/reader031/viewer/2022013121/554c0ea7b4c905ec518b46da/html5/thumbnails/23.jpg)
Reference
http://addyosmani.com/writing-modular-js/ http://www.slideshare.net/FabienDoiron/grunt-js http://www.slideshare.net/jamescryer/javascript-
testing-mocha-chai http://visionmedia.github.io/mocha/ http://chaijs.com/
![Page 24: Quality assurance for javascript](https://reader031.vdocuments.net/reader031/viewer/2022013121/554c0ea7b4c905ec518b46da/html5/thumbnails/24.jpg)