// Runs once at the very beginning.
QUnit.begin(function () {
console.log("Running Test Suite");
});
// Runs once at the very end.
QUnit.done(function (data) {
console.info("Suite: %d failures / %d passed / %d tests", data.failed, data.passed, data.total);
});
// Runs once after each assertion.
QUnit.log(function (data) {
console[data.result ? "log" : "error"](data.message);
});
// Runs before each test.
QUnit.testStart(function (data) {
console.group("Test: " + data.name);
});
// Runs after each test.
QUnit.testDone(function (data) {
console.info("Test: %d failures / %d passed / %d tests", data.failed, data.passed, data.total);
console.groupEnd();
});
// Runs before each module.
QUnit.moduleStart(function (data) {
console.group("Module: " + data.name);
});
// Runs after each module.
QUnit.moduleDone(function (data) {
console.info("Module: %d failures / %d passed / %d tests", data.failed, data.passed, data.total);
console.groupEnd();
});
module("core");
test("a test in the core module", function () {
ok(true, "this test had better pass");
});
test("another test in the core module", function () {
ok(true, "this test had also better pass");
});
module("options");
test("a test in the options module", function () {
ok(true, "this test really, really better pass");
});
test("another test in the options module", function () {
ok(false, "sadly, this test is going to fail");
});
// Defining "setup" and "teardown" callbacks.
module("other", {
setup: function () {
ok(true, "once extra assert per test");
this.prop = "foo";
},
teardown: function () {
ok(true, "and one extra assert after each test");
}
});
test("test with setup and teardown", function () {
expect(3);
deepEqual(this.prop, "foo", "this.prop === 'foo' in all tests");
});
Please Whitelist JSFiddle in your content blocker.
Help keep JSFiddle free for always by one of two ways:
Whitelist JSFiddle in your content blocker (two clicks)
Go PRO and get access to additional PRO features →
Join the 4+ million users, and keep the JSFiddle dream alive.
Ad-free
All ads in the editor and listing pages are turned completely off.
Use pre-released features
You get to try and use features (like the Palette Color Generator) months before everyone else.
Fiddle collections
Sort and categorize your Fiddles into multiple collections.
Private collections and fiddles
You can make as many Private Fiddles, and Private Collections as you wish!
Console
Debug your Fiddle with a minimal built-in JavaScript console.