Skip to content

Instantly share code, notes, and snippets.

@pcornier
Last active February 7, 2018 13:56
Show Gist options
  • Save pcornier/622d266376e4a898e89d3e34afa446e9 to your computer and use it in GitHub Desktop.
Save pcornier/622d266376e4a898e89d3e34afa446e9 to your computer and use it in GitHub Desktop.
running ordered async tests
tests = []
running = false
done = function() {
test = tests.shift()
if (test) test(done)
}
const it = function(name, test) {
tests.push(test)
if (!running) {
running = true
done()
}
}
// test file
it('will run first', function(done) {
setTimeout(function() {
console.log('ok1')
done()
}, 1000);
})
it('will start after test1 is done', function(done) {
console.log('ok2')
done()
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment