Skip to content

Instantly share code, notes, and snippets.

@olegpolyakov
Created October 2, 2019 12:50
Show Gist options
  • Save olegpolyakov/589c5cde40c97c65ce04851ab573d446 to your computer and use it in GitHub Desktop.
Save olegpolyakov/589c5cde40c97c65ce04851ab573d446 to your computer and use it in GitHub Desktop.
Test runner
const testRunner = {
tests: [],
test(description, fn) {
this.tests.push({
description,
fn
});
},
run() {
return new Promise((resolve, reject) => {
for (let test of this.tests) {
try {
test.fn();
test.ok = true;
} catch (error) {
test.ok = false;
test.error = error;
}
}
resolve(this.tests);
this.tests = [];
});
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment