Skip to content

Instantly share code, notes, and snippets.

@peterjwest
Created April 21, 2017 17:07
Show Gist options
  • Save peterjwest/ae556cfd329983575a47ca0b9d4b1cd3 to your computer and use it in GitHub Desktop.
Save peterjwest/ae556cfd329983575a47ca0b9d4b1cd3 to your computer and use it in GitHub Desktop.
Mocha timeouts
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