Tests fail (mocha, postgresql, knex)


I have a setup like below:

  1. nodejs restify application
  2. mocha tests with beforeEach that runs a raw SQL file through knex to the postgres database
  3. 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.


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 () {
            }).catch(function (err) {
                console.log('reset failed')

in all root describes for all test files

 beforeEach(function (done) {
        dbhelper.reset().then(done).catch(function (err) {
            throw err;

Not really sure where to go from here. Any suggestions would be much appreciated.