refactor(api): clean up test dbs when tests finish (#63149)

This commit is contained in:
Oliver Eyton-Williams
2025-10-28 22:14:56 +01:00
committed by GitHub
parent 77ea476f12
commit ae0a140c0c
3 changed files with 16 additions and 1 deletions

View File

@@ -40,6 +40,7 @@ describe('dev login', () => {
await fastify.prisma.user.deleteMany({
where: { email: defaultUserEmail }
});
await fastify.prisma.$runCommandRaw({ dropDatabase: 1 });
await fastify.close();
});

View File

@@ -43,6 +43,7 @@ describe('auth0 plugin', () => {
});
afterAll(async () => {
await fastify.prisma.$runCommandRaw({ dropDatabase: 1 });
await fastify.close();
});

View File

@@ -1,4 +1,12 @@
import { describe, test, expect, beforeAll, afterEach, vi } from 'vitest';
import {
describe,
test,
expect,
beforeAll,
afterEach,
afterAll,
vi
} from 'vitest';
import Fastify, { FastifyInstance } from 'fastify';
import db from '../../db/prisma.js';
@@ -24,6 +32,11 @@ describe('findOrCreateUser', () => {
fastify = await setupServer();
});
afterAll(async () => {
await fastify.prisma.$runCommandRaw({ dropDatabase: 1 });
await fastify.close();
});
afterEach(async () => {
await fastify.prisma.user.deleteMany({ where: { email } });
await fastify.close();