This is an example of how to write qunit style tests for brunch.io projects and the required setup
Created
December 22, 2012 21:55
-
-
Save smazurov/4361413 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# add this to the end of the exports object in the config file | |
test: | |
ui: 'qunit' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// This file will be automatically required when using `brunch test` command. | |
var chai = require('chai'); | |
module.exports = { | |
ok: function(state, message) { | |
chai.assert.ok(state, message); | |
}, | |
notEqual: function(actual, expected, message) { | |
chai.assert.notEqual(actual, expected, message); | |
}, | |
equal: function(actual, expected, message) { | |
chai.assert.equal(actual, expected, message); | |
}, | |
equals: function(actual, expected, message) { | |
this.equal(actual, expected, message); | |
}, | |
deepEqual: function(actual, expected, message) { | |
chai.assert.deepEqual(actual, expected, message); | |
} | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// test/name-of-module-test.js | |
test("one tautology", function() { | |
ok(true); | |
}); | |
suite("simple tests"); | |
test("increments", function() { | |
var mike = 0; | |
ok(mike++ === 0); | |
ok(mike === 1); | |
}); | |
test("increments (improved)", function() { | |
var mike = 0; | |
equal(mike++, 0); | |
equal(mike, 1); | |
}); | |
suite("setUp/tearDown"); | |
before(function() { | |
// console.log("Before"); | |
}); | |
after(function() { | |
// console.log("After"); | |
}); | |
test("example", function() { | |
// console.log("During"); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment