Quality Assurance for JavaScript
Contact me: hadoope@gmail.com
Outline
 Server Side Javascript
 Environment Preparation
 Static Check & Unit Test
NodeJs
 Javascript is a frontend programming language,
but things have changed...
Server Side Javascript
 Server Side Javascript needs:
 Package management and Modular
 Task Management Tools, like mave...
Writing Modular JavaScript
 Modularity
 AMD: Asynchronous Module Definition
define(
module_id /*optional*/,
[dependencie...
Package Management
NPM is short for Node Packaged Modules.
Grunt.js
 Why a build tool is needed for CI ?
 Why Grunt.js
Basic Grunt.js tasks
 init
Generate project scaffolding from a predefined template
 lint
validate files with jshint
 mi...
Outline
 Server Side Javascript
 Environment Preparation
 Static Check & Unit Test
Install NodeJs
 Install via source code
 Download from
nodejs.org/download
 ./configure & make & make install
 Install...
Install Related Modules
 npm install -g grunt-cli
 npm install -g grunt-contrib-jshint
 npm install -g grunt-mocha-
pha...
Grunt Configuration
Outline
 Server Side Javascript
 Environment Preparation
 Static Check & Unit Test
Static Check via JSHint
mpt comes from
Gruntfile.js
Unit Test via
Mocha
 Feature Rich
 Runs on node + the browser
 Simplifies async testing
 Growl notifications
 Choose your own asser...
Chai
 BDD / TDD
 For node + the browser
 Three assertion styles
 should - foo.should.be.a('string')
 expect - expect(...
Sample: TableRender.html
Sample: TableRender.js (1)
Sample: TableRender.js (2)
Unit Tests via Grunt
Reference
 http://addyosmani.com/writing-modular-js/
 http://www.slideshare.net/FabienDoiron/grunt-js
 http://www.slide...
Quality assurance for javascript
Upcoming SlideShare
Loading in...5
×

Quality assurance for javascript

388

Published on

0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
388
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
4
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide

Quality assurance for javascript

  1. 1. Quality Assurance for JavaScript Contact me: hadoope@gmail.com
  2. 2. Outline  Server Side Javascript  Environment Preparation  Static Check & Unit Test
  3. 3. NodeJs  Javascript is a frontend programming language, but things have changed...
  4. 4. 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
  5. 5. Writing Modular JavaScript  Modularity  AMD: Asynchronous Module Definition define( module_id /*optional*/, [dependencies] /*optional*/, definition function /*function for instantiating the module or object*/ );
  6. 6. Package Management NPM is short for Node Packaged Modules.
  7. 7. Grunt.js  Why a build tool is needed for CI ?  Why Grunt.js
  8. 8. 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)
  9. 9. Outline  Server Side Javascript  Environment Preparation  Static Check & Unit Test
  10. 10. 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
  11. 11. Install Related Modules  npm install -g grunt-cli  npm install -g grunt-contrib-jshint  npm install -g grunt-mocha- phantomjs
  12. 12. Grunt Configuration
  13. 13. Outline  Server Side Javascript  Environment Preparation  Static Check & Unit Test
  14. 14. Static Check via JSHint
  15. 15. mpt comes from Gruntfile.js
  16. 16. Unit Test via
  17. 17. Mocha  Feature Rich  Runs on node + the browser  Simplifies async testing  Growl notifications  Choose your own assertion library
  18. 18. 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')
  19. 19. Sample: TableRender.html
  20. 20. Sample: TableRender.js (1)
  21. 21. Sample: TableRender.js (2)
  22. 22. Unit Tests via Grunt
  23. 23. 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/
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×