medusa-test-utils 1.1.45 → 2.0.0-rc-20241003153304
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 +2 -0
- package/dist/database.d.ts.map +1 -0
- package/dist/database.js +100 -146
- package/dist/database.js.map +1 -1
- package/dist/events.d.ts +3 -0
- package/dist/events.d.ts.map +1 -0
- package/dist/events.js +41 -0
- package/dist/events.js.map +1 -0
- package/dist/id-map.d.ts +3 -2
- package/dist/id-map.d.ts.map +1 -0
- package/dist/id-map.js +8 -11
- package/dist/id-map.js.map +1 -1
- package/dist/index.d.ts +5 -4
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +5 -7
- package/dist/index.js.map +1 -1
- package/dist/init-modules.d.ts +2 -1
- package/dist/init-modules.d.ts.map +1 -0
- package/dist/init-modules.js +39 -97
- package/dist/init-modules.js.map +1 -1
- package/dist/jest.d.ts +1 -0
- package/dist/jest.d.ts.map +1 -0
- package/dist/jest.js +15 -64
- package/dist/jest.js.map +1 -1
- package/dist/medusa-test-runner-utils/bootstrap-app.d.ts +10 -5
- package/dist/medusa-test-runner-utils/bootstrap-app.d.ts.map +1 -0
- package/dist/medusa-test-runner-utils/bootstrap-app.js +53 -147
- package/dist/medusa-test-runner-utils/bootstrap-app.js.map +1 -1
- package/dist/medusa-test-runner-utils/clear-instances.d.ts +8 -0
- package/dist/medusa-test-runner-utils/clear-instances.d.ts.map +1 -0
- package/dist/medusa-test-runner-utils/clear-instances.js +14 -0
- package/dist/medusa-test-runner-utils/clear-instances.js.map +1 -0
- package/dist/medusa-test-runner-utils/config.d.ts +5 -0
- package/dist/medusa-test-runner-utils/config.d.ts.map +1 -0
- package/dist/medusa-test-runner-utils/config.js +28 -0
- package/dist/medusa-test-runner-utils/config.js.map +1 -0
- package/dist/medusa-test-runner-utils/index.d.ts +6 -0
- package/dist/medusa-test-runner-utils/index.d.ts.map +1 -0
- package/dist/medusa-test-runner-utils/index.js +22 -0
- package/dist/medusa-test-runner-utils/index.js.map +1 -0
- package/dist/medusa-test-runner-utils/use-db.d.ts +15 -12
- package/dist/medusa-test-runner-utils/use-db.d.ts.map +1 -0
- package/dist/medusa-test-runner-utils/use-db.js +51 -143
- package/dist/medusa-test-runner-utils/use-db.js.map +1 -1
- package/dist/medusa-test-runner-utils/utils.d.ts +2 -0
- package/dist/medusa-test-runner-utils/utils.d.ts.map +1 -0
- package/dist/medusa-test-runner-utils/utils.js +10 -0
- package/dist/medusa-test-runner-utils/utils.js.map +1 -0
- package/dist/medusa-test-runner.d.ts +16 -6
- package/dist/medusa-test-runner.d.ts.map +1 -0
- package/dist/medusa-test-runner.js +123 -343
- package/dist/medusa-test-runner.js.map +1 -1
- package/dist/mock-event-bus-service.d.ts +5 -4
- package/dist/mock-event-bus-service.d.ts.map +1 -0
- package/dist/mock-event-bus-service.js +13 -51
- package/dist/mock-event-bus-service.js.map +1 -1
- package/dist/module-test-runner.d.ts +4 -2
- package/dist/module-test-runner.d.ts.map +1 -0
- package/dist/module-test-runner.js +117 -132
- package/dist/module-test-runner.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/package.json +28 -39
- package/dist/mock-manager.d.ts +0 -9
- package/dist/mock-manager.js +0 -30
- package/dist/mock-manager.js.map +0 -1
- package/dist/mock-repository.d.ts +0 -51
- package/dist/mock-repository.js +0 -193
- package/dist/mock-repository.js.map +0 -1
@@ -8,15 +8,17 @@ export interface SuiteOptions<TService = unknown> {
|
|
8
8
|
clientUrl: string;
|
9
9
|
};
|
10
10
|
}
|
11
|
-
export declare function moduleIntegrationTestRunner({ moduleName, moduleModels, moduleOptions, joinerConfig, schema, debug, testSuite, resolve, injectedDependencies, }: {
|
11
|
+
export declare function moduleIntegrationTestRunner<TService = any>({ moduleName, moduleModels, moduleOptions, moduleDependencies, joinerConfig, schema, debug, testSuite, resolve, injectedDependencies, }: {
|
12
12
|
moduleName: string;
|
13
13
|
moduleModels?: any[];
|
14
14
|
moduleOptions?: Record<string, any>;
|
15
|
+
moduleDependencies?: string[];
|
15
16
|
joinerConfig?: any[];
|
16
17
|
schema?: string;
|
17
18
|
dbName?: string;
|
18
19
|
injectedDependencies?: Record<string, any>;
|
19
20
|
resolve?: string;
|
20
21
|
debug?: boolean;
|
21
|
-
testSuite:
|
22
|
+
testSuite: (options: SuiteOptions<TService>) => void;
|
22
23
|
}): void;
|
24
|
+
//# sourceMappingURL=module-test-runner.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"module-test-runner.d.ts","sourceRoot":"","sources":["../src/module-test-runner.ts"],"names":[],"mappings":"AAUA,OAAO,EAAsC,YAAY,EAAE,MAAM,YAAY,CAAA;AAI7E,MAAM,WAAW,YAAY,CAAC,QAAQ,GAAG,OAAO;IAC9C,eAAe,EAAE,YAAY,CAAA;IAC7B,SAAS,EAAE,GAAG,CAAA;IACd,OAAO,EAAE,QAAQ,CAAA;IACjB,QAAQ,EAAE;QACR,MAAM,EAAE,MAAM,CAAA;QACd,SAAS,EAAE,MAAM,CAAA;KAClB,CAAA;CACF;AA0CD,wBAAgB,2BAA2B,CAAC,QAAQ,GAAG,GAAG,EAAE,EAC1D,UAAU,EACV,YAAY,EACZ,aAAkB,EAClB,kBAAkB,EAClB,YAAiB,EACjB,MAAiB,EACjB,KAAa,EACb,SAAS,EACT,OAAO,EACP,oBAAyB,GAC1B,EAAE;IACD,UAAU,EAAE,MAAM,CAAA;IAClB,YAAY,CAAC,EAAE,GAAG,EAAE,CAAA;IACpB,aAAa,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;IACnC,kBAAkB,CAAC,EAAE,MAAM,EAAE,CAAA;IAC7B,YAAY,CAAC,EAAE,GAAG,EAAE,CAAA;IACpB,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,oBAAoB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;IAC1C,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,KAAK,CAAC,EAAE,OAAO,CAAA;IACf,SAAS,EAAE,CAAC,OAAO,EAAE,YAAY,CAAC,QAAQ,CAAC,KAAK,IAAI,CAAA;CACrD,QA2GA"}
|
@@ -1,162 +1,147 @@
|
|
1
1
|
"use strict";
|
2
|
-
var
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
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 };
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
3
|
+
if (k2 === undefined) k2 = k;
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
47
7
|
}
|
8
|
+
Object.defineProperty(o, k2, desc);
|
9
|
+
}) : (function(o, m, k, k2) {
|
10
|
+
if (k2 === undefined) k2 = k;
|
11
|
+
o[k2] = m[k];
|
12
|
+
}));
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
15
|
+
}) : function(o, v) {
|
16
|
+
o["default"] = v;
|
17
|
+
});
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
19
|
+
if (mod && mod.__esModule) return mod;
|
20
|
+
var result = {};
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
22
|
+
__setModuleDefault(result, mod);
|
23
|
+
return result;
|
24
|
+
};
|
25
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
26
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
48
27
|
};
|
49
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
50
|
-
exports.moduleIntegrationTestRunner =
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
29
|
+
exports.moduleIntegrationTestRunner = moduleIntegrationTestRunner;
|
30
|
+
const utils_1 = require("@medusajs/framework/utils");
|
31
|
+
const fs = __importStar(require("fs"));
|
32
|
+
const database_1 = require("./database");
|
33
|
+
const init_modules_1 = require("./init-modules");
|
34
|
+
const mock_event_bus_service_1 = __importDefault(require("./mock-event-bus-service"));
|
35
|
+
function createMikroOrmWrapper(options) {
|
36
|
+
let moduleModels = options.moduleModels ?? [];
|
37
|
+
if (!options.moduleModels) {
|
38
|
+
const basePath = (0, utils_1.normalizeImportPathWithSource)(options.resolve ?? process.cwd());
|
39
|
+
const modelsPath = fs.existsSync(`${basePath}/dist/models`)
|
40
|
+
? "/dist/models"
|
41
|
+
: fs.existsSync(`${basePath}/models`)
|
42
|
+
? "/models"
|
43
|
+
: "";
|
44
|
+
if (modelsPath) {
|
45
|
+
moduleModels = (0, utils_1.loadModels)(`${basePath}${modelsPath}`);
|
46
|
+
}
|
47
|
+
else {
|
48
|
+
moduleModels = [];
|
49
|
+
}
|
50
|
+
}
|
51
|
+
moduleModels = (0, utils_1.toMikroOrmEntities)(moduleModels);
|
52
|
+
const MikroOrmWrapper = (0, database_1.getMikroOrmWrapper)({
|
53
|
+
mikroOrmEntities: moduleModels,
|
54
|
+
clientUrl: options.dbConfig.clientUrl,
|
55
|
+
schema: options.dbConfig.schema,
|
56
|
+
});
|
57
|
+
return { MikroOrmWrapper, models: moduleModels };
|
58
|
+
}
|
59
|
+
function moduleIntegrationTestRunner({ moduleName, moduleModels, moduleOptions = {}, moduleDependencies, joinerConfig = [], schema = "public", debug = false, testSuite, resolve, injectedDependencies = {}, }) {
|
60
|
+
const moduleSdkImports = require("@medusajs/framework/modules-sdk");
|
60
61
|
process.env.LOG_LEVEL = "error";
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
var dbName = "medusa-".concat(moduleName.toLowerCase(), "-integration-").concat(tempName);
|
65
|
-
var dbConfig = {
|
62
|
+
const tempName = parseInt(process.env.JEST_WORKER_ID || "1");
|
63
|
+
const dbName = `medusa-${moduleName.toLowerCase()}-integration-${tempName}`;
|
64
|
+
const dbConfig = {
|
66
65
|
clientUrl: (0, database_1.getDatabaseURL)(dbName),
|
67
|
-
schema
|
68
|
-
debug
|
66
|
+
schema,
|
67
|
+
debug,
|
69
68
|
};
|
70
69
|
// Use a unique connection for all the entire suite
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
70
|
+
const connection = utils_1.ModulesSdkUtils.createPgConnection(dbConfig);
|
71
|
+
const { MikroOrmWrapper, models } = createMikroOrmWrapper({
|
72
|
+
moduleModels,
|
73
|
+
resolve,
|
74
|
+
dbConfig,
|
76
75
|
});
|
77
|
-
|
78
|
-
|
76
|
+
moduleModels = models;
|
77
|
+
const modulesConfig_ = {
|
78
|
+
[moduleName]: {
|
79
79
|
definition: moduleSdkImports.ModulesDefinition[moduleName],
|
80
|
-
resolve
|
81
|
-
|
82
|
-
|
83
|
-
|
80
|
+
resolve,
|
81
|
+
dependencies: moduleDependencies,
|
82
|
+
options: {
|
83
|
+
database: dbConfig,
|
84
|
+
...moduleOptions,
|
85
|
+
},
|
86
|
+
},
|
87
|
+
};
|
88
|
+
const moduleOptions_ = {
|
89
|
+
injectedDependencies: {
|
90
|
+
[utils_1.ContainerRegistrationKeys.PG_CONNECTION]: connection,
|
91
|
+
[utils_1.Modules.EVENT_BUS]: new mock_event_bus_service_1.default(),
|
92
|
+
[utils_1.ContainerRegistrationKeys.LOGGER]: console,
|
93
|
+
...injectedDependencies,
|
84
94
|
},
|
85
|
-
_b);
|
86
|
-
var moduleOptions_ = {
|
87
|
-
injectedDependencies: __assign((_c = {}, _c[utils_1.ContainerRegistrationKeys.PG_CONNECTION] = connection, _c.eventBusService = new _1.MockEventBusService(), _c[utils_1.ContainerRegistrationKeys.LOGGER] = console, _c), injectedDependencies),
|
88
95
|
modulesConfig: modulesConfig_,
|
89
96
|
databaseConfig: dbConfig,
|
90
|
-
joinerConfig
|
97
|
+
joinerConfig,
|
91
98
|
preventConnectionDestroyWarning: true,
|
92
99
|
};
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
MikroOrmWrapper
|
100
|
+
let shutdown;
|
101
|
+
let moduleService;
|
102
|
+
let medusaApp = {};
|
103
|
+
const options = {
|
104
|
+
MikroOrmWrapper,
|
98
105
|
medusaApp: new Proxy({}, {
|
99
|
-
get:
|
106
|
+
get: (target, prop) => {
|
100
107
|
return medusaApp[prop];
|
101
108
|
},
|
102
109
|
}),
|
103
110
|
service: new Proxy({}, {
|
104
|
-
get:
|
111
|
+
get: (target, prop) => {
|
105
112
|
return moduleService[prop];
|
106
113
|
},
|
107
114
|
}),
|
115
|
+
dbConfig: {
|
116
|
+
schema,
|
117
|
+
clientUrl: dbConfig.clientUrl,
|
118
|
+
},
|
108
119
|
};
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
}
|
125
|
-
}
|
126
|
-
|
127
|
-
return __generator(this, function (_a) {
|
128
|
-
switch (_a.label) {
|
129
|
-
case 0: return [4 /*yield*/, MikroOrmWrapper.clearDatabase()];
|
130
|
-
case 1:
|
131
|
-
_a.sent();
|
132
|
-
return [4 /*yield*/, shutdown()];
|
133
|
-
case 2:
|
134
|
-
_a.sent();
|
135
|
-
moduleService = {};
|
136
|
-
medusaApp = {};
|
137
|
-
return [2 /*return*/];
|
138
|
-
}
|
139
|
-
});
|
140
|
-
}); };
|
141
|
-
return describe("", function () {
|
120
|
+
const beforeEach_ = async () => {
|
121
|
+
if (moduleModels.length) {
|
122
|
+
await MikroOrmWrapper.setupDatabase();
|
123
|
+
}
|
124
|
+
const output = await (0, init_modules_1.initModules)(moduleOptions_);
|
125
|
+
shutdown = output.shutdown;
|
126
|
+
medusaApp = output.medusaApp;
|
127
|
+
moduleService = output.medusaApp.modules[moduleName];
|
128
|
+
};
|
129
|
+
const afterEach_ = async () => {
|
130
|
+
if (moduleModels.length) {
|
131
|
+
await MikroOrmWrapper.clearDatabase();
|
132
|
+
}
|
133
|
+
await shutdown();
|
134
|
+
moduleService = {};
|
135
|
+
medusaApp = {};
|
136
|
+
};
|
137
|
+
return describe("", () => {
|
142
138
|
beforeEach(beforeEach_);
|
143
139
|
afterEach(afterEach_);
|
144
|
-
afterAll(
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
case 0: return [4 /*yield*/, ((_a = connection.context) === null || _a === void 0 ? void 0 : _a.destroy())];
|
149
|
-
case 1:
|
150
|
-
_b.sent();
|
151
|
-
return [4 /*yield*/, connection.destroy()];
|
152
|
-
case 2:
|
153
|
-
_b.sent();
|
154
|
-
return [2 /*return*/];
|
155
|
-
}
|
156
|
-
});
|
157
|
-
}); });
|
140
|
+
afterAll(async () => {
|
141
|
+
await connection.context?.destroy();
|
142
|
+
await connection.destroy();
|
143
|
+
});
|
158
144
|
testSuite(options);
|
159
145
|
});
|
160
146
|
}
|
161
|
-
exports.moduleIntegrationTestRunner = moduleIntegrationTestRunner;
|
162
147
|
//# sourceMappingURL=module-test-runner.js.map
|
@@ -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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgEA,kEAkIC;AAlMD,qDAQkC;AAClC,uCAAwB;AACxB,yCAA6E;AAC7E,iDAAgE;AAChE,sFAAyE;AAYzE,SAAS,qBAAqB,CAAC,OAI9B;IAIC,IAAI,YAAY,GACd,OAAO,CAAC,YAAY,IAAI,EAAE,CAAA;IAE5B,IAAI,CAAC,OAAO,CAAC,YAAY,EAAE,CAAC;QAC1B,MAAM,QAAQ,GAAG,IAAA,qCAA6B,EAC5C,OAAO,CAAC,OAAO,IAAI,OAAO,CAAC,GAAG,EAAE,CACjC,CAAA;QAED,MAAM,UAAU,GAAG,EAAE,CAAC,UAAU,CAAC,GAAG,QAAQ,cAAc,CAAC;YACzD,CAAC,CAAC,cAAc;YAChB,CAAC,CAAC,EAAE,CAAC,UAAU,CAAC,GAAG,QAAQ,SAAS,CAAC;gBACrC,CAAC,CAAC,SAAS;gBACX,CAAC,CAAC,EAAE,CAAA;QAEN,IAAI,UAAU,EAAE,CAAC;YACf,YAAY,GAAG,IAAA,kBAAU,EAAC,GAAG,QAAQ,GAAG,UAAU,EAAE,CAAC,CAAA;QACvD,CAAC;aAAM,CAAC;YACN,YAAY,GAAG,EAAE,CAAA;QACnB,CAAC;IACH,CAAC;IAED,YAAY,GAAG,IAAA,0BAAkB,EAAC,YAAY,CAAC,CAAA;IAE/C,MAAM,eAAe,GAAG,IAAA,6BAAkB,EAAC;QACzC,gBAAgB,EAAE,YAAY;QAC9B,SAAS,EAAE,OAAO,CAAC,QAAQ,CAAC,SAAS;QACrC,MAAM,EAAE,OAAO,CAAC,QAAQ,CAAC,MAAM;KAChC,CAAC,CAAA;IAEF,OAAO,EAAE,eAAe,EAAE,MAAM,EAAE,YAAY,EAAE,CAAA;AAClD,CAAC;AAED,SAA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AAC;QACD,MAAM,QAAQ,EAAE,CAAA;QAChB,aAAa,GAAG,EAAE,CAAA;QAClB,SAAS,GAAG,EAAE,CAAA;IAChB,CAAC,CAAA;IAED,OAAO,QAAQ,CAAC,EAAE,EAAE,GAAG,EAAE;QACvB,UAAU,CAAC,WAAW,CAAC,CAAA;QACvB,SAAS,CAAC,UAAU,CAAC,CAAA;QACrB,QAAQ,CAAC,KAAK,IAAI,EAAE;YAClB,MAAO,UAAkB,CAAC,OAAO,EAAE,OAAO,EAAE,CAAA;YAC5C,MAAO,UAAkB,CAAC,OAAO,EAAE,CAAA;QACrC,CAAC,CAAC,CAAA;QAEF,SAAS,CAAC,OAAO,CAAC,CAAA;IACpB,CAAC,CAAC,CAAA;AACJ,CAAC"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"root":["../src/database.ts","../src/events.ts","../src/id-map.ts","../src/index.ts","../src/init-modules.ts","../src/jest.ts","../src/medusa-test-runner.ts","../src/mock-event-bus-service.ts","../src/module-test-runner.ts","../src/medusa-test-runner-utils/bootstrap-app.ts","../src/medusa-test-runner-utils/clear-instances.ts","../src/medusa-test-runner-utils/config.ts","../src/medusa-test-runner-utils/index.ts","../src/medusa-test-runner-utils/use-db.ts","../src/medusa-test-runner-utils/utils.ts"],"version":"5.6.2"}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "medusa-test-utils",
|
3
|
-
"version": "
|
3
|
+
"version": "2.0.0-rc-20241003153304",
|
4
4
|
"description": "Test utils for Medusa",
|
5
5
|
"main": "dist/index.js",
|
6
6
|
"repository": {
|
@@ -9,62 +9,51 @@
|
|
9
9
|
"directory": "packages/medusa-test-utils"
|
10
10
|
},
|
11
11
|
"engines": {
|
12
|
-
"node": ">=
|
12
|
+
"node": ">=20"
|
13
13
|
},
|
14
14
|
"scripts": {
|
15
|
-
"prepublishOnly": "cross-env NODE_ENV=production tsc --build",
|
16
|
-
"prepare": "cross-env NODE_ENV=production yarn run build",
|
17
15
|
"build": "rimraf dist && tsc --build",
|
18
16
|
"watch": "tsc --build --watch",
|
19
17
|
"test": "jest --passWithNoTests src"
|
20
18
|
},
|
21
19
|
"files": [
|
22
|
-
"dist"
|
20
|
+
"dist",
|
21
|
+
"!dist/**/__tests__",
|
22
|
+
"!dist/**/__mocks__",
|
23
|
+
"!dist/**/__fixtures__"
|
23
24
|
],
|
24
|
-
"author": "
|
25
|
+
"author": "Medusa",
|
25
26
|
"license": "MIT",
|
26
27
|
"devDependencies": {
|
27
|
-
"@medusajs/
|
28
|
-
"
|
29
|
-
"
|
28
|
+
"@medusajs/framework": "1.0.0-rc-20241003153304",
|
29
|
+
"@mikro-orm/core": "5.9.7",
|
30
|
+
"@mikro-orm/knex": "5.9.7",
|
31
|
+
"@mikro-orm/migrations": "5.9.7",
|
32
|
+
"@mikro-orm/postgresql": "5.9.7",
|
33
|
+
"awilix": "^8.0.1",
|
34
|
+
"jest": "^29.7.0",
|
35
|
+
"pg": "^8.13.0",
|
36
|
+
"pg-god": "^1.0.12",
|
30
37
|
"rimraf": "^3.0.2",
|
31
|
-
"typescript": "^5.
|
38
|
+
"typescript": "^5.6.2"
|
32
39
|
},
|
33
|
-
"
|
34
|
-
"@
|
35
|
-
"
|
36
|
-
"
|
37
|
-
"express": "^4.18.3",
|
40
|
+
"dependencies": {
|
41
|
+
"@types/express": "^4.17.17",
|
42
|
+
"axios": "^0.21.4",
|
43
|
+
"express": "^4.21.0",
|
38
44
|
"get-port": "^5.1.0",
|
39
|
-
"
|
40
|
-
|
45
|
+
"randomatic": "^3.1.1"
|
46
|
+
},
|
47
|
+
"peerDependencies": {
|
48
|
+
"@medusajs/framework": "1.0.0-rc-20241003153304",
|
49
|
+
"@medusajs/medusa": "2.0.0-rc-20241003153304",
|
50
|
+
"@mikro-orm/postgresql": "5.9.7",
|
51
|
+
"awilix": "^8.0.1"
|
41
52
|
},
|
42
53
|
"peerDependenciesMeta": {
|
43
54
|
"@medusajs/medusa": {
|
44
55
|
"optional": true
|
45
|
-
},
|
46
|
-
"axios": {
|
47
|
-
"optional": true
|
48
|
-
},
|
49
|
-
"express": {
|
50
|
-
"optional": true
|
51
|
-
},
|
52
|
-
"get-port": {
|
53
|
-
"optional": true
|
54
|
-
},
|
55
|
-
"pg-god": {
|
56
|
-
"optional": true
|
57
|
-
},
|
58
|
-
"typeorm": {
|
59
|
-
"optional": true
|
60
56
|
}
|
61
57
|
},
|
62
|
-
"dependencies": {
|
63
|
-
"@medusajs/utils": "^1.11.10",
|
64
|
-
"@mikro-orm/migrations": "5.9.7",
|
65
|
-
"@mikro-orm/postgresql": "5.9.7",
|
66
|
-
"medusa-core-utils": "^1.2.3",
|
67
|
-
"randomatic": "^3.1.1"
|
68
|
-
},
|
69
58
|
"gitHead": "81a7ff73d012fda722f6e9ef0bd9ba0232d37808"
|
70
59
|
}
|
package/dist/mock-manager.d.ts
DELETED
@@ -1,9 +0,0 @@
|
|
1
|
-
declare namespace _default {
|
2
|
-
namespace connection {
|
3
|
-
function getMetadata(target: any): any;
|
4
|
-
}
|
5
|
-
function getRepository(repo: any): any;
|
6
|
-
function withRepository(repo: any): any;
|
7
|
-
function transaction(isolationOrCb: any, cb: any): any;
|
8
|
-
}
|
9
|
-
export default _default;
|
package/dist/mock-manager.js
DELETED
@@ -1,30 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.default = {
|
4
|
-
connection: {
|
5
|
-
getMetadata: function (target) {
|
6
|
-
var _a;
|
7
|
-
return ((_a = target["metadata"]) !== null && _a !== void 0 ? _a : {
|
8
|
-
columns: [],
|
9
|
-
});
|
10
|
-
},
|
11
|
-
},
|
12
|
-
getRepository: function (repo) {
|
13
|
-
return repo;
|
14
|
-
},
|
15
|
-
withRepository: function (repo) {
|
16
|
-
if (repo) {
|
17
|
-
return Object.assign(repo, { manager: this });
|
18
|
-
}
|
19
|
-
return repo;
|
20
|
-
},
|
21
|
-
transaction: function (isolationOrCb, cb) {
|
22
|
-
if (typeof isolationOrCb === "string") {
|
23
|
-
return cb(this);
|
24
|
-
}
|
25
|
-
else {
|
26
|
-
return isolationOrCb(this);
|
27
|
-
}
|
28
|
-
},
|
29
|
-
};
|
30
|
-
//# sourceMappingURL=mock-manager.js.map
|
package/dist/mock-manager.js.map
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"mock-manager.js","sourceRoot":"","sources":["../src/mock-manager.js"],"names":[],"mappings":";;AAAA,kBAAe;IACb,UAAU,EAAE;QACV,WAAW,EAAE,UAAC,MAAM;;YAClB,OAAO,CACL,MAAA,MAAM,CAAC,UAAU,CAAC,mCAAI;gBACpB,OAAO,EAAE,EAAE;aACZ,CACF,CAAA;QACH,CAAC;KACF;IAED,aAAa,EAAE,UAAU,IAAI;QAC3B,OAAO,IAAI,CAAA;IACb,CAAC;IAED,cAAc,EAAE,UAAU,IAAI;QAC5B,IAAI,IAAI,EAAE;YACR,OAAO,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAA;SAC9C;QAED,OAAO,IAAI,CAAA;IACb,CAAC;IAED,WAAW,EAAE,UAAU,aAAa,EAAE,EAAE;QACtC,IAAI,OAAO,aAAa,KAAK,QAAQ,EAAE;YACrC,OAAO,EAAE,CAAC,IAAI,CAAC,CAAA;SAChB;aAAM;YACL,OAAO,aAAa,CAAC,IAAI,CAAC,CAAA;SAC3B;IACH,CAAC;CACF,CAAA"}
|
@@ -1,51 +0,0 @@
|
|
1
|
-
declare function _default(methods?: {}): MockRepo;
|
2
|
-
export default _default;
|
3
|
-
declare class MockRepo {
|
4
|
-
constructor({ create, update, remove, softRemove, find, findDescendantsTree, findOne, findOneWithRelations, findOneOrFail, save, findAndCount, del, count, insertBulk, metadata, }: {
|
5
|
-
create: any;
|
6
|
-
update: any;
|
7
|
-
remove: any;
|
8
|
-
softRemove: any;
|
9
|
-
find: any;
|
10
|
-
findDescendantsTree: any;
|
11
|
-
findOne: any;
|
12
|
-
findOneWithRelations: any;
|
13
|
-
findOneOrFail: any;
|
14
|
-
save: any;
|
15
|
-
findAndCount: any;
|
16
|
-
del: any;
|
17
|
-
count: any;
|
18
|
-
insertBulk: any;
|
19
|
-
metadata: any;
|
20
|
-
});
|
21
|
-
create_: any;
|
22
|
-
update_: any;
|
23
|
-
remove_: any;
|
24
|
-
delete_: any;
|
25
|
-
softRemove_: any;
|
26
|
-
find_: any;
|
27
|
-
findDescendantsTree_: any;
|
28
|
-
findOne_: any;
|
29
|
-
findOneOrFail_: any;
|
30
|
-
save_: any;
|
31
|
-
findAndCount_: any;
|
32
|
-
findOneWithRelations_: any;
|
33
|
-
insertBulk_: any;
|
34
|
-
count_: any;
|
35
|
-
metadata: any;
|
36
|
-
setFindOne(fn: any): void;
|
37
|
-
insertBulk: jest.Mock<any, any>;
|
38
|
-
create: jest.Mock<any, any>;
|
39
|
-
softRemove: jest.Mock<any, any>;
|
40
|
-
remove: jest.Mock<any, any>;
|
41
|
-
update: jest.Mock<any, any>;
|
42
|
-
findOneOrFail: jest.Mock<any, any>;
|
43
|
-
findOneWithRelations: jest.Mock<any, any>;
|
44
|
-
findOne: jest.Mock<any, any>;
|
45
|
-
findDescendantsTree: jest.Mock<any, any>;
|
46
|
-
find: jest.Mock<any, any>;
|
47
|
-
save: jest.Mock<any, any>;
|
48
|
-
findAndCount: jest.Mock<any, any>;
|
49
|
-
count: jest.Mock<any, any>;
|
50
|
-
delete: jest.Mock<any, any>;
|
51
|
-
}
|