@medusajs/test-utils 3.0.0-snapshot-20250410112222 → 3.0.0-snapshot-20251104004624
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/database.d.ts +1 -1
- package/dist/database.d.ts.map +1 -1
- package/dist/database.js +121 -39
- package/dist/database.js.map +1 -1
- package/dist/events.d.ts +15 -3
- package/dist/events.d.ts.map +1 -1
- package/dist/events.js +120 -21
- package/dist/events.js.map +1 -1
- package/dist/index.js +17 -7
- package/dist/index.js.map +1 -1
- package/dist/init-modules.d.ts +2 -1
- package/dist/init-modules.d.ts.map +1 -1
- package/dist/init-modules.js +10 -8
- package/dist/init-modules.js.map +1 -1
- package/dist/medusa-test-runner-utils/bootstrap-app.d.ts.map +1 -1
- package/dist/medusa-test-runner-utils/bootstrap-app.js +94 -40
- package/dist/medusa-test-runner-utils/bootstrap-app.js.map +1 -1
- package/dist/medusa-test-runner-utils/config.d.ts.map +1 -1
- package/dist/medusa-test-runner-utils/config.js +6 -0
- package/dist/medusa-test-runner-utils/config.js.map +1 -1
- package/dist/medusa-test-runner-utils/use-db.d.ts +2 -2
- package/dist/medusa-test-runner-utils/use-db.d.ts.map +1 -1
- package/dist/medusa-test-runner-utils/use-db.js +9 -8
- package/dist/medusa-test-runner-utils/use-db.js.map +1 -1
- package/dist/medusa-test-runner-utils/utils.d.ts +8 -0
- package/dist/medusa-test-runner-utils/utils.d.ts.map +1 -1
- package/dist/medusa-test-runner-utils/utils.js +15 -0
- package/dist/medusa-test-runner-utils/utils.js.map +1 -1
- package/dist/medusa-test-runner-utils/wait-workflow-executions.d.ts +9 -0
- package/dist/medusa-test-runner-utils/wait-workflow-executions.d.ts.map +1 -0
- package/dist/medusa-test-runner-utils/wait-workflow-executions.js +34 -0
- package/dist/medusa-test-runner-utils/wait-workflow-executions.js.map +1 -0
- package/dist/medusa-test-runner.d.ts +22 -1
- package/dist/medusa-test-runner.d.ts.map +1 -1
- package/dist/medusa-test-runner.js +220 -95
- package/dist/medusa-test-runner.js.map +1 -1
- package/dist/module-test-runner.d.ts +21 -1
- package/dist/module-test-runner.d.ts.map +1 -1
- package/dist/module-test-runner.js +231 -85
- package/dist/module-test-runner.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +10 -22
|
@@ -4,56 +4,110 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.startApp = startApp;
|
|
7
|
+
const logger_1 = require("@medusajs/framework/logger");
|
|
8
|
+
const utils_1 = require("@medusajs/framework/utils");
|
|
7
9
|
const express_1 = __importDefault(require("express"));
|
|
8
10
|
const get_port_1 = __importDefault(require("get-port"));
|
|
9
11
|
const path_1 = require("path");
|
|
10
|
-
const
|
|
11
|
-
const utils_2 = require("@medusajs/framework/utils");
|
|
12
|
+
const utils_2 = require("./utils");
|
|
12
13
|
async function bootstrapApp({ cwd, env = {}, } = {}) {
|
|
13
14
|
const app = (0, express_1.default)();
|
|
14
|
-
(0,
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
expressApp: app,
|
|
15
|
+
(0, utils_2.applyEnvVarsToProcess)(env);
|
|
16
|
+
// Register a health check endpoint
|
|
17
|
+
app.get("/health", (_, res) => {
|
|
18
|
+
res.status(200).send("OK");
|
|
19
19
|
});
|
|
20
|
-
const
|
|
21
|
-
|
|
22
|
-
shutdown
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
20
|
+
const loaders = require("@medusajs/medusa/loaders/index").default;
|
|
21
|
+
try {
|
|
22
|
+
const { container, shutdown } = await loaders({
|
|
23
|
+
directory: (0, path_1.resolve)(cwd || process.cwd()),
|
|
24
|
+
expressApp: app,
|
|
25
|
+
});
|
|
26
|
+
const PORT = process.env.PORT ? parseInt(process.env.PORT) : await (0, get_port_1.default)();
|
|
27
|
+
return {
|
|
28
|
+
shutdown,
|
|
29
|
+
container,
|
|
30
|
+
app,
|
|
31
|
+
port: PORT,
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
catch (error) {
|
|
35
|
+
logger_1.logger.error("Error bootstrapping app:", error);
|
|
36
|
+
throw error;
|
|
37
|
+
}
|
|
27
38
|
}
|
|
28
39
|
async function startApp({ cwd, env = {}, } = {}) {
|
|
29
|
-
const { app, port, container, shutdown: medusaShutdown, } = await bootstrapApp({
|
|
30
|
-
cwd,
|
|
31
|
-
env,
|
|
32
|
-
});
|
|
33
40
|
let expressServer;
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
41
|
+
let medusaShutdown = async () => void 0;
|
|
42
|
+
let container;
|
|
43
|
+
try {
|
|
44
|
+
const { app, port, container: appContainer, shutdown: appShutdown, } = await bootstrapApp({
|
|
45
|
+
cwd,
|
|
46
|
+
env,
|
|
47
|
+
});
|
|
48
|
+
container = appContainer;
|
|
49
|
+
medusaShutdown = appShutdown;
|
|
50
|
+
const shutdown = async () => {
|
|
51
|
+
try {
|
|
52
|
+
const shutdownPromise = (0, utils_1.promiseAll)([
|
|
53
|
+
expressServer?.shutdown(),
|
|
54
|
+
medusaShutdown(),
|
|
55
|
+
]);
|
|
56
|
+
await (0, utils_2.execOrTimeout)(shutdownPromise);
|
|
57
|
+
if (typeof global !== "undefined" && global?.gc) {
|
|
58
|
+
global.gc();
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
catch (error) {
|
|
62
|
+
logger_1.logger.error("Error during shutdown:", error);
|
|
63
|
+
try {
|
|
64
|
+
await expressServer?.shutdown();
|
|
65
|
+
await medusaShutdown();
|
|
66
|
+
}
|
|
67
|
+
catch (cleanupError) {
|
|
68
|
+
logger_1.logger.error("Error during forced cleanup:", cleanupError);
|
|
69
|
+
}
|
|
70
|
+
throw error;
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
return await new Promise((resolve, reject) => {
|
|
74
|
+
const server = app
|
|
75
|
+
.listen(port)
|
|
76
|
+
.on("error", async (err) => {
|
|
77
|
+
logger_1.logger.error("Error starting server:", err);
|
|
78
|
+
await shutdown();
|
|
79
|
+
return reject(err);
|
|
80
|
+
})
|
|
81
|
+
.on("listening", () => {
|
|
82
|
+
process.send?.(port);
|
|
83
|
+
resolve({
|
|
84
|
+
shutdown,
|
|
85
|
+
container,
|
|
86
|
+
port,
|
|
87
|
+
});
|
|
53
88
|
});
|
|
89
|
+
expressServer = utils_1.GracefulShutdownServer.create(server);
|
|
54
90
|
});
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
91
|
+
}
|
|
92
|
+
catch (error) {
|
|
93
|
+
logger_1.logger.error("Error in startApp:", error);
|
|
94
|
+
if (expressServer) {
|
|
95
|
+
try {
|
|
96
|
+
await expressServer.shutdown();
|
|
97
|
+
}
|
|
98
|
+
catch (cleanupError) {
|
|
99
|
+
logger_1.logger.error("Error cleaning up express server:", cleanupError);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
if (medusaShutdown) {
|
|
103
|
+
try {
|
|
104
|
+
await medusaShutdown();
|
|
105
|
+
}
|
|
106
|
+
catch (cleanupError) {
|
|
107
|
+
logger_1.logger.error("Error cleaning up medusa:", cleanupError);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
throw error;
|
|
111
|
+
}
|
|
58
112
|
}
|
|
59
113
|
//# sourceMappingURL=bootstrap-app.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bootstrap-app.js","sourceRoot":"","sources":["../../src/medusa-test-runner-utils/bootstrap-app.ts"],"names":[],"mappings":";;;;;
|
|
1
|
+
{"version":3,"file":"bootstrap-app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"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/medusa-test-runner-utils/config.ts"],"names":[],"mappings":"AAMA,wBAAsB,oBAAoB,CACxC,cAAc,EAAE,MAAM,EACtB,QAAQ,EAAE;IAAE,SAAS,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,OAAO,CAAA;CAAE,iBAwCjD"}
|
|
@@ -5,6 +5,12 @@ const utils_1 = require("@medusajs/framework/utils");
|
|
|
5
5
|
async function configLoaderOverride(entryDirectory, override) {
|
|
6
6
|
const { configManager } = await import("@medusajs/framework/config");
|
|
7
7
|
const { logger } = await import("@medusajs/framework");
|
|
8
|
+
await (0, utils_1.discoverAndRegisterFeatureFlags)({
|
|
9
|
+
flagDir: entryDirectory,
|
|
10
|
+
projectConfigFlags: {},
|
|
11
|
+
router: utils_1.FeatureFlag,
|
|
12
|
+
logger,
|
|
13
|
+
});
|
|
8
14
|
const { configModule, error } = await (0, utils_1.getConfigFile)(entryDirectory, "medusa-config");
|
|
9
15
|
if (error) {
|
|
10
16
|
throw new Error(error.message || "Error during config loading");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/medusa-test-runner-utils/config.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/medusa-test-runner-utils/config.ts"],"names":[],"mappings":";;AAMA,oDA0CC;AAhDD,qDAIkC;AAE3B,KAAK,UAAU,oBAAoB,CACxC,cAAsB,EACtB,QAAgD;IAEhD,MAAM,EAAE,aAAa,EAAE,GAAG,MAAM,MAAM,CAAC,4BAA4B,CAAC,CAAA;IACpE,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM,MAAM,CAAC,qBAAqB,CAAC,CAAA;IAEtD,MAAM,IAAA,uCAA+B,EAAC;QACpC,OAAO,EAAE,cAAc;QACvB,kBAAkB,EAAE,EAAE;QACtB,MAAM,EAAE,mBAAW;QACnB,MAAM;KACP,CAAC,CAAA;IAEF,MAAM,EAAE,YAAY,EAAE,KAAK,EAAE,GAAG,MAAM,IAAA,qBAAa,EAEjD,cAAc,EAAE,eAAe,CAAC,CAAA;IAElC,IAAI,KAAK,EAAE,CAAC;QACV,MAAM,IAAI,KAAK,CAAC,KAAK,CAAC,OAAO,IAAI,6BAA6B,CAAC,CAAA;IACjE,CAAC;IAED,YAAY,CAAC,aAAa,CAAC,qBAAqB,CAAA;IAChD,YAAY,CAAC,aAAa,CAAC,WAAW,GAAG,QAAQ,CAAC,SAAS,CAAA;IAC3D,YAAY,CAAC,aAAa,CAAC,eAAe,GAAG,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAA;IAC7D,YAAY,CAAC,aAAa,CAAC,qBAAqB;QAC9C,QAAQ,CAAC,SAAS,CAAC,QAAQ,CAAC,WAAW,CAAC;YACtC,CAAC,CAAC,EAAE;YACJ,CAAC,CAAC;gBACE,UAAU,EAAE;oBACV,GAAG,EAAE,EAAE,kBAAkB,EAAE,KAAK,EAAE;iBACnC;gBACD,mCAAmC,EAAE,KAAK;aAC3C,CAAA;IAEP,MAAM,CAAC,IAAI,CAAC,6CAA6C,CAAC,CAAA;IAC1D,MAAM,CAAC,MAAM,CAAC,YAAY,CAAC,KAAK,IAAI,EAAE,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAA;IAE1D,aAAa,CAAC,UAAU,CAAC;QACvB,aAAa,EAAE,YAAY;QAC3B,OAAO,EAAE,cAAc;KACxB,CAAC,CAAA;AACJ,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { MedusaAppLoader } from "@medusajs/framework";
|
|
2
|
-
import { MedusaContainer } from "@medusajs/framework/types";
|
|
2
|
+
import { Logger, MedusaContainer } from "@medusajs/framework/types";
|
|
3
3
|
/**
|
|
4
4
|
* Initiates the database connection
|
|
5
5
|
*/
|
|
@@ -11,5 +11,5 @@ export declare function migrateDatabase(appLoader: MedusaAppLoader): Promise<voi
|
|
|
11
11
|
/**
|
|
12
12
|
* Syncs links with the databse
|
|
13
13
|
*/
|
|
14
|
-
export declare function syncLinks(appLoader: MedusaAppLoader, directory: string, container: MedusaContainer): Promise<void>;
|
|
14
|
+
export declare function syncLinks(appLoader: MedusaAppLoader, directory: string, container: MedusaContainer, logger: Logger): Promise<void>;
|
|
15
15
|
//# sourceMappingURL=use-db.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-db.d.ts","sourceRoot":"","sources":["../../src/medusa-test-runner-utils/use-db.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAA;
|
|
1
|
+
{"version":3,"file":"use-db.d.ts","sourceRoot":"","sources":["../../src/medusa-test-runner-utils/use-db.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAA;AAE1D,OAAO,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAA;AAOnE;;GAEG;AACH,wBAAsB,MAAM,2CAM3B;AAED;;GAEG;AACH,wBAAsB,eAAe,CAAC,SAAS,EAAE,eAAe,iBAO/D;AAED;;GAEG;AACH,wBAAsB,SAAS,CAC7B,SAAS,EAAE,eAAe,EAC1B,SAAS,EAAE,MAAM,EACjB,SAAS,EAAE,eAAe,EAC1B,MAAM,EAAE,MAAM,iBAef"}
|
|
@@ -3,15 +3,15 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.initDb = initDb;
|
|
4
4
|
exports.migrateDatabase = migrateDatabase;
|
|
5
5
|
exports.syncLinks = syncLinks;
|
|
6
|
+
const logger_1 = require("@medusajs/framework/logger");
|
|
6
7
|
const utils_1 = require("@medusajs/framework/utils");
|
|
7
8
|
const path_1 = require("path");
|
|
8
9
|
/**
|
|
9
10
|
* Initiates the database connection
|
|
10
11
|
*/
|
|
11
12
|
async function initDb() {
|
|
12
|
-
const { pgConnectionLoader
|
|
13
|
-
const pgConnection = pgConnectionLoader();
|
|
14
|
-
await featureFlagsLoader();
|
|
13
|
+
const { pgConnectionLoader } = await import("@medusajs/framework");
|
|
14
|
+
const pgConnection = await pgConnectionLoader();
|
|
15
15
|
return pgConnection;
|
|
16
16
|
}
|
|
17
17
|
/**
|
|
@@ -22,25 +22,25 @@ async function migrateDatabase(appLoader) {
|
|
|
22
22
|
await appLoader.runModulesMigrations();
|
|
23
23
|
}
|
|
24
24
|
catch (err) {
|
|
25
|
-
|
|
25
|
+
logger_1.logger.error("Something went wrong while running the migrations");
|
|
26
26
|
throw err;
|
|
27
27
|
}
|
|
28
28
|
}
|
|
29
29
|
/**
|
|
30
30
|
* Syncs links with the databse
|
|
31
31
|
*/
|
|
32
|
-
async function syncLinks(appLoader, directory, container) {
|
|
32
|
+
async function syncLinks(appLoader, directory, container, logger) {
|
|
33
33
|
try {
|
|
34
34
|
await loadCustomLinks(directory, container);
|
|
35
35
|
const planner = await appLoader.getLinksExecutionPlanner();
|
|
36
36
|
const actionPlan = await planner.createPlan();
|
|
37
37
|
actionPlan.forEach((action) => {
|
|
38
|
-
|
|
38
|
+
logger.info(`Sync links: "${action.action}" ${action.tableName}`);
|
|
39
39
|
});
|
|
40
40
|
await planner.executePlan(actionPlan);
|
|
41
41
|
}
|
|
42
42
|
catch (err) {
|
|
43
|
-
|
|
43
|
+
logger.error("Something went wrong while syncing links");
|
|
44
44
|
throw err;
|
|
45
45
|
}
|
|
46
46
|
}
|
|
@@ -48,7 +48,8 @@ async function loadCustomLinks(directory, container) {
|
|
|
48
48
|
const configModule = container.resolve(utils_1.ContainerRegistrationKeys.CONFIG_MODULE);
|
|
49
49
|
const plugins = await (0, utils_1.getResolvedPlugins)(directory, configModule, true);
|
|
50
50
|
const linksSourcePaths = plugins.map((plugin) => (0, path_1.join)(plugin.resolve, "links"));
|
|
51
|
+
const logger = container.resolve(utils_1.ContainerRegistrationKeys.LOGGER);
|
|
51
52
|
const { LinkLoader } = await import("@medusajs/framework");
|
|
52
|
-
await new LinkLoader(linksSourcePaths).load();
|
|
53
|
+
await new LinkLoader(linksSourcePaths, logger).load();
|
|
53
54
|
}
|
|
54
55
|
//# sourceMappingURL=use-db.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-db.js","sourceRoot":"","sources":["../../src/medusa-test-runner-utils/use-db.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"use-db.js","sourceRoot":"","sources":["../../src/medusa-test-runner-utils/use-db.ts"],"names":[],"mappings":";;AAYA,wBAMC;AAKD,0CAOC;AAKD,8BAmBC;AArDD,uDAAmD;AAEnD,qDAGkC;AAClC,+BAA2B;AAE3B;;GAEG;AACI,KAAK,UAAU,MAAM;IAC1B,MAAM,EAAE,kBAAkB,EAAE,GAAG,MAAM,MAAM,CAAC,qBAAqB,CAAC,CAAA;IAElE,MAAM,YAAY,GAAG,MAAM,kBAAkB,EAAE,CAAA;IAE/C,OAAO,YAAY,CAAA;AACrB,CAAC;AAED;;GAEG;AACI,KAAK,UAAU,eAAe,CAAC,SAA0B;IAC9D,IAAI,CAAC;QACH,MAAM,SAAS,CAAC,oBAAoB,EAAE,CAAA;IACxC,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,eAAM,CAAC,KAAK,CAAC,mDAAmD,CAAC,CAAA;QACjE,MAAM,GAAG,CAAA;IACX,CAAC;AACH,CAAC;AAED;;GAEG;AACI,KAAK,UAAU,SAAS,CAC7B,SAA0B,EAC1B,SAAiB,EACjB,SAA0B,EAC1B,MAAc;IAEd,IAAI,CAAC;QACH,MAAM,eAAe,CAAC,SAAS,EAAE,SAAS,CAAC,CAAA;QAE3C,MAAM,OAAO,GAAG,MAAM,SAAS,CAAC,wBAAwB,EAAE,CAAA;QAC1D,MAAM,UAAU,GAAG,MAAM,OAAO,CAAC,UAAU,EAAE,CAAA;QAC7C,UAAU,CAAC,OAAO,CAAC,CAAC,MAAM,EAAE,EAAE;YAC5B,MAAM,CAAC,IAAI,CAAC,gBAAgB,MAAM,CAAC,MAAM,KAAK,MAAM,CAAC,SAAS,EAAE,CAAC,CAAA;QACnE,CAAC,CAAC,CAAA;QACF,MAAM,OAAO,CAAC,WAAW,CAAC,UAAU,CAAC,CAAA;IACvC,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,MAAM,CAAC,KAAK,CAAC,0CAA0C,CAAC,CAAA;QACxD,MAAM,GAAG,CAAA;IACX,CAAC;AACH,CAAC;AAED,KAAK,UAAU,eAAe,CAAC,SAAiB,EAAE,SAA0B;IAC1E,MAAM,YAAY,GAAG,SAAS,CAAC,OAAO,CACpC,iCAAyB,CAAC,aAAa,CACxC,CAAA;IACD,MAAM,OAAO,GAAG,MAAM,IAAA,0BAAkB,EAAC,SAAS,EAAE,YAAY,EAAE,IAAI,CAAC,CAAA;IACvE,MAAM,gBAAgB,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAC9C,IAAA,WAAI,EAAC,MAAM,CAAC,OAAO,EAAE,OAAO,CAAC,CAC9B,CAAA;IACD,MAAM,MAAM,GAAG,SAAS,CAAC,OAAO,CAAC,iCAAyB,CAAC,MAAM,CAAC,CAAA;IAElE,MAAM,EAAE,UAAU,EAAE,GAAG,MAAM,MAAM,CAAC,qBAAqB,CAAC,CAAA;IAC1D,MAAM,IAAI,UAAU,CAAC,gBAAgB,EAAE,MAAM,CAAC,CAAC,IAAI,EAAE,CAAA;AACvD,CAAC"}
|
|
@@ -1,2 +1,10 @@
|
|
|
1
1
|
export declare function applyEnvVarsToProcess(env?: Record<any, any>): void;
|
|
2
|
+
/**
|
|
3
|
+
* Execute a function and return a promise that resolves when the function
|
|
4
|
+
* resolves or rejects when the function rejects or the timeout is reached.
|
|
5
|
+
* @param fn - The function to execute.
|
|
6
|
+
* @param timeout - The timeout in milliseconds.
|
|
7
|
+
* @returns A promise that resolves when the function resolves or rejects when the function rejects or the timeout is reached.
|
|
8
|
+
*/
|
|
9
|
+
export declare function execOrTimeout(fn: Promise<any> | (() => Promise<void>), timeout?: number): Promise<any>;
|
|
2
10
|
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/medusa-test-runner-utils/utils.ts"],"names":[],"mappings":"AAEA,wBAAgB,qBAAqB,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC,GAAG,EAAE,GAAG,CAAC,QAI3D"}
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/medusa-test-runner-utils/utils.ts"],"names":[],"mappings":"AAEA,wBAAgB,qBAAqB,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC,GAAG,EAAE,GAAG,CAAC,QAI3D;AAED;;;;;;GAMG;AACH,wBAAsB,aAAa,CACjC,EAAE,EAAE,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC,EACxC,OAAO,GAAE,MAAa,gBASvB"}
|
|
@@ -1,10 +1,25 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.applyEnvVarsToProcess = applyEnvVarsToProcess;
|
|
4
|
+
exports.execOrTimeout = execOrTimeout;
|
|
4
5
|
const utils_1 = require("@medusajs/framework/utils");
|
|
5
6
|
function applyEnvVarsToProcess(env) {
|
|
6
7
|
if ((0, utils_1.isObject)(env)) {
|
|
7
8
|
Object.entries(env).forEach(([k, v]) => (process.env[k] = v));
|
|
8
9
|
}
|
|
9
10
|
}
|
|
11
|
+
/**
|
|
12
|
+
* Execute a function and return a promise that resolves when the function
|
|
13
|
+
* resolves or rejects when the function rejects or the timeout is reached.
|
|
14
|
+
* @param fn - The function to execute.
|
|
15
|
+
* @param timeout - The timeout in milliseconds.
|
|
16
|
+
* @returns A promise that resolves when the function resolves or rejects when the function rejects or the timeout is reached.
|
|
17
|
+
*/
|
|
18
|
+
async function execOrTimeout(fn, timeout = 5000) {
|
|
19
|
+
const timeoutPromise = new Promise((_, reject) => {
|
|
20
|
+
setTimeout(() => reject(new Error("Timeout")), timeout).unref();
|
|
21
|
+
});
|
|
22
|
+
const fnPromise = typeof fn === "function" ? fn() : fn;
|
|
23
|
+
return Promise.race([fnPromise, timeoutPromise]);
|
|
24
|
+
}
|
|
10
25
|
//# sourceMappingURL=utils.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/medusa-test-runner-utils/utils.ts"],"names":[],"mappings":";;AAEA,sDAIC;
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/medusa-test-runner-utils/utils.ts"],"names":[],"mappings":";;AAEA,sDAIC;AASD,sCAWC;AA1BD,qDAAoD;AAEpD,SAAgB,qBAAqB,CAAC,GAAsB;IAC1D,IAAI,IAAA,gBAAQ,EAAC,GAAG,CAAC,EAAE,CAAC;QAClB,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAA;IAC/D,CAAC;AACH,CAAC;AAED;;;;;;GAMG;AACI,KAAK,UAAU,aAAa,CACjC,EAAwC,EACxC,UAAkB,IAAI;IAEtB,MAAM,cAAc,GAAG,IAAI,OAAO,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,EAAE;QAC/C,UAAU,CAAC,GAAG,EAAE,CAAC,MAAM,CAAC,IAAI,KAAK,CAAC,SAAS,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC,KAAK,EAAE,CAAA;IACjE,CAAC,CAAC,CAAA;IAEF,MAAM,SAAS,GAAG,OAAO,EAAE,KAAK,UAAU,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAA;IAEtD,OAAO,OAAO,CAAC,IAAI,CAAC,CAAC,SAAS,EAAE,cAAc,CAAC,CAAC,CAAA;AAClD,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { MedusaContainer } from "@medusajs/framework/types";
|
|
2
|
+
/**
|
|
3
|
+
* Waits for all workflow executions to finish. When relying on workflows but not necessarily
|
|
4
|
+
* waiting for them to finish, this can be used to ensure that a test is not considered done while background executions are still running and can interfere with the other tests.
|
|
5
|
+
* @param container - The container instance.
|
|
6
|
+
* @returns A promise that resolves when all workflow executions have finished.
|
|
7
|
+
*/
|
|
8
|
+
export declare function waitWorkflowExecutions(container: MedusaContainer): Promise<void>;
|
|
9
|
+
//# sourceMappingURL=wait-workflow-executions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wait-workflow-executions.d.ts","sourceRoot":"","sources":["../../src/medusa-test-runner-utils/wait-workflow-executions.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAA;AAE3D;;;;;GAKG;AACH,wBAAsB,sBAAsB,CAAC,SAAS,EAAE,eAAe,iBAyBtE"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.waitWorkflowExecutions = waitWorkflowExecutions;
|
|
4
|
+
const utils_1 = require("@medusajs/framework/utils");
|
|
5
|
+
/**
|
|
6
|
+
* Waits for all workflow executions to finish. When relying on workflows but not necessarily
|
|
7
|
+
* waiting for them to finish, this can be used to ensure that a test is not considered done while background executions are still running and can interfere with the other tests.
|
|
8
|
+
* @param container - The container instance.
|
|
9
|
+
* @returns A promise that resolves when all workflow executions have finished.
|
|
10
|
+
*/
|
|
11
|
+
async function waitWorkflowExecutions(container) {
|
|
12
|
+
const wfe = container.resolve(utils_1.Modules.WORKFLOW_ENGINE, {
|
|
13
|
+
allowUnregistered: true,
|
|
14
|
+
});
|
|
15
|
+
if (!wfe) {
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
const timeout = setTimeout(() => {
|
|
19
|
+
throw new Error("Timeout waiting for workflow executions to finish");
|
|
20
|
+
}, 60000).unref();
|
|
21
|
+
let waitWorkflowsToFinish = true;
|
|
22
|
+
while (waitWorkflowsToFinish) {
|
|
23
|
+
const executions = await wfe.listWorkflowExecutions({
|
|
24
|
+
state: { $nin: ["not_started", "done", "reverted", "failed"] },
|
|
25
|
+
});
|
|
26
|
+
if (executions.length === 0) {
|
|
27
|
+
waitWorkflowsToFinish = false;
|
|
28
|
+
clearTimeout(timeout);
|
|
29
|
+
break;
|
|
30
|
+
}
|
|
31
|
+
await new Promise((resolve) => setTimeout(resolve, 50));
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingURL=wait-workflow-executions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wait-workflow-executions.js","sourceRoot":"","sources":["../../src/medusa-test-runner-utils/wait-workflow-executions.ts"],"names":[],"mappings":";;AASA,wDAyBC;AAlCD,qDAAmD;AAGnD;;;;;GAKG;AACI,KAAK,UAAU,sBAAsB,CAAC,SAA0B;IACrE,MAAM,GAAG,GAAG,SAAS,CAAC,OAAO,CAAC,eAAO,CAAC,eAAe,EAAE;QACrD,iBAAiB,EAAE,IAAI;KACxB,CAAC,CAAA;IACF,IAAI,CAAC,GAAG,EAAE,CAAC;QACT,OAAM;IACR,CAAC;IAED,MAAM,OAAO,GAAG,UAAU,CAAC,GAAG,EAAE;QAC9B,MAAM,IAAI,KAAK,CAAC,mDAAmD,CAAC,CAAA;IACtE,CAAC,EAAE,KAAK,CAAC,CAAC,KAAK,EAAE,CAAA;IAEjB,IAAI,qBAAqB,GAAG,IAAI,CAAA;IAChC,OAAO,qBAAqB,EAAE,CAAC;QAC7B,MAAM,UAAU,GAAG,MAAM,GAAG,CAAC,sBAAsB,CAAC;YAClD,KAAK,EAAE,EAAE,IAAI,EAAE,CAAC,aAAa,EAAE,MAAM,EAAE,UAAU,EAAE,QAAQ,CAAC,EAAE;SAC/D,CAAC,CAAA;QAEF,IAAI,UAAU,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YAC5B,qBAAqB,GAAG,KAAK,CAAA;YAC7B,YAAY,CAAC,OAAO,CAAC,CAAA;YACrB,MAAK;QACP,CAAC;QACD,MAAM,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,CAAA;IACzD,CAAC;AACH,CAAC"}
|
|
@@ -17,8 +17,25 @@ export interface MedusaSuiteOptions {
|
|
|
17
17
|
clientUrl: string;
|
|
18
18
|
};
|
|
19
19
|
getMedusaApp: () => MedusaAppOutput;
|
|
20
|
+
utils: {
|
|
21
|
+
waitWorkflowExecutions: () => Promise<void>;
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
interface TestRunnerConfig {
|
|
25
|
+
moduleName?: string;
|
|
26
|
+
env?: Record<string, any>;
|
|
27
|
+
dbName?: string;
|
|
28
|
+
medusaConfigFile?: string;
|
|
29
|
+
disableAutoTeardown?: boolean;
|
|
30
|
+
schema?: string;
|
|
31
|
+
debug?: boolean;
|
|
32
|
+
inApp?: boolean;
|
|
33
|
+
hooks?: {
|
|
34
|
+
beforeServerStart?: (container: MedusaContainer) => Promise<void>;
|
|
35
|
+
};
|
|
36
|
+
cwd?: string;
|
|
20
37
|
}
|
|
21
|
-
export declare function medusaIntegrationTestRunner({ moduleName, dbName, medusaConfigFile, schema, env, debug, inApp, testSuite, }: {
|
|
38
|
+
export declare function medusaIntegrationTestRunner({ moduleName, dbName, medusaConfigFile, schema, env, debug, inApp, testSuite, hooks, cwd, disableAutoTeardown, }: {
|
|
22
39
|
moduleName?: string;
|
|
23
40
|
env?: Record<string, any>;
|
|
24
41
|
dbName?: string;
|
|
@@ -27,5 +44,9 @@ export declare function medusaIntegrationTestRunner({ moduleName, dbName, medusa
|
|
|
27
44
|
debug?: boolean;
|
|
28
45
|
inApp?: boolean;
|
|
29
46
|
testSuite: (options: MedusaSuiteOptions) => void;
|
|
47
|
+
hooks?: TestRunnerConfig["hooks"];
|
|
48
|
+
cwd?: string;
|
|
49
|
+
disableAutoTeardown?: boolean;
|
|
30
50
|
}): void;
|
|
51
|
+
export {};
|
|
31
52
|
//# sourceMappingURL=medusa-test-runner.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"medusa-test-runner.d.ts","sourceRoot":"","sources":["../src/medusa-test-runner.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"medusa-test-runner.d.ts","sourceRoot":"","sources":["../src/medusa-test-runner.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,eAAe,EAAE,MAAM,iCAAiC,CAAA;AACjE,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAA;AAmB3D,MAAM,WAAW,kBAAkB;IACjC,YAAY,EAAE,GAAG,CAAA;IACjB,YAAY,EAAE,MAAM,eAAe,CAAA;IACnC,GAAG,EAAE,GAAG,CAAA;IACR,OAAO,EAAE;QACP,MAAM,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAA;QACzC,QAAQ,EAAE,CAAC,OAAO,EAAE;YAAE,MAAM,CAAC,EAAE,MAAM,CAAA;SAAE,KAAK,OAAO,CAAC,IAAI,CAAC,CAAA;QACzD,QAAQ,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAA;KAC5C,CAAA;IACD,QAAQ,EAAE;QACR,MAAM,EAAE,MAAM,CAAA;QACd,MAAM,EAAE,MAAM,CAAA;QACd,SAAS,EAAE,MAAM,CAAA;KAClB,CAAA;IACD,YAAY,EAAE,MAAM,eAAe,CAAA;IACnC,KAAK,EAAE;QACL,sBAAsB,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC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