How to wait for Meteor to be ready before running tests?

#1

I’m trying to run some code in Meteor.startup, before running my test suite. But my test suite starts running before the startup callback is called.

How can I force Meteor to wait for it?

#2

If you are performing a client side test you can use the method Meteor.status(), it will return an object indicates the status so you can wait until it is {connected:true}, at this stage the server is totally ready

#3

Well, it’s specifically on the server :confused:

#4

Well, this might do the trick:

describe('Init', () => {
  before(done => {
    Meteor.startup(done);
  });

  it('Has Initiated', () => {
    console.log('Server is ready')
  });
});

You just need to make sure this test suite runs first

2 Likes