@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
|
@@ -1,144 +1,269 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.medusaIntegrationTestRunner = medusaIntegrationTestRunner;
|
|
4
|
+
const awilix_1 = require("@medusajs/framework/awilix");
|
|
5
|
+
const logger_1 = require("@medusajs/framework/logger");
|
|
6
|
+
const migrations_1 = require("@medusajs/framework/migrations");
|
|
4
7
|
const utils_1 = require("@medusajs/framework/utils");
|
|
5
|
-
const awilix_1 = require("awilix");
|
|
6
8
|
const database_1 = require("./database");
|
|
7
9
|
const medusa_test_runner_utils_1 = require("./medusa-test-runner-utils");
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
10
|
+
const wait_workflow_executions_1 = require("./medusa-test-runner-utils/wait-workflow-executions");
|
|
11
|
+
class MedusaTestRunner {
|
|
12
|
+
constructor(config) {
|
|
13
|
+
this.globalContainer = null;
|
|
14
|
+
this.apiUtils = null;
|
|
15
|
+
this.loadedApplication = null;
|
|
16
|
+
this.shutdown = async () => void 0;
|
|
17
|
+
this.isFirstTime = true;
|
|
18
|
+
this.hooks = {};
|
|
19
|
+
const tempName = parseInt(process.env.JEST_WORKER_ID || "1");
|
|
20
|
+
const moduleName = config.moduleName ?? Math.random().toString(36).substring(7);
|
|
21
|
+
this.dbName =
|
|
22
|
+
config.dbName ??
|
|
23
|
+
`medusa-${moduleName.toLowerCase()}-integration-${tempName}`;
|
|
24
|
+
this.schema = config.schema ?? "public";
|
|
25
|
+
this.cwd = config.cwd ?? config.medusaConfigFile ?? process.cwd();
|
|
26
|
+
this.modulesConfigPath = config.medusaConfigFile ?? this.cwd;
|
|
27
|
+
this.env = config.env ?? {};
|
|
28
|
+
this.debug = config.debug ?? false;
|
|
29
|
+
this.inApp = config.inApp ?? false;
|
|
30
|
+
this.disableAutoTeardown = config?.disableAutoTeardown ?? false;
|
|
31
|
+
this.dbUtils = (0, database_1.dbTestUtilFactory)();
|
|
32
|
+
this.dbConfig = {
|
|
33
|
+
dbName: this.dbName,
|
|
34
|
+
clientUrl: (0, database_1.getDatabaseURL)(this.dbName),
|
|
35
|
+
schema: this.schema,
|
|
36
|
+
debug: this.debug,
|
|
37
|
+
};
|
|
38
|
+
this.hooks = config.hooks ?? {};
|
|
39
|
+
this.setupProcessHandlers();
|
|
40
|
+
}
|
|
41
|
+
setupProcessHandlers() {
|
|
42
|
+
process.on("SIGTERM", async () => {
|
|
43
|
+
await this.cleanup();
|
|
44
|
+
process.exit(0);
|
|
45
|
+
});
|
|
46
|
+
process.on("SIGINT", async () => {
|
|
47
|
+
await this.cleanup();
|
|
48
|
+
process.exit(0);
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
createApiProxy() {
|
|
52
|
+
return new Proxy({}, {
|
|
26
53
|
get: (target, prop) => {
|
|
27
|
-
return apiUtils[prop];
|
|
54
|
+
return this.apiUtils?.[prop];
|
|
28
55
|
},
|
|
29
|
-
})
|
|
30
|
-
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
createDbConnectionProxy() {
|
|
59
|
+
return new Proxy({}, {
|
|
31
60
|
get: (target, prop) => {
|
|
32
|
-
return dbUtils.pgConnection_[prop];
|
|
61
|
+
return this.dbUtils.pgConnection_?.[prop];
|
|
33
62
|
},
|
|
34
|
-
}),
|
|
35
|
-
getMedusaApp: () => loadedApplication,
|
|
36
|
-
getContainer: () => globalContainer,
|
|
37
|
-
dbConfig: {
|
|
38
|
-
dbName,
|
|
39
|
-
schema,
|
|
40
|
-
clientUrl: dbConfig.clientUrl,
|
|
41
|
-
},
|
|
42
|
-
dbUtils,
|
|
43
|
-
};
|
|
44
|
-
let isFirstTime = true;
|
|
45
|
-
const beforeAll_ = async () => {
|
|
46
|
-
await (0, medusa_test_runner_utils_1.configLoaderOverride)(cwd, dbConfig);
|
|
47
|
-
(0, medusa_test_runner_utils_1.applyEnvVarsToProcess)(env);
|
|
48
|
-
const { logger, container, MedusaAppLoader } = await import("@medusajs/framework");
|
|
49
|
-
const appLoader = new MedusaAppLoader();
|
|
50
|
-
container.register({
|
|
51
|
-
[utils_1.ContainerRegistrationKeys.LOGGER]: (0, awilix_1.asValue)(logger),
|
|
52
63
|
});
|
|
64
|
+
}
|
|
65
|
+
async initializeDatabase() {
|
|
53
66
|
try {
|
|
54
|
-
|
|
55
|
-
await dbUtils.create(dbName);
|
|
56
|
-
dbUtils.pgConnection_ = await (0, medusa_test_runner_utils_1.initDb)();
|
|
67
|
+
logger_1.logger.info(`Creating database ${this.dbName}`);
|
|
68
|
+
await this.dbUtils.create(this.dbName);
|
|
69
|
+
this.dbUtils.pgConnection_ = await (0, medusa_test_runner_utils_1.initDb)();
|
|
57
70
|
}
|
|
58
71
|
catch (error) {
|
|
59
|
-
|
|
72
|
+
logger_1.logger.error(`Error initializing database: ${error?.message}`);
|
|
73
|
+
await this.cleanup();
|
|
60
74
|
throw error;
|
|
61
75
|
}
|
|
62
|
-
|
|
76
|
+
}
|
|
77
|
+
async setupApplication() {
|
|
78
|
+
const { container, MedusaAppLoader } = await import("@medusajs/framework");
|
|
79
|
+
const appLoader = new MedusaAppLoader({
|
|
80
|
+
medusaConfigPath: this.modulesConfigPath,
|
|
81
|
+
cwd: this.cwd,
|
|
82
|
+
});
|
|
83
|
+
// Load plugins modules
|
|
84
|
+
const configModule = container.resolve(utils_1.ContainerRegistrationKeys.CONFIG_MODULE);
|
|
85
|
+
const plugins = await (0, utils_1.getResolvedPlugins)(this.cwd, configModule);
|
|
86
|
+
(0, utils_1.mergePluginModules)(configModule, plugins);
|
|
87
|
+
container.register({
|
|
88
|
+
[utils_1.ContainerRegistrationKeys.LOGGER]: (0, awilix_1.asValue)(logger_1.logger),
|
|
89
|
+
});
|
|
90
|
+
if (this.hooks?.beforeServerStart) {
|
|
91
|
+
await this.hooks.beforeServerStart(container);
|
|
92
|
+
}
|
|
93
|
+
await this.initializeDatabase();
|
|
94
|
+
const migrator = new migrations_1.Migrator({ container });
|
|
95
|
+
await migrator.ensureMigrationsTable();
|
|
96
|
+
logger_1.logger.info(`Migrating database with core migrations and links ${this.dbName}`);
|
|
63
97
|
await (0, medusa_test_runner_utils_1.migrateDatabase)(appLoader);
|
|
64
|
-
await (0, medusa_test_runner_utils_1.syncLinks)(appLoader,
|
|
98
|
+
await (0, medusa_test_runner_utils_1.syncLinks)(appLoader, this.modulesConfigPath, container, logger_1.logger);
|
|
65
99
|
await (0, medusa_test_runner_utils_1.clearInstances)();
|
|
66
|
-
|
|
67
|
-
let serverShutdownRes;
|
|
68
|
-
let portRes;
|
|
69
|
-
loadedApplication = await appLoader.load();
|
|
100
|
+
this.loadedApplication = await appLoader.load();
|
|
70
101
|
try {
|
|
71
|
-
const { shutdown
|
|
72
|
-
cwd,
|
|
73
|
-
env,
|
|
102
|
+
const { shutdown, container: appContainer, port, } = await (0, medusa_test_runner_utils_1.startApp)({
|
|
103
|
+
cwd: this.modulesConfigPath,
|
|
104
|
+
env: this.env,
|
|
105
|
+
});
|
|
106
|
+
this.globalContainer = appContainer;
|
|
107
|
+
this.shutdown = async () => {
|
|
108
|
+
await shutdown();
|
|
109
|
+
if (this.apiUtils?.cancelToken?.source) {
|
|
110
|
+
this.apiUtils.cancelToken.source.cancel("Request canceled by shutdown");
|
|
111
|
+
}
|
|
112
|
+
};
|
|
113
|
+
const { default: axios } = (await import("axios"));
|
|
114
|
+
const cancelTokenSource = axios.CancelToken.source();
|
|
115
|
+
this.apiUtils = axios.create({
|
|
116
|
+
baseURL: `http://localhost:${port}`,
|
|
117
|
+
cancelToken: cancelTokenSource.token,
|
|
74
118
|
});
|
|
75
|
-
|
|
76
|
-
serverShutdownRes = shutdown;
|
|
77
|
-
portRes = port;
|
|
119
|
+
this.apiUtils.cancelToken = { source: cancelTokenSource };
|
|
78
120
|
}
|
|
79
121
|
catch (error) {
|
|
80
|
-
|
|
122
|
+
logger_1.logger.error(`Error starting the app: ${error?.message}`);
|
|
123
|
+
await this.cleanup();
|
|
81
124
|
throw error;
|
|
82
125
|
}
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
await
|
|
90
|
-
await (0, medusa_test_runner_utils_1.
|
|
126
|
+
}
|
|
127
|
+
async cleanup() {
|
|
128
|
+
try {
|
|
129
|
+
process.removeAllListeners("SIGTERM");
|
|
130
|
+
process.removeAllListeners("SIGINT");
|
|
131
|
+
await this.dbUtils.shutdown(this.dbName);
|
|
132
|
+
await this.shutdown();
|
|
133
|
+
await (0, medusa_test_runner_utils_1.clearInstances)();
|
|
134
|
+
if (this.apiUtils?.cancelToken?.source) {
|
|
135
|
+
this.apiUtils.cancelToken.source.cancel("Cleanup");
|
|
136
|
+
}
|
|
137
|
+
if (this.globalContainer?.dispose) {
|
|
138
|
+
await this.globalContainer.dispose();
|
|
139
|
+
}
|
|
140
|
+
this.apiUtils = null;
|
|
141
|
+
this.loadedApplication = null;
|
|
142
|
+
this.globalContainer = null;
|
|
143
|
+
if (global.gc) {
|
|
144
|
+
global.gc();
|
|
145
|
+
}
|
|
91
146
|
}
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
147
|
+
catch (error) {
|
|
148
|
+
logger_1.logger.error("Error during cleanup:", error?.message);
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
async beforeAll() {
|
|
152
|
+
try {
|
|
153
|
+
this.setupProcessHandlers();
|
|
154
|
+
await (0, medusa_test_runner_utils_1.configLoaderOverride)(this.cwd, this.dbConfig);
|
|
155
|
+
(0, medusa_test_runner_utils_1.applyEnvVarsToProcess)(this.env);
|
|
156
|
+
await this.setupApplication();
|
|
157
|
+
}
|
|
158
|
+
catch (error) {
|
|
159
|
+
await this.cleanup();
|
|
160
|
+
throw error;
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
async beforeEach() {
|
|
164
|
+
if (this.isFirstTime) {
|
|
165
|
+
this.isFirstTime = false;
|
|
108
166
|
return;
|
|
109
167
|
}
|
|
110
|
-
|
|
168
|
+
await this.afterEach();
|
|
169
|
+
const container = this.globalContainer;
|
|
111
170
|
const copiedContainer = (0, utils_1.createMedusaContainer)({}, container);
|
|
112
171
|
try {
|
|
113
172
|
const { MedusaAppLoader } = await import("@medusajs/framework");
|
|
114
173
|
const medusaAppLoader = new MedusaAppLoader({
|
|
115
174
|
container: copiedContainer,
|
|
175
|
+
medusaConfigPath: this.modulesConfigPath,
|
|
176
|
+
cwd: this.cwd,
|
|
116
177
|
});
|
|
117
178
|
await medusaAppLoader.runModulesLoader();
|
|
118
179
|
}
|
|
119
180
|
catch (error) {
|
|
120
|
-
|
|
181
|
+
await copiedContainer.dispose?.();
|
|
182
|
+
logger_1.logger.error("Error running modules loaders:", error?.message);
|
|
121
183
|
throw error;
|
|
122
184
|
}
|
|
123
|
-
}
|
|
124
|
-
|
|
185
|
+
}
|
|
186
|
+
async afterEach() {
|
|
125
187
|
try {
|
|
126
|
-
await
|
|
188
|
+
await (0, wait_workflow_executions_1.waitWorkflowExecutions)(this.globalContainer);
|
|
189
|
+
if (!this.disableAutoTeardown) {
|
|
190
|
+
// Perform automatic teardown
|
|
191
|
+
await this.dbUtils.teardown({ schema: this.schema });
|
|
192
|
+
}
|
|
127
193
|
}
|
|
128
194
|
catch (error) {
|
|
129
|
-
|
|
195
|
+
logger_1.logger.error("Error tearing down database:", error?.message);
|
|
130
196
|
throw error;
|
|
131
197
|
}
|
|
132
|
-
}
|
|
198
|
+
}
|
|
199
|
+
getOptions() {
|
|
200
|
+
return {
|
|
201
|
+
api: this.createApiProxy(),
|
|
202
|
+
dbConnection: this.createDbConnectionProxy(),
|
|
203
|
+
getMedusaApp: () => this.loadedApplication,
|
|
204
|
+
getContainer: () => this.globalContainer,
|
|
205
|
+
dbConfig: {
|
|
206
|
+
dbName: this.dbName,
|
|
207
|
+
schema: this.schema,
|
|
208
|
+
clientUrl: this.dbConfig.clientUrl,
|
|
209
|
+
},
|
|
210
|
+
dbUtils: this.dbUtils,
|
|
211
|
+
utils: {
|
|
212
|
+
waitWorkflowExecutions: () => (0, wait_workflow_executions_1.waitWorkflowExecutions)(this.globalContainer),
|
|
213
|
+
},
|
|
214
|
+
};
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
function medusaIntegrationTestRunner({ moduleName, dbName, medusaConfigFile, schema = "public", env = {}, debug = false, inApp = false, testSuite, hooks, cwd, disableAutoTeardown, }) {
|
|
218
|
+
const runner = new MedusaTestRunner({
|
|
219
|
+
moduleName,
|
|
220
|
+
dbName,
|
|
221
|
+
medusaConfigFile,
|
|
222
|
+
schema,
|
|
223
|
+
env,
|
|
224
|
+
debug,
|
|
225
|
+
inApp,
|
|
226
|
+
hooks,
|
|
227
|
+
cwd,
|
|
228
|
+
disableAutoTeardown,
|
|
229
|
+
});
|
|
133
230
|
return describe("", () => {
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
231
|
+
let testOptions;
|
|
232
|
+
beforeAll(async () => {
|
|
233
|
+
await runner.beforeAll();
|
|
234
|
+
testOptions = runner.getOptions();
|
|
235
|
+
});
|
|
236
|
+
beforeEach(async () => {
|
|
237
|
+
await runner.beforeEach();
|
|
238
|
+
});
|
|
239
|
+
afterEach(async () => {
|
|
240
|
+
await runner.afterEach();
|
|
241
|
+
});
|
|
137
242
|
afterAll(async () => {
|
|
138
|
-
|
|
139
|
-
await
|
|
243
|
+
// Run main cleanup
|
|
244
|
+
await runner.cleanup();
|
|
245
|
+
// Clean references to the test options
|
|
246
|
+
for (const key in testOptions) {
|
|
247
|
+
if (typeof testOptions[key] === "function") {
|
|
248
|
+
testOptions[key] = null;
|
|
249
|
+
}
|
|
250
|
+
else if (typeof testOptions[key] === "object" &&
|
|
251
|
+
testOptions[key] !== null) {
|
|
252
|
+
Object.keys(testOptions[key]).forEach((k) => {
|
|
253
|
+
testOptions[key][k] = null;
|
|
254
|
+
});
|
|
255
|
+
testOptions[key] = null;
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
// Encourage garbage collection
|
|
259
|
+
// @ts-ignore
|
|
260
|
+
testOptions = null;
|
|
261
|
+
if (global.gc) {
|
|
262
|
+
global.gc();
|
|
263
|
+
}
|
|
140
264
|
});
|
|
141
|
-
|
|
265
|
+
// Run test suite with options
|
|
266
|
+
testSuite(runner.getOptions());
|
|
142
267
|
});
|
|
143
268
|
}
|
|
144
269
|
//# sourceMappingURL=medusa-test-runner.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"medusa-test-runner.js","sourceRoot":"","sources":["../src/medusa-test-runner.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"medusa-test-runner.js","sourceRoot":"","sources":["../src/medusa-test-runner.ts"],"names":[],"mappings":";;AA0UA,kEAqFC;AA/ZD,uDAAoD;AACpD,uDAAmD;AACnD,+DAAyD;AAGzD,qDAKkC;AAClC,yCAA8D;AAC9D,yEAQmC;AACnC,kGAA4F;AAqC5F,MAAM,gBAAgB;IA0BpB,YAAY,MAAwB;QAP5B,oBAAe,GAA2B,IAAI,CAAA;QAC9C,aAAQ,GAAQ,IAAI,CAAA;QACpB,sBAAiB,GAAQ,IAAI,CAAA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C;QACH,CAAC,CAAC,CAAA;QAEF,8BAA8B;QAC9B,SAAS,CAAC,MAAM,CAAC,UAAU,EAAE,CAAC,CAAA;IAChC,CAAC,CAAC,CAAA;AACJ,CAAC"}
|
|
@@ -8,7 +8,7 @@ export interface SuiteOptions<TService = unknown> {
|
|
|
8
8
|
clientUrl: string;
|
|
9
9
|
};
|
|
10
10
|
}
|
|
11
|
-
|
|
11
|
+
interface ModuleTestRunnerConfig<TService = any> {
|
|
12
12
|
moduleName: string;
|
|
13
13
|
moduleModels?: any[];
|
|
14
14
|
moduleOptions?: Record<string, any>;
|
|
@@ -19,6 +19,26 @@ export declare function moduleIntegrationTestRunner<TService = any>({ moduleName
|
|
|
19
19
|
injectedDependencies?: Record<string, any>;
|
|
20
20
|
resolve?: string;
|
|
21
21
|
debug?: boolean;
|
|
22
|
+
cwd?: string;
|
|
23
|
+
hooks?: {
|
|
24
|
+
beforeModuleInit?: () => Promise<void>;
|
|
25
|
+
afterModuleInit?: (medusaApp: any, service: TService) => Promise<void>;
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
export declare function moduleIntegrationTestRunner<TService = any>({ moduleName, moduleModels, moduleOptions, moduleDependencies, joinerConfig, schema, debug, testSuite, resolve, injectedDependencies, cwd, hooks, }: {
|
|
29
|
+
moduleName: string;
|
|
30
|
+
moduleModels?: any[];
|
|
31
|
+
moduleOptions?: Record<string, any>;
|
|
32
|
+
moduleDependencies?: string[];
|
|
33
|
+
joinerConfig?: any[];
|
|
34
|
+
schema?: string;
|
|
35
|
+
dbName?: string;
|
|
36
|
+
injectedDependencies?: Record<string, any>;
|
|
37
|
+
resolve?: string;
|
|
38
|
+
debug?: boolean;
|
|
39
|
+
cwd?: string;
|
|
40
|
+
hooks?: ModuleTestRunnerConfig<TService>["hooks"];
|
|
22
41
|
testSuite: (options: SuiteOptions<TService>) => void;
|
|
23
42
|
}): void;
|
|
43
|
+
export {};
|
|
24
44
|
//# sourceMappingURL=module-test-runner.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"module-test-runner.d.ts","sourceRoot":"","sources":["../src/module-test-runner.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"module-test-runner.d.ts","sourceRoot":"","sources":["../src/module-test-runner.ts"],"names":[],"mappings":"AAYA,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;AAED,UAAU,sBAAsB,CAAC,QAAQ,GAAG,GAAG;IAC7C,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,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,KAAK,CAAC,EAAE;QACN,gBAAgB,CAAC,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAA;QACtC,eAAe,CAAC,EAAE,CAAC,SAAS,EAAE,GAAG,EAAE,OAAO,EAAE,QAAQ,KAAK,OAAO,CAAC,IAAI,CAAC,CAAA;KACvE,CAAA;CACF;AAoQD,wBAAgB,2BAA2B,CA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