Setup up non-API tests to not need server and mongo running

chore(travis): Build files before running tests

chore(travis): require server for api tests
This commit is contained in:
Blade Barringer
2016-10-20 22:32:46 -05:00
parent 93aa92de7c
commit ba19c00617
6 changed files with 25 additions and 25 deletions

View File

@@ -15,25 +15,3 @@ global.expect = chai.expect;
global.sinon = require('sinon');
global.sandbox = sinon.sandbox.create();
global.Promise = Bluebird;
import nconf from 'nconf';
import mongoose from 'mongoose';
//------------------------------
// Load nconf for unit tests
//------------------------------
if (process.env.LOAD_SERVER === '0') { // when the server is in a different process we simply connect to mongoose
require('../../website/server/libs/setupNconf')('./config.json');
// Use Q promises instead of mpromise in mongoose
mongoose.Promise = Bluebird;
mongoose.connect(nconf.get('TEST_DB_URI'));
} else { // When running tests and the server in the same process
require('../../website/server/libs/setupNconf')('./config.json.example');
nconf.set('NODE_DB_URI', nconf.get('TEST_DB_URI'));
nconf.set('NODE_ENV', 'test');
nconf.set('IS_TEST', true);
// We require src/server and npt src/index because
// 1. nconf is already setup
// 2. we don't need clustering
require('../../website/server/server');
}