Add QunitAssert parameter to setup functions

Add QunitAssert parameter to the setup, teardown, beforeEach and
afterEach functions.

This facilitates the usage of for example async code in the setup.
This commit is contained in:
Rainer ziller
2015-11-26 16:01:04 +01:00
parent b4d977b61e
commit a5ff255a5d
2 changed files with 32 additions and 4 deletions
+24
View File
@@ -170,6 +170,30 @@ QUnit.module("module A", {
}
});
QUnit.module("module with async setup and teardown", {
setup: function (assert) {
var done = assert.async();
setTimeout(function () {
// prepare something for all following tests
});
},
teardown: function (assert) {
// clean up after each test
}
});
QUnit.module("module with async setup and teardown", {
beforeEach: function (assert: QUnitAssert) {
var done = assert.async();
setTimeout(function () {
// prepare something for all following tests
});
},
afterEach: function () {
// clean up after each test
}
});
QUnit.test("a test", function (assert) {
function square(x) {