Test-Driven JavaScript with
Brad Urani
Director of Engineering
@BradUrani
Important Terms:
Suites: a collection of tests in single file - describe
Specs - AKA tests. Test a single condition only - it
Expectation - AKA assertions, verify result - expect
Matcher - Perform comparison - .toEqual, .toBe
TDD vs BDD
TDD vs TFD
Principles of good unit tests
*Your mileage may vary
Important Questions
Integration Tests
Avoid the Middle Ground
Behavioral Testing with the ‘Page’ pattern
Jasmine and CoffeeScript
describe "CoffeeScript Jasmine specs", ->
it "is beautiful!", ->
expect(" your code is so beautiful"). toBeTruthy()
Jasmine and NodeJS
jasmine-node require("../ src/ test.js");
it(" does an asynchronous call", function() {
exampleAsyncCall( function( response) {
expect( response). toContain(" something expected");
done();
});
});
Jasmine and Ruby
gem ‘jasmine’
rails generate jasmine:install
jasmine init
rake jasmine:ci
Jasmine with Jenkins and PhantomJS
Benefits
Costs:
Is it worth it?
Yes, but…
Resources
Source: https://github.com/bradurani/ConwaysGameOfLifeJasmineDemo
Brad Urani
LinkedIn: http://linkedin.com/in/bradurani
Twitter: @BradUrani
Email: bradurani@gmail.com