fix: improves integration tests (#332)

* fix: improves integration tests

* fix: giftcard order with total 0

* fix: remove breaking eager
This commit is contained in:
Sebastian Rindom
2021-08-11 09:26:25 +02:00
committed by GitHub
parent 8edf8aacfa
commit 9a701ff229
23 changed files with 355 additions and 672 deletions
+4 -2
View File
@@ -3,7 +3,7 @@ const { spawn } = require("child_process");
const { setPort } = require("./use-api");
module.exports = ({ cwd }) => {
module.exports = ({ cwd, verbose }) => {
const serverPath = path.join(__dirname, "test-server.js");
return new Promise((resolve, reject) => {
@@ -15,7 +15,9 @@ module.exports = ({ cwd }) => {
JWT_SECRET: "test",
COOKIE_SECRET: "test",
},
stdio: ["ignore", "ignore", "inherit", "ipc"],
stdio: verbose
? ["inherit", "inherit", "inherit", "ipc"]
: ["ignore", "ignore", "ignore", "ipc"],
});
medusaProcess.on("uncaughtException", (err) => {
+28 -3
View File
@@ -12,6 +12,15 @@ const pgGodCredentials = {
password: DB_PASSWORD,
};
const keepTables = [
"staged_job",
"shipping_profile",
"fulfillment_provider",
"payment_provider",
"country",
"currency",
];
const DbTestUtil = {
db_: null,
@@ -19,13 +28,29 @@ const DbTestUtil = {
this.db_ = connection;
},
clear: function () {
return this.db_.synchronize(true);
clear: async function () {
this.db_.synchronize(true);
},
teardown: async function () {
const entities = this.db_.entityMetadatas;
const manager = this.db_.manager;
await manager.query(`SET session_replication_role = 'replica';`);
for (const entity of entities) {
if (keepTables.includes(entity.tableName)) {
continue;
}
await manager.query(`DELETE FROM "${entity.tableName}";`);
}
await manager.query(`SET session_replication_role = 'origin';`);
},
shutdown: async function () {
await this.db_.close();
return dropDatabase({ databaseName }, pgGodCredentials);
const databaseName = "medusa-integration";
return await dropDatabase({ databaseName }, pgGodCredentials);
},
};