Skip to content

Instantly share code, notes, and snippets.

@sadick254
Created June 20, 2018 17:24
Show Gist options
  • Save sadick254/79ab060a64b099b20a37775746b90fe1 to your computer and use it in GitHub Desktop.
Save sadick254/79ab060a64b099b20a37775746b90fe1 to your computer and use it in GitHub Desktop.
const assert = require("assert");
function describe(testcase, callback) {
console.log(testcase);
callback();
}
function it(description, callback) {
try {
callback();
console.log(`\t ✓ ${description}`);
} catch (e) {
console.log(`\t x ${description}`);
}
}
function expect(actual) {
return {
toEqual(expected) {
assert.equal(actual, expected);
},
toBe(expected) {
assert.deepStrictEqual(actual, expected);
},
toBeTruthy() {
assert.ok(actual);
},
toHaveLength(expected) {
assert.ok(actual.length === expected);
}
};
}
module.exports = {
describe,
expect,
it
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment