medusa-test-utils 1.1.45-snapshot-20240607093839 → 1.1.45-snapshot-20240701122250
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/database.js +56 -142
- package/dist/database.js.map +1 -1
- package/dist/events.js +7 -54
- package/dist/events.js.map +1 -1
- package/dist/id-map.js +8 -13
- package/dist/id-map.js.map +1 -1
- package/dist/init-modules.js +37 -98
- package/dist/init-modules.js.map +1 -1
- package/dist/jest.js +14 -62
- package/dist/jest.js.map +1 -1
- package/dist/medusa-test-runner-utils/bootstrap-app.js +48 -141
- package/dist/medusa-test-runner-utils/bootstrap-app.js.map +1 -1
- package/dist/medusa-test-runner-utils/use-db.js +26 -99
- package/dist/medusa-test-runner-utils/use-db.js.map +1 -1
- package/dist/medusa-test-runner.d.ts +7 -0
- package/dist/medusa-test-runner.js +130 -290
- package/dist/medusa-test-runner.js.map +1 -1
- package/dist/mock-event-bus-service.d.ts +4 -4
- package/dist/mock-event-bus-service.js +13 -53
- package/dist/mock-event-bus-service.js.map +1 -1
- package/dist/module-test-runner.js +57 -128
- package/dist/module-test-runner.js.map +1 -1
- package/package.json +6 -6
@@ -1,162 +1,91 @@
|
|
1
1
|
"use strict";
|
2
|
-
var __assign = (this && this.__assign) || function () {
|
3
|
-
__assign = Object.assign || function(t) {
|
4
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
5
|
-
s = arguments[i];
|
6
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
7
|
-
t[p] = s[p];
|
8
|
-
}
|
9
|
-
return t;
|
10
|
-
};
|
11
|
-
return __assign.apply(this, arguments);
|
12
|
-
};
|
13
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
14
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
15
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
16
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
17
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
18
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
19
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
20
|
-
});
|
21
|
-
};
|
22
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
23
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
24
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
25
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
26
|
-
function step(op) {
|
27
|
-
if (f) throw new TypeError("Generator is already executing.");
|
28
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
29
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
30
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
31
|
-
switch (op[0]) {
|
32
|
-
case 0: case 1: t = op; break;
|
33
|
-
case 4: _.label++; return { value: op[1], done: false };
|
34
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
35
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
36
|
-
default:
|
37
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
38
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
39
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
40
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
41
|
-
if (t[2]) _.ops.pop();
|
42
|
-
_.trys.pop(); continue;
|
43
|
-
}
|
44
|
-
op = body.call(thisArg, _);
|
45
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
46
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
47
|
-
}
|
48
|
-
};
|
49
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
50
3
|
exports.moduleIntegrationTestRunner = void 0;
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
function moduleIntegrationTestRunner(
|
56
|
-
|
57
|
-
var _this = this;
|
58
|
-
var moduleName = _a.moduleName, moduleModels = _a.moduleModels, _d = _a.moduleOptions, moduleOptions = _d === void 0 ? {} : _d, _e = _a.joinerConfig, joinerConfig = _e === void 0 ? [] : _e, _f = _a.schema, schema = _f === void 0 ? "public" : _f, _g = _a.debug, debug = _g === void 0 ? false : _g, testSuite = _a.testSuite, resolve = _a.resolve, _h = _a.injectedDependencies, injectedDependencies = _h === void 0 ? {} : _h;
|
59
|
-
var moduleSdkImports = require("@medusajs/modules-sdk");
|
4
|
+
const utils_1 = require("@medusajs/utils");
|
5
|
+
const _1 = require(".");
|
6
|
+
const database_1 = require("./database");
|
7
|
+
const init_modules_1 = require("./init-modules");
|
8
|
+
function moduleIntegrationTestRunner({ moduleName, moduleModels, moduleOptions = {}, joinerConfig = [], schema = "public", debug = false, testSuite, resolve, injectedDependencies = {}, }) {
|
9
|
+
const moduleSdkImports = require("@medusajs/modules-sdk");
|
60
10
|
process.env.LOG_LEVEL = "error";
|
61
|
-
moduleModels
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
11
|
+
moduleModels ??= Object.values(require(`${process.cwd()}/src/models`));
|
12
|
+
moduleModels = (0, utils_1.toMikroOrmEntities)(moduleModels);
|
13
|
+
const tempName = parseInt(process.env.JEST_WORKER_ID || "1");
|
14
|
+
const dbName = `medusa-${moduleName.toLowerCase()}-integration-${tempName}`;
|
15
|
+
const dbConfig = {
|
66
16
|
clientUrl: (0, database_1.getDatabaseURL)(dbName),
|
67
|
-
schema
|
68
|
-
debug
|
17
|
+
schema,
|
18
|
+
debug,
|
69
19
|
};
|
70
20
|
// Use a unique connection for all the entire suite
|
71
|
-
|
72
|
-
|
21
|
+
const connection = utils_1.ModulesSdkUtils.createPgConnection(dbConfig);
|
22
|
+
const MikroOrmWrapper = (0, database_1.getMikroOrmWrapper)({
|
73
23
|
mikroOrmEntities: moduleModels,
|
74
24
|
clientUrl: dbConfig.clientUrl,
|
75
25
|
schema: dbConfig.schema,
|
76
26
|
});
|
77
|
-
|
78
|
-
|
27
|
+
const modulesConfig_ = {
|
28
|
+
[moduleName]: {
|
79
29
|
definition: moduleSdkImports.ModulesDefinition[moduleName],
|
80
|
-
resolve
|
81
|
-
options:
|
30
|
+
resolve,
|
31
|
+
options: {
|
32
|
+
database: dbConfig,
|
33
|
+
...moduleOptions,
|
34
|
+
},
|
35
|
+
},
|
36
|
+
};
|
37
|
+
const moduleOptions_ = {
|
38
|
+
injectedDependencies: {
|
39
|
+
[utils_1.ContainerRegistrationKeys.PG_CONNECTION]: connection,
|
40
|
+
eventBusModuleService: new _1.MockEventBusService(),
|
41
|
+
[utils_1.ContainerRegistrationKeys.LOGGER]: console,
|
42
|
+
...injectedDependencies,
|
82
43
|
},
|
83
|
-
_b);
|
84
|
-
var moduleOptions_ = {
|
85
|
-
injectedDependencies: __assign((_c = {}, _c[utils_1.ContainerRegistrationKeys.PG_CONNECTION] = connection, _c["eventBusModuleService"] = new _1.MockEventBusService(), _c[utils_1.ContainerRegistrationKeys.LOGGER] = console, _c), injectedDependencies),
|
86
44
|
modulesConfig: modulesConfig_,
|
87
45
|
databaseConfig: dbConfig,
|
88
|
-
joinerConfig
|
46
|
+
joinerConfig,
|
89
47
|
preventConnectionDestroyWarning: true,
|
90
48
|
};
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
MikroOrmWrapper
|
49
|
+
let shutdown;
|
50
|
+
let moduleService;
|
51
|
+
let medusaApp = {};
|
52
|
+
const options = {
|
53
|
+
MikroOrmWrapper,
|
96
54
|
medusaApp: new Proxy({}, {
|
97
|
-
get:
|
55
|
+
get: (target, prop) => {
|
98
56
|
return medusaApp[prop];
|
99
57
|
},
|
100
58
|
}),
|
101
59
|
service: new Proxy({}, {
|
102
|
-
get:
|
60
|
+
get: (target, prop) => {
|
103
61
|
return moduleService[prop];
|
104
62
|
},
|
105
63
|
}),
|
106
64
|
dbConfig: {
|
107
|
-
schema
|
65
|
+
schema,
|
108
66
|
clientUrl: dbConfig.clientUrl,
|
109
67
|
},
|
110
68
|
};
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
}
|
126
|
-
});
|
127
|
-
}); };
|
128
|
-
var afterEach_ = function () { return __awaiter(_this, void 0, void 0, function () {
|
129
|
-
return __generator(this, function (_a) {
|
130
|
-
switch (_a.label) {
|
131
|
-
case 0: return [4 /*yield*/, MikroOrmWrapper.clearDatabase()];
|
132
|
-
case 1:
|
133
|
-
_a.sent();
|
134
|
-
return [4 /*yield*/, shutdown()];
|
135
|
-
case 2:
|
136
|
-
_a.sent();
|
137
|
-
moduleService = {};
|
138
|
-
medusaApp = {};
|
139
|
-
return [2 /*return*/];
|
140
|
-
}
|
141
|
-
});
|
142
|
-
}); };
|
143
|
-
return describe("", function () {
|
69
|
+
const beforeEach_ = async () => {
|
70
|
+
await MikroOrmWrapper.setupDatabase();
|
71
|
+
const output = await (0, init_modules_1.initModules)(moduleOptions_);
|
72
|
+
shutdown = output.shutdown;
|
73
|
+
medusaApp = output.medusaApp;
|
74
|
+
moduleService = output.medusaApp.modules[moduleName];
|
75
|
+
};
|
76
|
+
const afterEach_ = async () => {
|
77
|
+
await MikroOrmWrapper.clearDatabase();
|
78
|
+
await shutdown();
|
79
|
+
moduleService = {};
|
80
|
+
medusaApp = {};
|
81
|
+
};
|
82
|
+
return describe("", () => {
|
144
83
|
beforeEach(beforeEach_);
|
145
84
|
afterEach(afterEach_);
|
146
|
-
afterAll(
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
case 0: return [4 /*yield*/, ((_a = connection.context) === null || _a === void 0 ? void 0 : _a.destroy())];
|
151
|
-
case 1:
|
152
|
-
_b.sent();
|
153
|
-
return [4 /*yield*/, connection.destroy()];
|
154
|
-
case 2:
|
155
|
-
_b.sent();
|
156
|
-
return [2 /*return*/];
|
157
|
-
}
|
158
|
-
});
|
159
|
-
}); });
|
85
|
+
afterAll(async () => {
|
86
|
+
await connection.context?.destroy();
|
87
|
+
await connection.destroy();
|
88
|
+
});
|
160
89
|
testSuite(options);
|
161
90
|
});
|
162
91
|
}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"module-test-runner.js","sourceRoot":"","sources":["../src/module-test-runner.ts"],"names":[],"mappings":"
|
1
|
+
{"version":3,"file":"module-test-runner.js","sourceRoot":"","sources":["../src/module-test-runner.ts"],"names":[],"mappings":";;;AAAA,2CAIwB;AACxB,wBAAuC;AACvC,yCAA6E;AAC7E,iDAAgE;AAYhE,SAAgB,2BAA2B,CAAiB,EAC1D,UAAU,EACV,YAAY,EACZ,aAAa,GAAG,EAAE,EAClB,YAAY,GAAG,EAAE,EACjB,MAAM,GAAG,QAAQ,EACjB,KAAK,GAAG,KAAK,EACb,SAAS,EACT,OAAO,EACP,oBAAoB,GAAG,EAAE,GAY1B;IACC,MAAM,gBAAgB,GAAG,OAAO,CAAC,uBAAuB,CAAC,CAAA;IAEzD,OAAO,CAAC,GAAG,CAAC,SAAS,GAAG,OAAO,CAAA;IAE/B,YAAY,KAAK,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC,GAAG,EAAE,aAAa,CAAC,CAAC,CAAA;IACtE,YAAY,GAAG,IAAA,0BAAkB,EAAC,YAAY,CAAC,CAAA;IAE/C,MAAM,QAAQ,GAAG,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,cAAc,IAAI,GAAG,CAAC,CAAA;IAC5D,MA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
|
3
|
-
"version": "1.1.45-snapshot-
|
3
|
+
"version": "1.1.45-snapshot-20240701122250",
|
4
4
|
"description": "Test utils for Medusa",
|
5
5
|
"main": "dist/index.js",
|
6
6
|
"repository": {
|
@@ -24,15 +24,15 @@
|
|
24
24
|
"author": "Sebastian Rindom",
|
25
25
|
"license": "MIT",
|
26
26
|
"devDependencies": {
|
27
|
-
"@medusajs/types": "1.12.0-snapshot-
|
27
|
+
"@medusajs/types": "1.12.0-snapshot-20240701122250",
|
28
28
|
"cross-env": "^5.2.1",
|
29
|
-
"jest": "^
|
29
|
+
"jest": "^29.7.0",
|
30
30
|
"rimraf": "^3.0.2",
|
31
31
|
"typescript": "^5.1.6"
|
32
32
|
},
|
33
33
|
"peerDependencies": {
|
34
|
-
"@medusajs/medusa": "1.20.6-snapshot-
|
35
|
-
"@medusajs/modules-sdk": "1.13.0-snapshot-
|
34
|
+
"@medusajs/medusa": "1.20.6-snapshot-20240701122250",
|
35
|
+
"@medusajs/modules-sdk": "1.13.0-snapshot-20240701122250",
|
36
36
|
"axios": "^0.28.0",
|
37
37
|
"express": "^4.18.3",
|
38
38
|
"get-port": "^5.1.0",
|
@@ -56,7 +56,7 @@
|
|
56
56
|
}
|
57
57
|
},
|
58
58
|
"dependencies": {
|
59
|
-
"@medusajs/utils": "1.12.0-snapshot-
|
59
|
+
"@medusajs/utils": "1.12.0-snapshot-20240701122250",
|
60
60
|
"@mikro-orm/migrations": "5.9.7",
|
61
61
|
"@mikro-orm/postgresql": "5.9.7",
|
62
62
|
"randomatic": "^3.1.1"
|