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.
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({});
})
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.