JavaScript Testing: Mocha + Chai
Upcoming SlideShare
Loading in...5
×
 

JavaScript Testing: Mocha + Chai

on

  • 3,633 views

Introduction to Mocha with Chai for TDD/BDD with JavaScript

Introduction to Mocha with Chai for TDD/BDD with JavaScript

Statistics

Views

Total Views
3,633
Views on SlideShare
3,630
Embed Views
3

Actions

Likes
5
Downloads
19
Comments
0

2 Embeds 3

http://www.linkedin.com 2
https://www.linkedin.com 1

Accessibility

Categories

Upload Details

Uploaded via as Microsoft PowerPoint

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

    JavaScript Testing: Mocha + Chai JavaScript Testing: Mocha + Chai Presentation Transcript

    • JavaScript Testing With Mocha and Chai
    • JavaScript Test Frameworks• QUnit• Mocha• YUI Test• Jasmine• JSUnit • CrosscheckJ3Unit JSNUnit JSSpec UnitTestingJSpec screw-unit• Suitest Test.SimpleRhinoUnit Buster.JS• Sinon.js• DOH• Enhance JS• RhUnit
    • Choosing a framework• Client side?• Server side?• Well maintained?• Well documented?• Integration with CI
    • Mocha
    • Mocha• Feature Rich• Runs on node + the browser• Simplifies async testing• Growl notifications• Choose your own assertion library
    • Chai• BBD / 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’)
    • Getting started• Requires node• Requires npm• npm install -g mocha• npm install -g chai
    • Setup• Expects tests to be in <project_root>/test• Allows of per project options file: • mocha.opts• To run test: • mocha
    • First testdescribe(Array, function(){ describe(#indexOf(), function(){ it(should return -1 when the value is not present, function(){ [1,2,3].indexOf(5).should.equal(-1); [1,2,3].indexOf(0).should.equal(-1); }) })})
    • Hooks• before()• after()• beforeEach()• afterEach()
    • Modifying Test Cases• Pending tests - no callback• Exclusive tests - append .only• Inclusive tests - append .skip
    • Other features• mocha --reports• mocha --watch• mocha --growl• mocha --compilers• Interface support for: TDD, BDD + QUnit
    • CoffeeScript• mocha --compilers coffee:coffee-script describe Task instance, -> task1 = task2 = null it should have a name, -> task1 = new Task feed the cat task1.name.should.equal feed the cat
    • Fin