public
Last active

Async testing

  • Download Gist
gistfile1.js
JavaScript
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
 
// 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);
});
});

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.