Raw
1 import { dropDatabase } from "./medusa-test-runner-utils/postgres-template"
2
3 export function afterAllHookDropDatabase() {
4 const DB_HOST = process.env.DB_HOST ?? "localhost"
5 const DB_USERNAME = process.env.DB_USERNAME ?? "postgres"
6 const DB_PASSWORD = process.env.DB_PASSWORD ?? ""
7 const DB_NAME = process.env.DB_TEMP_NAME || ""
8
9 const databaseCredentials = {
10 user: DB_USERNAME,
11 password: DB_PASSWORD,
12 host: DB_HOST,
13 }
14
15 afterAll(async () => {
16 try {
17 await dropDatabase({ databaseName: DB_NAME }, databaseCredentials)
18 } catch (e) {
19 console.error(
20 `This might fail if it is run during the unit tests since there is no database to drop. Otherwise, please check what is the issue. ${e.message}`
21 )
22 }
23 })
24 }