Skip to content

Instantly share code, notes, and snippets.

@smazurov
Created December 22, 2012 21:51
Show Gist options
  • Save smazurov/4361398 to your computer and use it in GitHub Desktop.
Save smazurov/4361398 to your computer and use it in GitHub Desktop.
Setup needed to get bdd-syntax tests rocking for brunch.io

This is an example of how to write bdd style tests for brunch.io projects and the required setup

// This file will be automatically required when using `brunch test` command.
var chai = require('chai');
module.exports = {
assert: chai.assert,
expect: chai.expect,
should: chai.should
};
// test/name-of-module-test.js
describe('Array BDD', function(){
describe('#indexOf()', function(){
it('should return -1 when the value is not present', function(){
assert.equal(-1, [1,2,3].indexOf(5));
assert.equal(-1, [1,2,3].indexOf(0));
});
});
});
describe('object', function(){
var foo = 'bar', beverages = { tea: [ 'chai', 'matcha', 'oolong' ] };
it('foo should be a string, equal to bar and have length of 3', function(){
assert.typeOf(foo, 'string', 'foo is a string');
assert.equal(foo, 'bar', 'foo equal `bar`');
assert.lengthOf(foo, 3, 'foo`s value has a length of 3');
});
it('beverages should have 2 types of tea', function() {
assert.lengthOf(beverages.tea, 3, 'beverages has 3 types of tea');
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment