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,10 +1,13 @@
const path = require("path")
const {
bootstrapApp,
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")
@@ -16,12 +19,15 @@ const {
simpleRegionFactory,
} = require("../../../../factories")
const { simpleSalesChannelFactory } = require("../../../../factories")
const {
getContainer,
} = require("../../../../environment-helpers/use-container")
const adminHeaders = { headers: { "x-medusa-access-token": "test_token" } }
describe("Inventory Items endpoints", () => {
let appContainer
let dbConnection
let express
let shutdownServer
let inventoryItem
let locationId
@@ -41,13 +47,14 @@ describe("Inventory Items endpoints", () => {
beforeAll(async () => {
const cwd = path.resolve(path.join(__dirname, "..", "..", ".."))
dbConnection = await initDb({ cwd })
const { container, app, port } = await bootstrapApp({ cwd })
appContainer = container
shutdownServer = await startBootstrapApp({ cwd })
appContainer = getContainer()
})
setPort(port)
express = app.listen(port, (err) => {
process.send(port)
})
afterAll(async () => {
const db = useDb()
await db.shutdown()
await shutdownServer()
})
beforeEach(async () => {
@@ -138,12 +145,6 @@ describe("Inventory Items endpoints", () => {
})
})
afterAll(async () => {
const db = useDb()
await db.shutdown()
express.close()
})
afterEach(async () => {
jest.clearAllMocks()
const db = useDb()