Created
June 15, 2012 10:10
-
-
Save darobin/2935734 to your computer and use it in GitHub Desktop.
Async testing
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
// testharness.js | |
var t = async_test("Timeout times out"); | |
setTimeout(t.step_func(function () { | |
assert_true(true); | |
t.done(); | |
}), 100); | |
// Jasmine | |
describe("Timeout", function () { | |
it("times out", function () { | |
var result = false; | |
setTimeout(function () { result = true; }, 100); | |
waitsFor(function () { return result; }); | |
runs(function () { | |
expect(result).toBeTruthy(); | |
}); | |
}); | |
}) | |
// QUnit | |
asyncTest("Timeout times out", function () { | |
setTimeout(function () { | |
ok(true, "true is true"); | |
start(); | |
}, 100); | |
}); | |
// Mocha | |
describe("Timeout", function () { | |
it("times out", function (done) { | |
setTimeout(function () { | |
true.should.equal(true); | |
done(); | |
}, 100); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment