Skip to content

Instantly share code, notes, and snippets.

@darobin
Created June 15, 2012 10:10
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save darobin/2935734 to your computer and use it in GitHub Desktop.
Save darobin/2935734 to your computer and use it in GitHub Desktop.
Async testing
// 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