mirror of
https://github.com/freeCodeCamp/freeCodeCamp.git
synced 2025-12-29 09:01:04 -05:00
refactor(api): clean up test dbs when tests finish (#63149)
This commit is contained in:
committed by
GitHub
parent
77ea476f12
commit
ae0a140c0c
@@ -40,6 +40,7 @@ describe('dev login', () => {
|
||||
await fastify.prisma.user.deleteMany({
|
||||
where: { email: defaultUserEmail }
|
||||
});
|
||||
await fastify.prisma.$runCommandRaw({ dropDatabase: 1 });
|
||||
await fastify.close();
|
||||
});
|
||||
|
||||
|
||||
@@ -43,6 +43,7 @@ describe('auth0 plugin', () => {
|
||||
});
|
||||
|
||||
afterAll(async () => {
|
||||
await fastify.prisma.$runCommandRaw({ dropDatabase: 1 });
|
||||
await fastify.close();
|
||||
});
|
||||
|
||||
|
||||
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user