Created
October 13, 2019 19:52
-
-
Save yoav-lavi/19f75d24181862d69399548abd49be26 to your computer and use it in GitHub Desktop.
Scriptable describe + test
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
exports.describe = async (name, callback) => { | |
const output = []; | |
const test = async (name, callback) => { | |
const testStartTime = Date.now(); | |
const testResult = await callback(); | |
const testTime = | |
Date.now() - testStartTime; | |
output.push( | |
`• ${name} (${testTime}ms): ${ | |
testResult ? '✅' : '❌' | |
}` | |
); | |
}; | |
const suiteStartTime = Date.now(); | |
await callback(test); | |
const totalTime = | |
Date.now() - suiteStartTime; | |
output.push(`${totalTime}ms total`); | |
const alert = new Alert(); | |
alert.title = name; | |
alert.message = output.join('\n'); | |
alert.addAction('Done'); | |
alert.present(); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment