I have a setup like below:
- nodejs restify application
- mocha tests with beforeEach that runs a raw SQL file through knex to the postgres database
- the file drops and creates all tables and populates with data
All of my tests fail with postgresql showing “relation ‘users’ does not exist” . If I enable ssh and run them manually using the same command as in circle.yml they all pass.
dbhelper
var fs = require('fs'),
db = require('../../lib/database');
module.exports = {
reset: reset
};
function reset() {
return new Promise(function (resolve, reject) {
fs.readFile('./test/data/create_db.sql', function (err, data) {
if (err) {
return reject(err);
}
db.raw(data.toString('utf8')).then(function () {
resolve();
}).catch(function (err) {
console.log('reset failed')
reject(err);
});
});
});
}
in all root describes for all test files
beforeEach(function (done) {
this.timeout(120000);
dbhelper.reset().then(done).catch(function (err) {
throw err;
});
});
Not really sure where to go from here. Any suggestions would be much appreciated.