mirror of
https://github.com/Unleash/unleash.git
synced 2024-12-28 00:06:53 +01:00
d1fd5d3900
* fix: e2e tests should only set up one database per test file * fix: Allow e2e-tests to reset db content
43 lines
1.0 KiB
JavaScript
43 lines
1.0 KiB
JavaScript
'use strict';
|
|
|
|
process.env.NODE_ENV = 'test';
|
|
|
|
const supertest = require('supertest');
|
|
|
|
const getApp = require('../../../lib/app');
|
|
const getLogger = require('../../fixtures/no-logger');
|
|
const StateService = require('../../../lib/state-service');
|
|
|
|
const { EventEmitter } = require('events');
|
|
const eventBus = new EventEmitter();
|
|
|
|
function createApp(stores, adminAuthentication = 'none', preHook) {
|
|
return getApp({
|
|
stores,
|
|
eventBus,
|
|
preHook,
|
|
adminAuthentication,
|
|
secret: 'super-secret',
|
|
sessionAge: 4000,
|
|
stateService: new StateService({ stores, getLogger }),
|
|
getLogger,
|
|
});
|
|
}
|
|
|
|
module.exports = {
|
|
async setupApp(stores) {
|
|
const app = createApp(stores);
|
|
return supertest.agent(app);
|
|
},
|
|
|
|
async setupAppWithAuth(stores) {
|
|
const app = createApp(stores, 'unsecure');
|
|
return supertest.agent(app);
|
|
},
|
|
|
|
async setupAppWithCustomAuth(stores, preHook) {
|
|
const app = createApp(stores, 'custom', preHook);
|
|
return supertest.agent(app);
|
|
},
|
|
};
|