Created
April 21, 2017 17:07
-
-
Save peterjwest/ae556cfd329983575a47ca0b9d4b1cd3 to your computer and use it in GitHub Desktop.
Mocha timeouts
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
var assert = require('assert'); | |
describe('Synchronous timeout', () => { | |
beforeEach(() => { | |
var x = Date.now(); | |
while (Date.now() < x + 2100) {} | |
}); | |
it('Tests nothing', () => assert.equal(1, 1)); | |
}); | |
describe('Asynchronous timeout', () => { | |
beforeEach((done) => { | |
setTimeout(done, 2100); | |
}); | |
it('Tests nothing', () => assert.equal(1, 1)); | |
}); | |
describe('Combination timeout', () => { | |
beforeEach((done) => { | |
var x = Date.now(); | |
while (Date.now() < x + 1500) {} | |
setTimeout(done, 600); | |
}); | |
it('Tests nothing', () => assert.equal(1, 1)); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment