Last active
August 5, 2024 11:47
-
-
Save fpirsch/464e1d424bb24b0b9fe9a404eee7a4d4 to your computer and use it in GitHub Desktop.
The smallest test framework
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const test = exports.test = (label, cb) => (test.$list || (test.$list = [])).push({ label, cb }) | |
exports.beforeEach = cb => test.$beforeEach = cb | |
setImmediate(() => test.$list.forEach(async ({ label, cb }) => console.log(label, await cb(test.$beforeEach?.()) || '\u001B[32m✔\u001B[39m'))) | |
test.skip = (label, cb) => console.log(label, '\u001B[91m✗ SKIPPED\u001B[39m') | |
test.todo = (label, cb) => console.log(label, '\u001B[91m✗ TODO\u001B[39m') | |
test.only = (label, cb) => (test.$list = [{ label, cb }]).push = () => {} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
No bullshit test framework with
Recommended assertion library : https://nodejs.org/api/assert.html
Usage example: