1
0
mirror of https://github.com/Unleash/unleash.git synced 2024-12-28 00:06:53 +01:00
unleash.unleash/test/specHelper.js
Jari Bakken d89ce75906 Test refactoring:
* reduce setup duplication
* consistent test file names
2014-11-25 14:41:11 +01:00

35 lines
824 B
JavaScript

var request = require('supertest');
var mockery = require('mockery');
var server;
function setupMockServer() {
mockery.enable({
warnOnReplace: false,
warnOnUnregistered: false,
useCleanCache: true
});
mockery.registerSubstitute('./eventDb', '../test/eventDbMock');
mockery.registerSubstitute('./featureDb', '../test/featureDbMock');
mockery.registerSubstitute('./strategyDb', '../test/strategyDbMock');
server = require('../server');
return request('http://localhost:' + server.app.get('port'));
}
function tearDownMockServer() {
mockery.disable();
mockery.deregisterAll();
if (server) {
server.server.close();
server = null;
}
}
module.exports = {
setupMockServer: setupMockServer,
tearDownMockServer: tearDownMockServer
};