diff --git a/test/integration-tests/test-server/run-test.ts b/test/integration-tests/test-server/run-test.ts index 311a7af..5c6c33d 100644 --- a/test/integration-tests/test-server/run-test.ts +++ b/test/integration-tests/test-server/run-test.ts @@ -2,7 +2,8 @@ import { closeConnection, initConnection } from '@enigmatis/mongo-driver'; import { config } from 'dotenv'; import * as mongoose from 'mongoose'; import { logger, server } from './server'; -export async function init() { + +export async function startTestServer() { config(); jest.setTimeout(15000); const connectionString = @@ -12,7 +13,7 @@ export async function init() { server.start(); } -export async function finish() { +export async function stopTestServer() { await closeConnection(); await server.stop(); } diff --git a/test/integration-tests/tests/irrelevant-entities.test.ts b/test/integration-tests/tests/irrelevant-entities.test.ts index 180b719..4c1b9cc 100644 --- a/test/integration-tests/tests/irrelevant-entities.test.ts +++ b/test/integration-tests/tests/irrelevant-entities.test.ts @@ -1,7 +1,7 @@ import { PolarisRequestHeaders } from '@enigmatis/utills'; import { graphqlRawRequest, graphQLRequest } from '../test-server/client'; import { BookModelPerReality } from '../test-server/dal/book-model'; -import { finish, init } from '../test-server/run-test'; +import { startTestServer, stopTestServer } from '../test-server/run-test'; export const titles = ['first', 'second', 'third', 'fourth', 'fifth']; const prepareDb = async (headers: PolarisRequestHeaders) => { @@ -15,12 +15,12 @@ const prepareDb = async (headers: PolarisRequestHeaders) => { const requestHeaders = { 'reality-id': 1, 'data-version': 1 }; beforeEach(async () => { - await init(); + await startTestServer(); await prepareDb({ realityId: 1 }); }); afterEach(() => { - return finish(); + return stopTestServer(); }); describe('irrelevant entities tests', () => { diff --git a/test/integration-tests/tests/mutation.test.ts b/test/integration-tests/tests/mutation.test.ts index ff92711..4e32846 100644 --- a/test/integration-tests/tests/mutation.test.ts +++ b/test/integration-tests/tests/mutation.test.ts @@ -1,5 +1,5 @@ import { graphQLRequest } from '../test-server/client'; -import { finish, init } from '../test-server/run-test'; +import { startTestServer, stopTestServer } from '../test-server/run-test'; const headers = { 'reality-id': 1 }; const createBookMutation = `mutation createBook ($book:BookInput!) {createBook(book:$book){testId}}`; @@ -12,11 +12,11 @@ const deleteBookMutation = `mutation deleteBook ($bookId:String!) { const defaultBookVariables = (title: string, testId: string) => ({ title, testId }); beforeEach(() => { - return init(); + return startTestServer(); }); afterEach(() => { - return finish(); + return stopTestServer(); }); describe('mutation tests', () => { diff --git a/test/integration-tests/tests/query.test.ts b/test/integration-tests/tests/query.test.ts index 69b8b61..06ed7ef 100644 --- a/test/integration-tests/tests/query.test.ts +++ b/test/integration-tests/tests/query.test.ts @@ -1,7 +1,7 @@ import { PolarisRequestHeaders } from '@enigmatis/utills'; import { graphQLRequest } from '../test-server/client'; import { BookModelPerReality } from '../test-server/dal/book-model'; -import { finish, init } from '../test-server/run-test'; +import { startTestServer, stopTestServer } from '../test-server/run-test'; const titles = ['first', 'second', 'third', 'fourth', 'fifth']; @@ -16,12 +16,12 @@ const prepareDb = async (headers: PolarisRequestHeaders) => { const requestHeaders = { 'reality-id': 1 }; beforeEach(async () => { - await init(); + await startTestServer(); await prepareDb({ realityId: 1 }); }); afterEach(() => { - return finish(); + return stopTestServer(); }); describe('query tests', () => { diff --git a/test/integration-tests/tests/reality.test.ts b/test/integration-tests/tests/reality.test.ts index ead4fef..dc2f19c 100644 --- a/test/integration-tests/tests/reality.test.ts +++ b/test/integration-tests/tests/reality.test.ts @@ -1,7 +1,7 @@ import { graphQLRequest } from '../test-server/client'; import { AuthorModelPerReality } from '../test-server/dal/author-model'; import { BookModelPerReality } from '../test-server/dal/book-model'; -import { finish, init } from '../test-server/run-test'; +import { startTestServer, stopTestServer } from '../test-server/run-test'; const dbRealityIdHeader = (realityId: any) => ({ realityId }); const requestRealityIdHeader = (realityId: any) => ({ 'reality-id': realityId }); @@ -45,12 +45,12 @@ const prepareDb = async () => { }; beforeEach(async () => { - await init(); + await startTestServer(); await prepareDb(); }); afterEach(() => { - return finish(); + return stopTestServer(); }); describe('reality tests', () => {