Reputation: 7107
In my test environment I'm using mocha
as my test runner. I have configured the NODE_ENV
as "test" in a setup.js
file which I configured to run with mocha on start up using
mocha --require setup.js
I am using sequelize
as my ORM and I want it to init with the force
flag set to true. Where should I execute the sync
function?
import models from '../src/data/models';
models.sync({
force: true
});
Since it is an async function, the tests may start before the syncing stage finished.
Upvotes: 0
Views: 157
Reputation: 1671
Add any initialization or code that you need run prior to your tests running to the global before
handler.
before(function () {
//models code here
return models.sync({});
})
Upvotes: 1