fix(integration): setup (#5511)

* fix(integration): setup
This commit is contained in:
Adrien de Peretti
2023-11-01 13:56:12 -04:00
committed by GitHub
parent 4692f54b49
commit 80fe362f33
45 changed files with 461 additions and 405 deletions
@@ -1,8 +1,13 @@
const path = require("path")
const { bootstrapApp } = require("../../../environment-helpers/bootstrap-app")
const {
startBootstrapApp,
} = require("../../../environment-helpers/bootstrap-app")
const { initDb, useDb } = require("../../../environment-helpers/use-db")
const { setPort, useApi } = require("../../../environment-helpers/use-api")
const {
useApi,
useExpressServer,
} = require("../../../environment-helpers/use-api")
const adminSeeder = require("../../../helpers/admin-seeder")
@@ -14,11 +19,12 @@ const {
simpleProductFactory,
simpleShippingOptionFactory,
} = require("../../../factories")
const { getContainer } = require("../../../environment-helpers/use-container")
describe("medusa-plugin-sendgrid", () => {
let appContainer
let dbConnection
let express
let shutdownServer
const doAfterEach = async () => {
const db = useDb()
@@ -28,19 +34,14 @@ describe("medusa-plugin-sendgrid", () => {
beforeAll(async () => {
const cwd = path.resolve(path.join(__dirname, "..", ".."))
dbConnection = await initDb({ cwd })
const { container, app, port } = await bootstrapApp({ cwd })
appContainer = container
setPort(port)
express = app.listen(port, (err) => {
process.send(port)
})
shutdownServer = await startBootstrapApp({ cwd })
appContainer = getContainer()
})
afterAll(async () => {
const db = useDb()
await db.shutdown()
express.close()
await shutdownServer()
})
afterEach(async () => {