Gulp-Mocha delay before performing test

150 Views Asked by At

The normal version of Mocha supports delays before executings tests (link: https://mochajs.org/#hooks).

Is there a way to do this in gulp-mocha?

2

There are 2 best solutions below

3
Stanislav On

The tests syntax remains the same when using gulp-mocha in compare to simple mocha

Actually, gulp-mocha is just a wrapper to help you run test suites via gulp

0
DevNebulae On

The ideal way to fix this issue is to make an asynchronous test.

describe('StackOverflowExample', function() {
    it('Demonstrates how to create a test with delay', async function(done) {
        setTimeout(() => {
            //Your code here
            done();
        }, 250); //Set the delay to your liking
    });
});