slid.es/w33ble/let-s-talk-testing
It doesn't matter
Verify output or other parameters
Collection of tests
A single test
Consistent source of data
Consistent replacement for other code
Watch and query code execution
Pattern for grouping code into components
Passing dependencies to consumers
Amount of your code that is tests
Detects errors and potential problems
Integrating code into a shared repo
Pushing working code to production
test("make sure the thingie is a thing", function (t) {
t.equal(thingie, "thing", "thingie should be thing");
t.deepEqual(array, ["foo", "bar"], "array has foo and bar elements");
t.deepEqual(object, {foo: 42}, "object has foo property");
t.type(thingie, "string", "type of thingie is string");
t.ok(true, "this is always true");
t.notOk(false, "this is never true");
t.test("a child test", function (t) {
t.equal(this, superEasy, "right!?");
});
});
var expect = require('chai').expect;
describe('User', function(){
describe('save', function(){
it('should be a function', function () {
expect(User).to.have.property('save');
expect(User.save).to.be.a('function');
});
it('should save without error', function(done){
var user = new User('Luna');
user.save(function(err){
expect(err).to.be.a('null');
expect(user.name).to.be('Luna');
done();
});
});
});
});
describe('User', function(){
describe('save', function(){
it('should be a function', function () {
expect('save' in User).toBe(true);
expect(typeof User.save).toBe('function');
});
it('should save without error', function(done){
var user = new User('Luna');
user.save(function(err){
expect(err).toBeNull('null');
expect(user.name).toBe('Luna');
done();
});
});
});
});
Test a specific, isolated unit of code
Test the integration of system components
Test a specific, isolated unit of code
Test the integration of components
Automatic Local Execution
Automatic Remote Execution
Did the tests pass?