Chore/integration tests modules utils (#6581)
new wrapper for medusa integration tests. for now it is only applied to the modules directory, but it could be used in the api integration tests or any other integrations that requires a db and a server up and running. It is not perfect, but I wanted to have something working and centralised before improving it, also avoiding too many conflicts with other prs
This commit is contained in:
committed by
GitHub
parent
a6736c7ee0
commit
51bb6f1e89
@@ -1,29 +1,27 @@
|
||||
import dbFactory from "./../../../environment-helpers/use-template-db"
|
||||
import { medusaIntegrationTestRunner } from "medusa-test-utils"
|
||||
|
||||
jest.setTimeout(30000)
|
||||
|
||||
describe("Standalone Modules", () => {
|
||||
beforeAll(async () => {
|
||||
const DB_HOST = process.env.DB_HOST
|
||||
const DB_USERNAME = process.env.DB_USERNAME
|
||||
const DB_PASSWORD = process.env.DB_PASSWORD
|
||||
const DB_NAME = process.env.DB_TEMP_NAME
|
||||
medusaIntegrationTestRunner({
|
||||
testSuite: ({ dbConnection }) => {
|
||||
describe("Standalone Modules", () => {
|
||||
beforeAll(async () => {
|
||||
process.env.POSTGRES_URL = dbConnection.manager.connection.options.url
|
||||
})
|
||||
|
||||
process.env.POSTGRES_URL = `postgres://${DB_USERNAME}:${DB_PASSWORD}@${DB_HOST}/${DB_NAME}`
|
||||
await dbFactory.createFromTemplate(DB_NAME)
|
||||
})
|
||||
afterAll(async () => {
|
||||
process.env.POSTGRES_URL = undefined
|
||||
})
|
||||
|
||||
afterAll(async () => {
|
||||
process.env.POSTGRES_URL = undefined
|
||||
})
|
||||
it("Should migrate database and initialize Product module using connection string from environment variable ", async function () {
|
||||
const { initialize, runMigrations } = require("@medusajs/product")
|
||||
await runMigrations()
|
||||
|
||||
it("Should migrate database and initialize Product module using connection string from environment variable ", async function () {
|
||||
const { initialize, runMigrations } = require("@medusajs/product")
|
||||
await runMigrations()
|
||||
const product = await initialize()
|
||||
const productList = await product.list()
|
||||
|
||||
const product = await initialize()
|
||||
const productList = await product.list()
|
||||
|
||||
expect(productList).toEqual(expect.arrayContaining([]))
|
||||
})
|
||||
expect(productList).toEqual(expect.arrayContaining([]))
|
||||
})
|
||||
})
|
||||
},
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user