diff --git a/src/test/e2e/api/admin/favorites.e2e.test.ts b/src/test/e2e/api/admin/favorites.e2e.test.ts index 0229849ee4..4ab4dab948 100644 --- a/src/test/e2e/api/admin/favorites.e2e.test.ts +++ b/src/test/e2e/api/admin/favorites.e2e.test.ts @@ -102,6 +102,7 @@ beforeAll(async () => { afterAll(async () => { await app.destroy(); + await db.destroy(); }); afterEach(async () => { diff --git a/src/test/e2e/api/admin/public-signup-token.e2e.test.ts b/src/test/e2e/api/admin/public-signup-token.e2e.test.ts index 27ce35c89e..7d4850e460 100644 --- a/src/test/e2e/api/admin/public-signup-token.e2e.test.ts +++ b/src/test/e2e/api/admin/public-signup-token.e2e.test.ts @@ -7,7 +7,7 @@ import { PublicSignupTokenCreateSchema } from '../../../../lib/openapi/spec/publ let stores; let db; -beforeEach(async () => { +beforeAll(async () => { db = await dbInit('test', getLogger); stores = db.stores; }); diff --git a/src/test/e2e/api/admin/user/pat.e2e.test.ts b/src/test/e2e/api/admin/user/pat.e2e.test.ts index 4a07a87a56..2344e9d35e 100644 --- a/src/test/e2e/api/admin/user/pat.e2e.test.ts +++ b/src/test/e2e/api/admin/user/pat.e2e.test.ts @@ -31,6 +31,7 @@ beforeAll(async () => { afterAll(async () => { getLogger.setMuteError(false); await app.destroy(); + await db.destroy(); }); test('should create a PAT', async () => { diff --git a/src/test/e2e/api/auth/simple-password-provider.e2e.test.ts b/src/test/e2e/api/auth/simple-password-provider.e2e.test.ts index 6f2c6ce8ca..c835253008 100644 --- a/src/test/e2e/api/auth/simple-password-provider.e2e.test.ts +++ b/src/test/e2e/api/auth/simple-password-provider.e2e.test.ts @@ -61,7 +61,7 @@ beforeEach(async () => { }); }); -afterAll(async () => { +afterEach(async () => { await app.destroy(); await db.destroy(); }); diff --git a/src/test/e2e/custom-auth.test.ts b/src/test/e2e/custom-auth.test.ts index d8f9594488..9676b4d96a 100644 --- a/src/test/e2e/custom-auth.test.ts +++ b/src/test/e2e/custom-auth.test.ts @@ -21,6 +21,10 @@ beforeAll(async () => { stores = db.stores; }); +afterAll(async () => { + await db.destroy(); +}); + test('Using custom auth type without defining custom middleware causes default DENY ALL policy to take effect', async () => { jest.spyOn(global.console, 'error').mockImplementation(() => jest.fn()); const { request, destroy } = await setupAppWithCustomAuth( diff --git a/src/test/e2e/helpers/test-helper.ts b/src/test/e2e/helpers/test-helper.ts index 6ef7896881..81ee8f4141 100644 --- a/src/test/e2e/helpers/test-helper.ts +++ b/src/test/e2e/helpers/test-helper.ts @@ -216,10 +216,14 @@ async function createApp( const request = supertest.agent(app); const destroy = async () => { - services.versionService.destroy(); - services.clientInstanceService.destroy(); - services.clientMetricsServiceV2.destroy(); - services.proxyService.destroy(); + // iterate on the keys of services and if the services at that key has a function called destroy then call it + await Promise.all( + Object.keys(services).map(async (key) => { + if (services[key].destroy) { + await services[key].destroy(); + } + }), + ); }; // TODO: use create from server-impl instead?