Skip to content

Instantly share code, notes, and snippets.

@icodealot
Last active October 13, 2017 13:01
Show Gist options
  • Save icodealot/1e524f1134c7bcaa31a8a61cd4709afe to your computer and use it in GitHub Desktop.
Save icodealot/1e524f1134c7bcaa31a8a61cd4709afe to your computer and use it in GitHub Desktop.
// Trick QUnit into exporting QUnit reference since 1.19+ no
// longer export a global reference to QUnit. (or just revert
// back to using QUnit 1.18.0) Don't actually know if this is
// a good idea or not but it works.
var exports = this;
load("https://code.jquery.com/qunit/qunit-2.4.0.js");
with(QUnit) {
log(function(d) {
var message;
if (!d.result) {
message = " 🛑\t" + d.name + " actual: " + d.actual + " <> expected: " + d.expected;
} else {
message = "✅\t" + d.name;
}
if (d.message) {
message += " >>> " + d.message
}
print(message);
});
done(function(d) {
print("--------------TEST SUMMARY--------------");
print("Completed", d.total, "tests in", d.runtime, "ms\n");
print(" ✅ --> passed:\t",d.passed);
print(" 🛑 --> failed:\t",d.failed);
print("----------------------------------------");
});
}
with(QUnit) {
test("Should be equal", function(assert) {
assert.equal(true,true,"Should be equal...");
});
test("Should not be equal", function(assert) {
assert.equal(false,true);
});
test("Should be OK", function(assert) {
assert.ok(true,"This test is fine.");
});
test("Should fail", function(assert) {
assert.ok(undefined,"This test should fail.");
});
}
QUnit.load();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment