Last active
February 7, 2018 13:56
-
-
Save pcornier/622d266376e4a898e89d3e34afa446e9 to your computer and use it in GitHub Desktop.
running ordered async tests
This file contains 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
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