#Greetings
  • Sequoia McDowell
  • Web Developer at PTC
  • @_sequoia
  • sequoia.mcdowell@gmail.com

Testing Javascript

with Jasmine.js

it( 'should add one and one' , function(){
	expect( 1 + 1 ).toEqual( 2 );
});

What is Unit Testing?

Wikipedia:
Unit testing: a method by which individual units of source code, sets of one or more computer program modules together with associated control data, usage procedures, and operating procedures, are tested to determine if they are fit for use.

Code that tests other code

Why Do It?

  • Know when code stops working
  • Know when code starts working
  • I changed my code, does it still work?

Benefits

  • Catch bugs early
  • Change code faster, more safely
  • Forces you to write better code

How/When do you do it?

  • When you write a feature
  • When you fix a bug
  • Before you write a feature
    (Test Driven Development)
  • Before you deploy/share

Other Stuff

  • More Matchers (jQuery, underscore)
  • Fixtures
  • Running from Console

Resources

me