From 8e7de6dd369166320e47aa5c1f4bb5ffbfae94bc Mon Sep 17 00:00:00 2001 From: Zakaria El Asri <33696020+zakariaelas@users.noreply.github.com> Date: Wed, 9 Mar 2022 17:20:18 +0100 Subject: [PATCH] fix: make sure @medusajs/medusa is loaded correctly regardless of integration test suite being run (#1166) --- integration-tests/api/jest.config.js | 1 + integration-tests/globalSetup.js | 3 ++- integration-tests/helpers/use-template-db.js | 5 ++--- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/integration-tests/api/jest.config.js b/integration-tests/api/jest.config.js index 69e2c815ba..97bb1752d6 100644 --- a/integration-tests/api/jest.config.js +++ b/integration-tests/api/jest.config.js @@ -1,4 +1,5 @@ // API +process.chdir(__dirname) module.exports = { name: "api", diff --git a/integration-tests/globalSetup.js b/integration-tests/globalSetup.js index 947a9e9cae..a7f0bd0474 100644 --- a/integration-tests/globalSetup.js +++ b/integration-tests/globalSetup.js @@ -1,5 +1,6 @@ const dbFactory = require("./helpers/use-template-db") +const path = require("path") module.exports = async () => { - await dbFactory.createTemplateDb_() + await dbFactory.createTemplateDb_({ cwd: path.resolve(".") }) } diff --git a/integration-tests/helpers/use-template-db.js b/integration-tests/helpers/use-template-db.js index e9befaa482..e5c77a2b6d 100644 --- a/integration-tests/helpers/use-template-db.js +++ b/integration-tests/helpers/use-template-db.js @@ -20,14 +20,13 @@ class DatabaseFactory { this.templateDbName = "medusa-integration-template" } - async createTemplateDb_() { + async createTemplateDb_({ cwd }) { try { - const cwd = path.resolve(path.join(__dirname, "..")) + // const cwd = path.resolve(path.join(__dirname, "..")) const connection = await this.getMasterConnection() const migrationDir = path.resolve( path.join( cwd, - "api", `node_modules`, `@medusajs`, `medusa`,