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?
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?
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
Well, it’s specifically on the server
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
@florianbienefelt Very cool.
I suggest to use root level mocha hooks.
Then before block will run before all tests.
// init.app-test.js
/* eslint-env mocha */
import { Meteor } from 'meteor/meteor';
before((done) => {
// wait until all server modules are loaded (in Meteor.startup)
Meteor.startup(done);
});