- Screen name: Clint Irving
Clint Irving's Profile
1 Posts
1 Responses
0
Followers
Show:
- Expanded view
- List view
Private Message
- 06-Aug-2013 10:31 PM
- Forum: QUnit and Testing
Perhaps I’m doing something incorrectly, or it’s related to how I’m loading QUnit with requirejs, but I’ve noticed that the testStart and testDone callbacks do not seem to run atomically with the test itself. This same issue also appears to occur with the setup and teardown callbacks in a module definition. Here’s a code snippet to illustrate this:
- // mytests.js
- define(["qunit"], function ( QUnit) {
- var run = function () {
- QUnit.testStart = function (details) {
- console.log("testStart: " + details.name);
- };
- QUnit.testDone = function (details) {
- console.log("testDone: " + details.name);
- };
- test("test 1", function () {
- console.log("run: test 1");
- ok(true);
- });
- test("test 2", function () {
- console.log("run: test 2");
- ok(true);
- });
- };
- return { run: run };
- });
- // tests.js
- define(["qunit", "mytests"], function(QUnit, mytests) {
- mytests.run();
- });
- // main.js
- requirejs.config({
- paths: {
- "qunit": "/qunit/qunit-1.12.0",
- },
- shim: {
- "qunit": {
- exports: "QUnit",
- init: function() {
- QUnit.config.autoload = false;
- QUnit.config.autostart = false;
- }
- }
- }
- });
- require(["tests.js"], function (tests) {
- });
The output of the run of mytests can produce the following:
testStart: test 1
run: test 1
testStart: test 2
run: test 2
testDone: test 1
testDone: test 2
I would have expected only either of the following outputs:
testStart: test 1
run: test 1
testDone: test 1
testStart: test 2
run: test 2
testDone: test 2
or:
testStart: test 2
run: test 2
testDone: test 2
testStart: test 1
run: test 1
testDone: test 1
- «Prev
- Next »
Moderate user : Clint Irving