Testing the below in a Mocha/Chain start-up block, the code never waits as expected. Instead, the log reports on the start of creation, then logs from a test (not included), then reports the index creation is complete.
Should not Mocha not exit the before-each block until the Promise is reolved or rejected?
What have I missed?
module.exports.prototype.setup = function (term) {
this.logger.info("Re-creating the index '%s'", $index);
return this.client.indices.delete({
index: $index,
ignore: [404]
}).then((err, resp, respcode) => {
this.logger.info("Creating index '%s'", $index);
return this.client.indices.create({
index: $index,
body: this.schemaBody
});
});
};