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
@@ -3,20 +3,9 @@ const { spawn } = require("child_process")
const { setPort, useExpressServer } = require("./use-api")
const { setContainer } = require("./use-container")
module.exports = ({
cwd,
redisUrl,
uploadDir,
verbose,
env,
bootstrapApp = false,
}) => {
module.exports = async ({ cwd, redisUrl, uploadDir, verbose, env }) => {
const serverPath = path.join(__dirname, "test-server.js")
if (bootstrapApp) {
require(serverPath)
}
// in order to prevent conflicts in redis, use a different db for each worker
// same fix as for databases (works with up to 15)
// redis dbs are 0-indexed and jest worker ids are indexed from 1
@@ -25,7 +14,7 @@ module.exports = ({
verbose = verbose ?? false
return new Promise((resolve, reject) => {
return await new Promise((resolve, reject) => {
const medusaProcess = spawn("node", [path.resolve(serverPath)], {
cwd,
env: {
@@ -44,11 +33,13 @@ module.exports = ({
medusaProcess.on("error", (err) => {
console.log(err)
reject(err)
process.exit()
})
medusaProcess.on("uncaughtException", (err) => {
console.log(err)
reject(err)
medusaProcess.kill()
})