Make Mocha wait before running next test

Got some mocha tests that require data from prior function calls, but then because it's using a webservice, and would like it to literally wait for a predetermined amount of time before running the next test, something like:

var global;

it('should give some info', function(done) {
  run.someMethod(param, function(err, result) {
    global = result.global
  done();
  });
});

wait(30000); // basically block it from running the next assertion

it('should give more info', function(done) {
  run.anotherMethod(global, function(err, result) {
    expect(result).to.be.an('object');
  done();
  });
});

Any ideas would be appreciated. Thanks!

While this.timeout() will extend the timeout of a single test, it's not the answer to your question. this.timeout() sets the timeout of your current test.

But don't worry, you should be fine anyway. Tests are not running in parallel, they're done in series, so you should not have a problem with your global approach.

setTimeout definitely could help, but may be there is a "cleaner" way to do that. docs actually says to use this.timeout(delay) to avoid timeout errors while testing async code, so be careful.

var global;

it('should give some info', function(done) {
  run.someMethod(param, function(err, result) {
    global = result.global
  done();
  });
});



it('should give more info', function(done) {
    this.timeout(30000);

    setTimeout(function () {
      run.anotherMethod(global, function(err, result) {
        expect(result).to.be.an('object');
        done();
      });
    }, 30000);
 });