Created
October 2, 2019 12:50
-
-
Save olegpolyakov/589c5cde40c97c65ce04851ab573d446 to your computer and use it in GitHub Desktop.
Test runner
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 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