Skip to content

Commit 7b16bdc

Browse files
committed
test: copy over db instead of cleanup
1 parent 0d44092 commit 7b16bdc

File tree

1 file changed

+4
-9
lines changed

1 file changed

+4
-9
lines changed

tests/setup/db-setup.ts

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,19 @@
11
import path from 'node:path'
22
import fsExtra from 'fs-extra'
3-
import { afterAll, afterEach, beforeAll } from 'vitest'
4-
import { cleanupDb } from '#tests/db-utils.ts'
3+
import { afterAll, beforeEach } from 'vitest'
54
import { BASE_DATABASE_PATH } from './global-setup.ts'
65

76
const databaseFile = `./tests/prisma/data.${process.env.VITEST_POOL_ID || 0}.db`
87
const databasePath = path.join(process.cwd(), databaseFile)
98
process.env.DATABASE_URL = `file:${databasePath}`
109

11-
beforeAll(async () => {
10+
beforeEach(async () => {
1211
await fsExtra.copyFile(BASE_DATABASE_PATH, databasePath)
1312
})
1413

15-
// we *must* use dynamic imports here so the process.env.DATABASE_URL is set
16-
// before prisma is imported and initialized
17-
afterEach(async () => {
18-
await cleanupDb()
19-
})
20-
2114
afterAll(async () => {
15+
// we *must* use dynamic imports here so the process.env.DATABASE_URL is set
16+
// before prisma is imported and initialized
2217
const { prisma } = await import('#app/utils/db.server.ts')
2318
await prisma.$disconnect()
2419
await fsExtra.remove(databasePath)

0 commit comments

Comments
 (0)