diff --git a/src/scripts/integration-tests.ts b/src/scripts/integration-tests.ts index 740b58e1f8..195212ee74 100644 --- a/src/scripts/integration-tests.ts +++ b/src/scripts/integration-tests.ts @@ -14,11 +14,10 @@ async function main() { execSync('yarn prebuild:scripts', { stdio: 'inherit' }); execSync('yarn build:esbuild', { stdio: 'inherit' }); - const result = execSync('vitest run --config vitest.integration.config.ts', { + execSync('vitest run --config vitest.integration.config.ts', { stdio: 'inherit', encoding: 'utf-8' }); - console.log(result.toString()); } catch (err) { throw new Error(err as any); } finally { diff --git a/tests/integration/setup.ts b/tests/integration/setup.ts index 8617aef368..8de59d7589 100644 --- a/tests/integration/setup.ts +++ b/tests/integration/setup.ts @@ -1,6 +1,8 @@ import '../globalSetup'; -import { vi } from 'vitest'; +import { beforeAll, beforeEach, vi } from 'vitest'; + +import { prisma } from '../../src/lib/settings/prisma'; vi.mock('../../src/lib/util/handleMahojiConfirmation', () => ({ handleMahojiConfirmation: vi.fn() @@ -26,3 +28,16 @@ globalClient.fetchUser = async (id: string | bigint) => ({ id: typeof id === 'string' ? id : String(id), send: async () => {} }); + +beforeAll(async () => { + console.log( + await prisma.$queryRawUnsafe(`SELECT pg_terminate_backend(pid) +FROM pg_stat_activity +WHERE state = 'idle' + AND pid <> pg_backend_pid();`) + ); +}); + +beforeEach(async () => { + console.log(await prisma.$queryRawUnsafe('SELECT COUNT(*) FROM pg_stat_activity;')); +});