@rstest/core 0.5.3 → 0.6.0
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/LICENSE.md +1 -1
- package/dist/{0~816.js → 0~628.js} +41 -110
- package/dist/0~655.js +121 -121
- package/dist/0~85.js +1 -1
- package/dist/importActualLoader.mjs +1 -0
- package/dist/index.js +64 -44
- package/dist/mockRuntimeCode.js +118 -0
- package/dist/worker.js +39 -19
- package/dist-types/index.d.ts +12 -1
- package/dist-types/worker.d.ts +13 -1
- package/package.json +11 -11
package/LICENSE.md
CHANGED
|
@@ -682,7 +682,7 @@ Licensed under MIT license in the repository at chalk/ansi-styles.
|
|
|
682
682
|
|
|
683
683
|
### birpc
|
|
684
684
|
|
|
685
|
-
Licensed under MIT license in the repository at git+https://github.com/antfu/birpc.git.
|
|
685
|
+
Licensed under MIT license in the repository at git+https://github.com/antfu-collective/birpc.git.
|
|
686
686
|
|
|
687
687
|
> MIT License
|
|
688
688
|
>
|
|
@@ -5,9 +5,9 @@ import * as __WEBPACK_EXTERNAL_MODULE_node_v8_d0df5498__ from "node:v8";
|
|
|
5
5
|
import * as __WEBPACK_EXTERNAL_MODULE_node_events_0a6aefe7__ from "node:events";
|
|
6
6
|
import * as __WEBPACK_EXTERNAL_MODULE_tinypool__ from "tinypool";
|
|
7
7
|
import * as __WEBPACK_EXTERNAL_MODULE_node_inspector_dd9822d6__ from "node:inspector";
|
|
8
|
-
export const __webpack_id__ = "
|
|
8
|
+
export const __webpack_id__ = "628";
|
|
9
9
|
export const __webpack_ids__ = [
|
|
10
|
-
"
|
|
10
|
+
"628"
|
|
11
11
|
];
|
|
12
12
|
export const __webpack_modules__ = {
|
|
13
13
|
"./src/core/rsbuild.ts": function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
|
@@ -15,6 +15,7 @@ export const __webpack_modules__ = {
|
|
|
15
15
|
XD: ()=>createRsbuildServer,
|
|
16
16
|
zh: ()=>prepareRsbuild
|
|
17
17
|
});
|
|
18
|
+
var external_node_url_ = __webpack_require__("node:url");
|
|
18
19
|
var core_ = __webpack_require__("@rsbuild/core");
|
|
19
20
|
var dist = __webpack_require__("../../node_modules/.pnpm/pathe@2.0.3/node_modules/pathe/dist/index.mjs");
|
|
20
21
|
var utils = __webpack_require__("./src/utils/index.ts");
|
|
@@ -108,7 +109,6 @@ export const __webpack_modules__ = {
|
|
|
108
109
|
}
|
|
109
110
|
});
|
|
110
111
|
var external_node_path_ = __webpack_require__("node:path");
|
|
111
|
-
var external_node_url_ = __webpack_require__("node:url");
|
|
112
112
|
const PLUGIN_CSS_FILTER = 'rstest:css-filter';
|
|
113
113
|
const css_filter_dirname = external_node_path_["default"].dirname((0, external_node_url_.fileURLToPath)(import.meta.url));
|
|
114
114
|
const pluginCSSFilter = ()=>({
|
|
@@ -268,6 +268,8 @@ export const __webpack_modules__ = {
|
|
|
268
268
|
});
|
|
269
269
|
}
|
|
270
270
|
} : null;
|
|
271
|
+
var external_node_fs_ = __webpack_require__("node:fs");
|
|
272
|
+
const mockRuntime_dirname = external_node_path_["default"].dirname((0, external_node_url_.fileURLToPath)(import.meta.url));
|
|
271
273
|
class MockRuntimeRspackPlugin {
|
|
272
274
|
apply(compiler) {
|
|
273
275
|
const { RuntimeModule } = compiler.webpack;
|
|
@@ -276,109 +278,24 @@ export const __webpack_modules__ = {
|
|
|
276
278
|
super('rstest runtime');
|
|
277
279
|
}
|
|
278
280
|
generate() {
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
return;
|
|
282
|
-
}
|
|
283
|
-
|
|
284
|
-
const originalRequire = __webpack_require__;
|
|
285
|
-
__webpack_require__ = function(...args) {
|
|
286
|
-
try {
|
|
287
|
-
return originalRequire(...args);
|
|
288
|
-
} catch (e) {
|
|
289
|
-
const errMsg = e.message ?? e.toString();
|
|
290
|
-
if (errMsg.includes('__webpack_modules__[moduleId] is not a function')) {
|
|
291
|
-
throw new Error(\`Cannot find module '\${args[0]}'\`)
|
|
292
|
-
}
|
|
293
|
-
throw e;
|
|
294
|
-
}
|
|
295
|
-
};
|
|
296
|
-
|
|
297
|
-
Object.keys(originalRequire).forEach(key => {
|
|
298
|
-
__webpack_require__[key] = originalRequire[key];
|
|
299
|
-
});
|
|
300
|
-
|
|
301
|
-
__webpack_require__.rstest_original_modules = {};
|
|
302
|
-
|
|
303
|
-
__webpack_require__.rstest_reset_modules = () => {
|
|
304
|
-
const mockedIds = Object.keys(__webpack_require__.rstest_original_modules)
|
|
305
|
-
Object.keys(__webpack_module_cache__).forEach(id => {
|
|
306
|
-
// Do not reset mocks registry.
|
|
307
|
-
if (!mockedIds.includes(id)) {
|
|
308
|
-
delete __webpack_module_cache__[id];
|
|
309
|
-
}
|
|
310
|
-
});
|
|
311
|
-
}
|
|
312
|
-
|
|
313
|
-
__webpack_require__.rstest_unmock = (id) => {
|
|
314
|
-
delete __webpack_module_cache__[id]
|
|
315
|
-
}
|
|
316
|
-
|
|
317
|
-
__webpack_require__.rstest_require_actual = __webpack_require__.rstest_import_actual = (id) => {
|
|
318
|
-
const originalModule = __webpack_require__.rstest_original_modules[id];
|
|
319
|
-
// Use fallback module if the module is not mocked.
|
|
320
|
-
const fallbackMod = __webpack_require__(id);
|
|
321
|
-
return originalModule ? originalModule : fallbackMod;
|
|
322
|
-
}
|
|
323
|
-
|
|
324
|
-
__webpack_require__.rstest_exec = async (id, modFactory) => {
|
|
325
|
-
if (__webpack_module_cache__) {
|
|
326
|
-
let asyncFactory = __webpack_module_cache__[id];
|
|
327
|
-
if (asyncFactory && asyncFactory.constructor.name === 'AsyncFunction') {
|
|
328
|
-
await asyncFactory();
|
|
329
|
-
}
|
|
330
|
-
}
|
|
331
|
-
};
|
|
332
|
-
|
|
333
|
-
__webpack_require__.rstest_mock = (id, modFactory) => {
|
|
334
|
-
let requiredModule = undefined
|
|
335
|
-
try {
|
|
336
|
-
requiredModule = __webpack_require__(id);
|
|
337
|
-
} catch {
|
|
338
|
-
// TODO: non-resolved module
|
|
339
|
-
} finally {
|
|
340
|
-
__webpack_require__.rstest_original_modules[id] = requiredModule;
|
|
341
|
-
}
|
|
342
|
-
if (typeof modFactory === 'string' || typeof modFactory === 'number') {
|
|
343
|
-
__webpack_module_cache__[id] = { exports: __webpack_require__(modFactory) };
|
|
344
|
-
} else if (typeof modFactory === 'function') {
|
|
345
|
-
if (modFactory.constructor.name === 'AsyncFunction') {
|
|
346
|
-
__webpack_module_cache__[id] = async () => {
|
|
347
|
-
const exports = await modFactory();
|
|
348
|
-
__webpack_require__.r(exports);
|
|
349
|
-
__webpack_module_cache__[id] = { exports, id, loaded: true };
|
|
350
|
-
}
|
|
351
|
-
} else {
|
|
352
|
-
const exports = modFactory();
|
|
353
|
-
__webpack_require__.r(exports);
|
|
354
|
-
__webpack_module_cache__[id] = { exports, id, loaded: true };
|
|
355
|
-
}
|
|
356
|
-
}
|
|
357
|
-
};
|
|
358
|
-
|
|
359
|
-
__webpack_require__.rstest_do_mock = (id, modFactory) => {
|
|
360
|
-
let requiredModule = undefined
|
|
361
|
-
try {
|
|
362
|
-
requiredModule = __webpack_require__(id);
|
|
363
|
-
} catch {
|
|
364
|
-
// TODO: non-resolved module
|
|
365
|
-
} finally {
|
|
366
|
-
__webpack_require__.rstest_original_modules[id] = requiredModule;
|
|
367
|
-
}
|
|
368
|
-
if (typeof modFactory === 'string' || typeof modFactory === 'number') {
|
|
369
|
-
__webpack_module_cache__[id] = { exports: __webpack_require__(modFactory) };
|
|
370
|
-
} else if (typeof modFactory === 'function') {
|
|
371
|
-
const exports = modFactory();
|
|
372
|
-
__webpack_require__.r(exports);
|
|
373
|
-
__webpack_module_cache__[id] = { exports, id, loaded: true };
|
|
374
|
-
}
|
|
375
|
-
};
|
|
376
|
-
|
|
377
|
-
`;
|
|
281
|
+
const code = external_node_fs_["default"].readFileSync(external_node_path_["default"].join(mockRuntime_dirname, './mockRuntimeCode.js'), 'utf8');
|
|
282
|
+
return code;
|
|
378
283
|
}
|
|
379
284
|
}
|
|
380
|
-
compiler.hooks.
|
|
381
|
-
compilation.hooks.
|
|
285
|
+
compiler.hooks.compilation.tap('RstestMockPlugin', (compilation)=>{
|
|
286
|
+
compilation.hooks.runtimeModule.tap('RstestMockChunkLoadingRuntimePlugin', (module)=>{
|
|
287
|
+
if ('require_chunk_loading' === module.name) {
|
|
288
|
+
const finalSource = module.source.source.toString('utf-8').replace('for (var moduleId in moreModules) {', "for (var moduleId in moreModules) {\n if (Object.keys(__webpack_require__.rstest_original_modules).includes(moduleId)) continue;");
|
|
289
|
+
module.source.source = Buffer.from(finalSource);
|
|
290
|
+
}
|
|
291
|
+
if ('define_property_getters' === module.name) {
|
|
292
|
+
const finalSource = module.source.source.toString('utf-8').replace('enumerable: true, get:', 'enumerable: true, configurable: true, get:');
|
|
293
|
+
module.source.source = Buffer.from(finalSource);
|
|
294
|
+
}
|
|
295
|
+
});
|
|
296
|
+
});
|
|
297
|
+
compiler.hooks.thisCompilation.tap('RstestMockPlugin', (compilation)=>{
|
|
298
|
+
compilation.hooks.additionalTreeRuntimeRequirements.tap('RstestAddMockRuntimePlugin', (chunk)=>{
|
|
382
299
|
compilation.addRuntimeModule(chunk, new RetestImportRuntimeModule());
|
|
383
300
|
});
|
|
384
301
|
});
|
|
@@ -418,8 +335,8 @@ global.__rstest_clean_core_cache__ = __rstest_clean_core_cache__;
|
|
|
418
335
|
`;
|
|
419
336
|
}
|
|
420
337
|
}
|
|
421
|
-
compiler.hooks.thisCompilation.tap('
|
|
422
|
-
compilation.hooks.additionalTreeRuntimeRequirements.tap('
|
|
338
|
+
compiler.hooks.thisCompilation.tap('RstestCacheControlPlugin', (compilation)=>{
|
|
339
|
+
compilation.hooks.additionalTreeRuntimeRequirements.tap('RstestAddCacheControlRuntimePlugin', (chunk)=>{
|
|
423
340
|
compilation.addRuntimeModule(chunk, new RetestCacheControlModule());
|
|
424
341
|
});
|
|
425
342
|
});
|
|
@@ -443,6 +360,7 @@ global.__rstest_clean_core_cache__ = __rstest_clean_core_cache__;
|
|
|
443
360
|
});
|
|
444
361
|
}
|
|
445
362
|
});
|
|
363
|
+
const rsbuild_dirname = dist.Ay.dirname((0, external_node_url_.fileURLToPath)(import.meta.url));
|
|
446
364
|
function parseInlineSourceMapStr(code) {
|
|
447
365
|
const inlineSourceMapRegex = /\/\/# sourceMappingURL=data:application\/json(?:;charset=utf-8)?;base64,(.+)\s*$/m;
|
|
448
366
|
const match = code.match(inlineSourceMapRegex);
|
|
@@ -574,6 +492,11 @@ global.__rstest_clean_core_cache__ = __rstest_clean_core_cache__;
|
|
|
574
492
|
const rstestCompilerPlugin = {
|
|
575
493
|
name: 'rstest:compiler',
|
|
576
494
|
setup: (api)=>{
|
|
495
|
+
api.modifyBundlerChain((chain)=>{
|
|
496
|
+
chain.module.rule('rstest-mock-module-doppelgangers').test(/\.(?:js|jsx|mjs|cjs|ts|tsx|mts|cts)$/).with({
|
|
497
|
+
rstest: 'importActual'
|
|
498
|
+
}).use('import-actual-loader').loader(dist.Ay.resolve(rsbuild_dirname, './importActualLoader.mjs')).end();
|
|
499
|
+
});
|
|
577
500
|
api.onAfterCreateCompiler(({ compiler })=>{
|
|
578
501
|
rspackCompiler = compiler;
|
|
579
502
|
});
|
|
@@ -728,6 +651,7 @@ global.__rstest_clean_core_cache__ = __rstest_clean_core_cache__;
|
|
|
728
651
|
b: ()=>createPool
|
|
729
652
|
});
|
|
730
653
|
var external_node_os_ = __webpack_require__("node:os");
|
|
654
|
+
var pathe_M_eThtNZ = __webpack_require__("../../node_modules/.pnpm/pathe@2.0.3/node_modules/pathe/dist/shared/pathe.M-eThtNZ.mjs");
|
|
731
655
|
var utils = __webpack_require__("./src/utils/index.ts");
|
|
732
656
|
var memory = __webpack_require__("./src/utils/memory.ts");
|
|
733
657
|
var external_node_url_ = __webpack_require__("node:url");
|
|
@@ -839,7 +763,7 @@ global.__rstest_clean_core_cache__ = __rstest_clean_core_cache__;
|
|
|
839
763
|
if (msg.t === TYPE_REQUEST) {
|
|
840
764
|
const { m: method, a: args } = msg;
|
|
841
765
|
let result, error;
|
|
842
|
-
const fn = resolver ? resolver(method, functions[method]) : functions[method];
|
|
766
|
+
const fn = await (resolver ? resolver(method, functions[method]) : functions[method]);
|
|
843
767
|
if (fn) try {
|
|
844
768
|
result = await fn.apply("rpc" === bind ? rpc : functions, args);
|
|
845
769
|
} catch (e) {
|
|
@@ -893,7 +817,6 @@ global.__rstest_clean_core_cache__ = __rstest_clean_core_cache__;
|
|
|
893
817
|
while(i--)id += urlAlphabet[64 * random() | 0];
|
|
894
818
|
return id;
|
|
895
819
|
}
|
|
896
|
-
var pathe_M_eThtNZ = __webpack_require__("../../node_modules/.pnpm/pathe@2.0.3/node_modules/pathe/dist/shared/pathe.M-eThtNZ.mjs");
|
|
897
820
|
const forks_filename = (0, external_node_url_.fileURLToPath)(import.meta.url);
|
|
898
821
|
const forks_dirname = (0, pathe_M_eThtNZ.d)(forks_filename);
|
|
899
822
|
function createChannel(rpcMethods) {
|
|
@@ -1047,6 +970,12 @@ global.__rstest_clean_core_cache__ = __rstest_clean_core_cache__;
|
|
|
1047
970
|
},
|
|
1048
971
|
onTestFileStart: async (test)=>{
|
|
1049
972
|
await Promise.all(reporters.map((reporter)=>reporter.onTestFileStart?.(test)));
|
|
973
|
+
},
|
|
974
|
+
resolveSnapshotPath: (testPath)=>{
|
|
975
|
+
const snapExtension = '.snap';
|
|
976
|
+
const resolver = context.normalizedConfig.resolveSnapshotPath || (()=>(0, pathe_M_eThtNZ.j)((0, pathe_M_eThtNZ.d)(testPath), '__snapshots__', `${(0, pathe_M_eThtNZ.c)(testPath)}${snapExtension}`));
|
|
977
|
+
const snapshotPath = resolver(testPath, snapExtension);
|
|
978
|
+
return snapshotPath;
|
|
1050
979
|
}
|
|
1051
980
|
};
|
|
1052
981
|
return {
|
|
@@ -1054,11 +983,12 @@ global.__rstest_clean_core_cache__ = __rstest_clean_core_cache__;
|
|
|
1054
983
|
const projectName = context.normalizedConfig.name;
|
|
1055
984
|
const runtimeConfig = getRuntimeConfig(project);
|
|
1056
985
|
const setupAssets = setupEntries.flatMap((entry)=>entry.files || []);
|
|
1057
|
-
const results = await Promise.all(entries.map(async (entryInfo)=>{
|
|
986
|
+
const results = await Promise.all(entries.map(async (entryInfo, index)=>{
|
|
1058
987
|
const result = await pool.runTest({
|
|
1059
988
|
options: {
|
|
1060
989
|
entryInfo,
|
|
1061
990
|
context: {
|
|
991
|
+
taskId: index + 1,
|
|
1062
992
|
project: projectName,
|
|
1063
993
|
rootPath: context.rootPath,
|
|
1064
994
|
projectRoot: project.rootPath,
|
|
@@ -1101,10 +1031,11 @@ global.__rstest_clean_core_cache__ = __rstest_clean_core_cache__;
|
|
|
1101
1031
|
const runtimeConfig = getRuntimeConfig(project);
|
|
1102
1032
|
const projectName = project.normalizedConfig.name;
|
|
1103
1033
|
const setupAssets = setupEntries.flatMap((entry)=>entry.files || []);
|
|
1104
|
-
return Promise.all(entries.map(async (entryInfo)=>pool.collectTests({
|
|
1034
|
+
return Promise.all(entries.map(async (entryInfo, index)=>pool.collectTests({
|
|
1105
1035
|
options: {
|
|
1106
1036
|
entryInfo,
|
|
1107
1037
|
context: {
|
|
1038
|
+
taskId: index + 1,
|
|
1108
1039
|
project: projectName,
|
|
1109
1040
|
rootPath: context.rootPath,
|
|
1110
1041
|
projectRoot: project.rootPath,
|
package/dist/0~655.js
CHANGED
|
@@ -1541,7 +1541,7 @@ export const __webpack_modules__ = {
|
|
|
1541
1541
|
const string = `${options.stylize(helpers_truncate(array[i], options.truncate), 'number')}${i === array.length - 1 ? '' : ', '}`;
|
|
1542
1542
|
options.truncate -= string.length;
|
|
1543
1543
|
if (array[i] !== array.length && options.truncate <= 3) {
|
|
1544
|
-
output +=
|
|
1544
|
+
output += `…(${array.length - array[i] + 1})`;
|
|
1545
1545
|
break;
|
|
1546
1546
|
}
|
|
1547
1547
|
output += string;
|
|
@@ -1598,7 +1598,7 @@ export const __webpack_modules__ = {
|
|
|
1598
1598
|
}
|
|
1599
1599
|
function inspectBigInt(number, options) {
|
|
1600
1600
|
let nums = helpers_truncate(number.toString(), options.truncate - 1);
|
|
1601
|
-
if (
|
|
1601
|
+
if ("…" !== nums) nums += 'n';
|
|
1602
1602
|
return options.stylize(nums, 'bigint');
|
|
1603
1603
|
}
|
|
1604
1604
|
function inspectRegExp(value, options) {
|
|
@@ -1754,7 +1754,7 @@ export const __webpack_modules__ = {
|
|
|
1754
1754
|
options.truncate -= propertyContents.length;
|
|
1755
1755
|
const truncate = options.truncate;
|
|
1756
1756
|
let children = inspectNodeCollection(element.children, options);
|
|
1757
|
-
if (children && children.length > truncate) children =
|
|
1757
|
+
if (children && children.length > truncate) children = `…(${element.children.length})`;
|
|
1758
1758
|
return `${head}${propertyContents}${headClose}${children}${tail}`;
|
|
1759
1759
|
}
|
|
1760
1760
|
const symbolsSupported = 'function' == typeof Symbol && 'function' == typeof Symbol.for;
|
|
@@ -3285,7 +3285,7 @@ export const __webpack_modules__ = {
|
|
|
3285
3285
|
function getCommonAndChangedSubstrings(diffs, op, hasCommonDiff) {
|
|
3286
3286
|
return diffs.reduce((reduced, diff)=>reduced + (diff[0] === DIFF_EQUAL ? diff[1] : diff[0] === op ? hasCommonDiff ? dist_node.Ay.inverse(diff[1]) : diff[1] : ""), "");
|
|
3287
3287
|
}
|
|
3288
|
-
__webpack_require__("../../node_modules/.pnpm/tinyspy@4.0.
|
|
3288
|
+
__webpack_require__("../../node_modules/.pnpm/tinyspy@4.0.4/node_modules/tinyspy/dist/index.js");
|
|
3289
3289
|
new Set();
|
|
3290
3290
|
function isMockFunction(fn) {
|
|
3291
3291
|
return "function" == typeof fn && "_isMockFunction" in fn && fn._isMockFunction;
|
|
@@ -11369,165 +11369,165 @@ deep-eql/index.js:
|
|
|
11369
11369
|
var node_r = void 0 !== process.env.FORCE_TTY || (0, external_node_tty_.isatty)(1);
|
|
11370
11370
|
var node_u = p(node_r);
|
|
11371
11371
|
},
|
|
11372
|
-
"../../node_modules/.pnpm/tinyspy@4.0.
|
|
11372
|
+
"../../node_modules/.pnpm/tinyspy@4.0.4/node_modules/tinyspy/dist/index.js": function(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
|
|
11373
11373
|
__webpack_require__.d(__webpack_exports__, {
|
|
11374
|
-
jo: ()=>
|
|
11375
|
-
lf: ()=>
|
|
11374
|
+
jo: ()=>M,
|
|
11375
|
+
lf: ()=>T
|
|
11376
11376
|
});
|
|
11377
|
-
function
|
|
11378
|
-
if (!
|
|
11377
|
+
function S(e, t) {
|
|
11378
|
+
if (!e) throw new Error(t);
|
|
11379
11379
|
}
|
|
11380
|
-
function
|
|
11381
|
-
return typeof
|
|
11380
|
+
function f(e, t) {
|
|
11381
|
+
return typeof t === e;
|
|
11382
11382
|
}
|
|
11383
|
-
function
|
|
11384
|
-
return
|
|
11383
|
+
function w(e) {
|
|
11384
|
+
return e instanceof Promise;
|
|
11385
11385
|
}
|
|
11386
|
-
function
|
|
11387
|
-
Object.defineProperty(
|
|
11386
|
+
function u(e, t, r) {
|
|
11387
|
+
Object.defineProperty(e, t, r);
|
|
11388
11388
|
}
|
|
11389
|
-
function
|
|
11390
|
-
|
|
11391
|
-
value,
|
|
11389
|
+
function l(e, t, r) {
|
|
11390
|
+
u(e, t, {
|
|
11391
|
+
value: r,
|
|
11392
11392
|
configurable: !0,
|
|
11393
11393
|
writable: !0
|
|
11394
11394
|
});
|
|
11395
11395
|
}
|
|
11396
|
-
var
|
|
11397
|
-
var
|
|
11398
|
-
|
|
11399
|
-
},
|
|
11396
|
+
var y = Symbol.for("tinyspy:spy");
|
|
11397
|
+
var x = /* @__PURE__ */ new Set(), h = (e)=>{
|
|
11398
|
+
e.called = !1, e.callCount = 0, e.calls = [], e.results = [], e.resolves = [], e.next = [];
|
|
11399
|
+
}, k = (e)=>(u(e, y, {
|
|
11400
11400
|
value: {
|
|
11401
|
-
reset: ()=>
|
|
11402
|
-
}
|
|
11403
|
-
}),
|
|
11404
|
-
function
|
|
11405
|
-
|
|
11406
|
-
let
|
|
11407
|
-
let
|
|
11408
|
-
|
|
11409
|
-
let
|
|
11410
|
-
if (
|
|
11411
|
-
|
|
11412
|
-
let [
|
|
11413
|
-
if ("ok" ===
|
|
11414
|
-
throw
|
|
11415
|
-
}
|
|
11416
|
-
let
|
|
11417
|
-
if (
|
|
11418
|
-
new.target ?
|
|
11419
|
-
} catch (
|
|
11420
|
-
throw
|
|
11421
|
-
|
|
11422
|
-
|
|
11423
|
-
]),
|
|
11424
|
-
}
|
|
11425
|
-
let
|
|
11426
|
-
|
|
11427
|
-
|
|
11401
|
+
reset: ()=>h(e[y])
|
|
11402
|
+
}
|
|
11403
|
+
}), e[y]), T = (e)=>e[y] || k(e);
|
|
11404
|
+
function R(e) {
|
|
11405
|
+
S(f("function", e) || f("undefined", e), "cannot spy on a non-function value");
|
|
11406
|
+
let t = function(...s) {
|
|
11407
|
+
let n = T(t);
|
|
11408
|
+
n.called = !0, n.callCount++, n.calls.push(s);
|
|
11409
|
+
let d = n.next.shift();
|
|
11410
|
+
if (d) {
|
|
11411
|
+
n.results.push(d);
|
|
11412
|
+
let [a, i] = d;
|
|
11413
|
+
if ("ok" === a) return i;
|
|
11414
|
+
throw i;
|
|
11415
|
+
}
|
|
11416
|
+
let o, c = "ok", p = n.results.length;
|
|
11417
|
+
if (n.impl) try {
|
|
11418
|
+
new.target ? o = Reflect.construct(n.impl, s, new.target) : o = n.impl.apply(this, s), c = "ok";
|
|
11419
|
+
} catch (a) {
|
|
11420
|
+
throw o = a, c = "error", n.results.push([
|
|
11421
|
+
c,
|
|
11422
|
+
a
|
|
11423
|
+
]), a;
|
|
11424
|
+
}
|
|
11425
|
+
let g = [
|
|
11426
|
+
c,
|
|
11427
|
+
o
|
|
11428
11428
|
];
|
|
11429
|
-
return
|
|
11429
|
+
return w(o) && o.then((a)=>n.resolves[p] = [
|
|
11430
11430
|
"ok",
|
|
11431
|
-
|
|
11432
|
-
], (
|
|
11431
|
+
a
|
|
11432
|
+
], (a)=>n.resolves[p] = [
|
|
11433
11433
|
"error",
|
|
11434
|
-
|
|
11435
|
-
]),
|
|
11434
|
+
a
|
|
11435
|
+
]), n.results.push(g), o;
|
|
11436
11436
|
};
|
|
11437
|
-
|
|
11438
|
-
let
|
|
11439
|
-
return
|
|
11440
|
-
}
|
|
11441
|
-
function
|
|
11442
|
-
return !!
|
|
11443
|
-
}
|
|
11444
|
-
var
|
|
11445
|
-
let
|
|
11446
|
-
if (
|
|
11447
|
-
|
|
11448
|
-
|
|
11437
|
+
l(t, "_isMockFunction", !0), l(t, "length", e ? e.length : 0), l(t, "name", e && e.name || "spy");
|
|
11438
|
+
let r = T(t);
|
|
11439
|
+
return r.reset(), r.impl = e, t;
|
|
11440
|
+
}
|
|
11441
|
+
function v(e) {
|
|
11442
|
+
return !!e && !0 === e._isMockFunction;
|
|
11443
|
+
}
|
|
11444
|
+
var b = (e, t)=>{
|
|
11445
|
+
let r = Object.getOwnPropertyDescriptor(e, t);
|
|
11446
|
+
if (r) return [
|
|
11447
|
+
e,
|
|
11448
|
+
r
|
|
11449
11449
|
];
|
|
11450
|
-
let
|
|
11451
|
-
for(; null !==
|
|
11452
|
-
let
|
|
11453
|
-
if (
|
|
11454
|
-
|
|
11455
|
-
|
|
11450
|
+
let s = Object.getPrototypeOf(e);
|
|
11451
|
+
for(; null !== s;){
|
|
11452
|
+
let n = Object.getOwnPropertyDescriptor(s, t);
|
|
11453
|
+
if (n) return [
|
|
11454
|
+
s,
|
|
11455
|
+
n
|
|
11456
11456
|
];
|
|
11457
|
-
|
|
11457
|
+
s = Object.getPrototypeOf(s);
|
|
11458
11458
|
}
|
|
11459
|
-
},
|
|
11460
|
-
null !=
|
|
11459
|
+
}, P = (e, t)=>{
|
|
11460
|
+
null != t && "function" == typeof t && null != t.prototype && Object.setPrototypeOf(e.prototype, t.prototype);
|
|
11461
11461
|
};
|
|
11462
|
-
function
|
|
11463
|
-
|
|
11464
|
-
let [
|
|
11465
|
-
if (!
|
|
11466
|
-
|
|
11462
|
+
function M(e, t, r) {
|
|
11463
|
+
S(!f("undefined", e), "spyOn could not find an object to spy upon"), S(f("object", e) || f("function", e), "cannot spyOn on a primitive value");
|
|
11464
|
+
let [s, n] = (()=>{
|
|
11465
|
+
if (!f("object", t)) return [
|
|
11466
|
+
t,
|
|
11467
11467
|
"value"
|
|
11468
11468
|
];
|
|
11469
|
-
if ("getter" in
|
|
11470
|
-
if ("getter" in
|
|
11471
|
-
|
|
11469
|
+
if ("getter" in t && "setter" in t) throw new Error("cannot spy on both getter and setter");
|
|
11470
|
+
if ("getter" in t) return [
|
|
11471
|
+
t.getter,
|
|
11472
11472
|
"get"
|
|
11473
11473
|
];
|
|
11474
|
-
if ("setter" in
|
|
11475
|
-
|
|
11474
|
+
if ("setter" in t) return [
|
|
11475
|
+
t.setter,
|
|
11476
11476
|
"set"
|
|
11477
11477
|
];
|
|
11478
11478
|
throw new Error("specify getter or setter to spy on");
|
|
11479
|
-
})(), [
|
|
11480
|
-
|
|
11481
|
-
let
|
|
11482
|
-
"value" ===
|
|
11483
|
-
let
|
|
11484
|
-
|
|
11485
|
-
let
|
|
11486
|
-
let { value, ...
|
|
11479
|
+
})(), [d, o] = b(e, s) || [];
|
|
11480
|
+
S(o || s in e, `${String(s)} does not exist`);
|
|
11481
|
+
let c = !1;
|
|
11482
|
+
"value" === n && o && !o.value && o.get && (n = "get", c = !0, r = o.get());
|
|
11483
|
+
let p;
|
|
11484
|
+
o ? p = o[n] : "value" !== n ? p = ()=>e[s] : p = e[s], p && j(p) && (p = p[y].getOriginal());
|
|
11485
|
+
let g = (I)=>{
|
|
11486
|
+
let { value: F, ...O } = o || {
|
|
11487
11487
|
configurable: !0,
|
|
11488
11488
|
writable: !0
|
|
11489
11489
|
};
|
|
11490
|
-
"value" !==
|
|
11491
|
-
},
|
|
11492
|
-
|
|
11490
|
+
"value" !== n && delete O.writable, O[n] = I, u(e, s, O);
|
|
11491
|
+
}, a = ()=>{
|
|
11492
|
+
d !== e ? Reflect.deleteProperty(e, s) : o && !p ? u(e, s, o) : g(p);
|
|
11493
11493
|
};
|
|
11494
|
-
|
|
11495
|
-
let
|
|
11496
|
-
"value" ===
|
|
11497
|
-
let
|
|
11498
|
-
return
|
|
11494
|
+
r || (r = p);
|
|
11495
|
+
let i = E(R(r), r);
|
|
11496
|
+
"value" === n && P(i, p);
|
|
11497
|
+
let m = i[y];
|
|
11498
|
+
return l(m, "restore", a), l(m, "getOriginal", ()=>c ? p() : p), l(m, "willCall", (I)=>(m.impl = I, i)), g(c ? ()=>(P(i, r), i) : i), x.add(i), i;
|
|
11499
11499
|
}
|
|
11500
|
-
var
|
|
11500
|
+
var K = /* @__PURE__ */ new Set([
|
|
11501
11501
|
"length",
|
|
11502
11502
|
"name",
|
|
11503
11503
|
"prototype"
|
|
11504
11504
|
]);
|
|
11505
|
-
function
|
|
11506
|
-
let
|
|
11507
|
-
for(;
|
|
11508
|
-
let
|
|
11509
|
-
...Object.getOwnPropertyNames(
|
|
11510
|
-
...Object.getOwnPropertySymbols(
|
|
11505
|
+
function D(e) {
|
|
11506
|
+
let t = /* @__PURE__ */ new Set(), r = {};
|
|
11507
|
+
for(; e && e !== Object.prototype && e !== Function.prototype;){
|
|
11508
|
+
let s = [
|
|
11509
|
+
...Object.getOwnPropertyNames(e),
|
|
11510
|
+
...Object.getOwnPropertySymbols(e)
|
|
11511
11511
|
];
|
|
11512
|
-
for (let
|
|
11513
|
-
|
|
11512
|
+
for (let n of s)r[n] || K.has(n) || (t.add(n), r[n] = Object.getOwnPropertyDescriptor(e, n));
|
|
11513
|
+
e = Object.getPrototypeOf(e);
|
|
11514
11514
|
}
|
|
11515
11515
|
return {
|
|
11516
|
-
properties,
|
|
11517
|
-
descriptors:
|
|
11516
|
+
properties: t,
|
|
11517
|
+
descriptors: r
|
|
11518
11518
|
};
|
|
11519
11519
|
}
|
|
11520
|
-
function
|
|
11521
|
-
if (!
|
|
11522
|
-
let { properties, descriptors:
|
|
11523
|
-
for (let
|
|
11524
|
-
let
|
|
11525
|
-
|
|
11520
|
+
function E(e, t) {
|
|
11521
|
+
if (!t || y in t) return e;
|
|
11522
|
+
let { properties: r, descriptors: s } = D(t);
|
|
11523
|
+
for (let n of r){
|
|
11524
|
+
let d = s[n];
|
|
11525
|
+
b(e, n) || u(e, n, d);
|
|
11526
11526
|
}
|
|
11527
|
-
return
|
|
11527
|
+
return e;
|
|
11528
11528
|
}
|
|
11529
|
-
function
|
|
11530
|
-
return
|
|
11529
|
+
function j(e) {
|
|
11530
|
+
return v(e) && "getOriginal" in e[y];
|
|
11531
11531
|
}
|
|
11532
11532
|
}
|
|
11533
11533
|
};
|
package/dist/0~85.js
CHANGED
|
@@ -1511,7 +1511,7 @@ export const __webpack_modules__ = {
|
|
|
1511
1511
|
return this._fakingTime;
|
|
1512
1512
|
}
|
|
1513
1513
|
}
|
|
1514
|
-
var tinyspy_dist = __webpack_require__("../../node_modules/.pnpm/tinyspy@4.0.
|
|
1514
|
+
var tinyspy_dist = __webpack_require__("../../node_modules/.pnpm/tinyspy@4.0.4/node_modules/tinyspy/dist/index.js");
|
|
1515
1515
|
let callOrder = 0;
|
|
1516
1516
|
const mocks = new Set();
|
|
1517
1517
|
const wrapSpy = (obj, methodName, mockFn)=>{
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default ((source)=>source);
|