From c6b0cd0127fb8e7e1d350349ef072b4e4319c6d6 Mon Sep 17 00:00:00 2001 From: Jakob Ackermann Date: Thu, 25 Feb 2021 12:22:37 +0000 Subject: [PATCH] Merge pull request #3687 from overleaf/jpa-spd-mocks-init Move app initialisation logic to separate file GitOrigin-RevId: 858d22b56a42bc1ab53fef54bc209daae4e0fb07 --- services/web/test/acceptance/src/Init.js | 12 +---------- .../test/acceptance/src/helpers/InitApp.js | 20 +++++++++++++++++++ 2 files changed, 21 insertions(+), 11 deletions(-) create mode 100644 services/web/test/acceptance/src/helpers/InitApp.js diff --git a/services/web/test/acceptance/src/Init.js b/services/web/test/acceptance/src/Init.js index 7df31b86ac..7939bebbb4 100644 --- a/services/web/test/acceptance/src/Init.js +++ b/services/web/test/acceptance/src/Init.js @@ -1,6 +1,4 @@ -const App = require('../../../app.js') -const MongoHelper = require('./helpers/MongoHelper') -const { logger } = require('logger-sharelatex') +require('./helpers/InitApp') const MockAnalyticsApi = require('./mocks/MockAnalyticsApi') const MockChatApi = require('./mocks/MockChatApi') @@ -15,10 +13,6 @@ const MockSpellingApi = require('./mocks/MockSpellingApi') const MockV1Api = require('./mocks/MockV1Api') const MockV1HistoryApi = require('./mocks/MockV1HistoryApi') -logger.level('error') - -MongoHelper.initialize() - const mockOpts = { debug: ['1', 'true', 'TRUE'].includes(process.env.DEBUG_MOCKS) } @@ -35,7 +29,3 @@ MockRecurlyApi.initialize(6034, mockOpts) MockSpellingApi.initialize(3005, mockOpts) MockV1Api.initialize(5000, mockOpts) MockV1HistoryApi.initialize(3100, mockOpts) - -before(function(done) { - App.listen(3000, 'localhost', done) -}) diff --git a/services/web/test/acceptance/src/helpers/InitApp.js b/services/web/test/acceptance/src/helpers/InitApp.js new file mode 100644 index 0000000000..5cb94335bd --- /dev/null +++ b/services/web/test/acceptance/src/helpers/InitApp.js @@ -0,0 +1,20 @@ +const App = require('../../../../app.js') +const MongoHelper = require('./MongoHelper') +const { logger } = require('logger-sharelatex') + +logger.level('error') + +MongoHelper.initialize() + +let server + +before('start main app', function(done) { + server = App.listen(3000, 'localhost', done) +}) + +after('stop main app', function(done) { + if (!server) { + return done() + } + server.close(done) +})