@rstest/core 0.7.9 → 0.8.1

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.
@@ -7378,6 +7378,104 @@ __webpack_require__.add({
7378
7378
  return number < 0 ? -1 : 1;
7379
7379
  };
7380
7380
  },
7381
+ "../../node_modules/.pnpm/os-browserify@0.3.0/node_modules/os-browserify/browser.js" (__unused_rspack_module, exports) {
7382
+ exports.endianness = function() {
7383
+ return 'LE';
7384
+ };
7385
+ exports.hostname = function() {
7386
+ if ("u" > typeof location) return location.hostname;
7387
+ return '';
7388
+ };
7389
+ exports.loadavg = function() {
7390
+ return [];
7391
+ };
7392
+ exports.uptime = function() {
7393
+ return 0;
7394
+ };
7395
+ exports.freemem = function() {
7396
+ return Number.MAX_VALUE;
7397
+ };
7398
+ exports.totalmem = function() {
7399
+ return Number.MAX_VALUE;
7400
+ };
7401
+ exports.cpus = function() {
7402
+ return [];
7403
+ };
7404
+ exports.type = function() {
7405
+ return 'Browser';
7406
+ };
7407
+ exports.release = function() {
7408
+ if ("u" > typeof navigator) return navigator.appVersion;
7409
+ return '';
7410
+ };
7411
+ exports.networkInterfaces = exports.getNetworkInterfaces = function() {
7412
+ return {};
7413
+ };
7414
+ exports.arch = function() {
7415
+ return "javascript";
7416
+ };
7417
+ exports.platform = function() {
7418
+ return 'browser';
7419
+ };
7420
+ exports.tmpdir = exports.tmpDir = function() {
7421
+ return '/tmp';
7422
+ };
7423
+ exports.EOL = '\n';
7424
+ exports.homedir = function() {
7425
+ return '/';
7426
+ };
7427
+ },
7428
+ "../../node_modules/.pnpm/picocolors@1.1.1/node_modules/picocolors/picocolors.browser.js" (module) {
7429
+ var x = String;
7430
+ var create = function() {
7431
+ return {
7432
+ isColorSupported: false,
7433
+ reset: x,
7434
+ bold: x,
7435
+ dim: x,
7436
+ italic: x,
7437
+ underline: x,
7438
+ inverse: x,
7439
+ hidden: x,
7440
+ strikethrough: x,
7441
+ black: x,
7442
+ red: x,
7443
+ green: x,
7444
+ yellow: x,
7445
+ blue: x,
7446
+ magenta: x,
7447
+ cyan: x,
7448
+ white: x,
7449
+ gray: x,
7450
+ bgBlack: x,
7451
+ bgRed: x,
7452
+ bgGreen: x,
7453
+ bgYellow: x,
7454
+ bgBlue: x,
7455
+ bgMagenta: x,
7456
+ bgCyan: x,
7457
+ bgWhite: x,
7458
+ blackBright: x,
7459
+ redBright: x,
7460
+ greenBright: x,
7461
+ yellowBright: x,
7462
+ blueBright: x,
7463
+ magentaBright: x,
7464
+ cyanBright: x,
7465
+ whiteBright: x,
7466
+ bgBlackBright: x,
7467
+ bgRedBright: x,
7468
+ bgGreenBright: x,
7469
+ bgYellowBright: x,
7470
+ bgBlueBright: x,
7471
+ bgMagentaBright: x,
7472
+ bgCyanBright: x,
7473
+ bgWhiteBright: x
7474
+ };
7475
+ };
7476
+ module.exports = create();
7477
+ module.exports.createColors = create;
7478
+ },
7381
7479
  "../../node_modules/.pnpm/possible-typed-array-names@1.1.0/node_modules/possible-typed-array-names/index.js" (module) {
7382
7480
  module.exports = [
7383
7481
  'Float16Array',
@@ -8701,6 +8799,19 @@ __webpack_require__.add({
8701
8799
  exports.setImmediate = "u" > typeof self && self.setImmediate || void 0 !== __webpack_require__.g && __webpack_require__.g.setImmediate || this && this.setImmediate;
8702
8800
  exports.clearImmediate = "u" > typeof self && self.clearImmediate || void 0 !== __webpack_require__.g && __webpack_require__.g.clearImmediate || this && this.clearImmediate;
8703
8801
  },
8802
+ "../../node_modules/.pnpm/tty-browserify@0.0.1/node_modules/tty-browserify/index.js" (__unused_rspack_module, exports) {
8803
+ exports.isatty = function() {
8804
+ return false;
8805
+ };
8806
+ function ReadStream() {
8807
+ throw new Error('tty.ReadStream is not implemented');
8808
+ }
8809
+ exports.ReadStream = ReadStream;
8810
+ function WriteStream() {
8811
+ throw new Error('tty.WriteStream is not implemented');
8812
+ }
8813
+ exports.WriteStream = WriteStream;
8814
+ },
8704
8815
  "../../node_modules/.pnpm/type-detect@4.0.8/node_modules/type-detect/type-detect.js" (module, __unused_rspack_exports, __webpack_require__) {
8705
8816
  (function(global, factory) {
8706
8817
  module.exports = factory();
@@ -17760,6 +17871,302 @@ const JestExtend = (chai, utils)=>{
17760
17871
  use(JestExtendPlugin(chai, expect, expects));
17761
17872
  });
17762
17873
  };
17874
+ const browser = __webpack_require__("../../node_modules/.pnpm/process@0.11.10/node_modules/process/browser.js");
17875
+ const browser_0 = __webpack_require__("../../node_modules/.pnpm/os-browserify@0.3.0/node_modules/os-browserify/browser.js");
17876
+ const tty_browserify = __webpack_require__("../../node_modules/.pnpm/tty-browserify@0.0.1/node_modules/tty-browserify/index.js");
17877
+ function hasFlag(flag, argv = globalThis.Deno ? globalThis.Deno.args : browser.argv) {
17878
+ const prefix = flag.startsWith('-') ? '' : 1 === flag.length ? '-' : '--';
17879
+ const position = argv.indexOf(prefix + flag);
17880
+ const terminatorPosition = argv.indexOf('--');
17881
+ return -1 !== position && (-1 === terminatorPosition || position < terminatorPosition);
17882
+ }
17883
+ const { env: env } = browser;
17884
+ let flagForceColor;
17885
+ if (hasFlag('no-color') || hasFlag('no-colors') || hasFlag('color=false') || hasFlag('color=never')) flagForceColor = 0;
17886
+ else if (hasFlag('color') || hasFlag('colors') || hasFlag('color=true') || hasFlag('color=always')) flagForceColor = 1;
17887
+ function envForceColor() {
17888
+ if (!('FORCE_COLOR' in env)) return;
17889
+ if ('true' === env.FORCE_COLOR) return 1;
17890
+ if ('false' === env.FORCE_COLOR) return 0;
17891
+ if (0 === env.FORCE_COLOR.length) return 1;
17892
+ const level = Math.min(Number.parseInt(env.FORCE_COLOR, 10), 3);
17893
+ if (![
17894
+ 0,
17895
+ 1,
17896
+ 2,
17897
+ 3
17898
+ ].includes(level)) return;
17899
+ return level;
17900
+ }
17901
+ function translateLevel(level) {
17902
+ if (0 === level) return false;
17903
+ return {
17904
+ level,
17905
+ hasBasic: true,
17906
+ has256: level >= 2,
17907
+ has16m: level >= 3
17908
+ };
17909
+ }
17910
+ function _supportsColor(haveStream, { streamIsTTY, sniffFlags = true } = {}) {
17911
+ const noFlagForceColor = envForceColor();
17912
+ if (void 0 !== noFlagForceColor) flagForceColor = noFlagForceColor;
17913
+ const forceColor = sniffFlags ? flagForceColor : noFlagForceColor;
17914
+ if (0 === forceColor) return 0;
17915
+ if (sniffFlags) {
17916
+ if (hasFlag('color=16m') || hasFlag('color=full') || hasFlag('color=truecolor')) return 3;
17917
+ if (hasFlag('color=256')) return 2;
17918
+ }
17919
+ if ('TF_BUILD' in env && 'AGENT_NAME' in env) return 1;
17920
+ if (haveStream && !streamIsTTY && void 0 === forceColor) return 0;
17921
+ const min = forceColor || 0;
17922
+ if ('dumb' === env.TERM) return min;
17923
+ if ('win32' === browser.platform) {
17924
+ const osRelease = browser_0.release().split('.');
17925
+ if (Number(osRelease[0]) >= 10 && Number(osRelease[2]) >= 10586) return Number(osRelease[2]) >= 14931 ? 3 : 2;
17926
+ return 1;
17927
+ }
17928
+ if ('CI' in env) {
17929
+ if ([
17930
+ 'GITHUB_ACTIONS',
17931
+ 'GITEA_ACTIONS',
17932
+ 'CIRCLECI'
17933
+ ].some((key)=>key in env)) return 3;
17934
+ if ([
17935
+ 'TRAVIS',
17936
+ 'APPVEYOR',
17937
+ 'GITLAB_CI',
17938
+ 'BUILDKITE',
17939
+ 'DRONE'
17940
+ ].some((sign)=>sign in env) || 'codeship' === env.CI_NAME) return 1;
17941
+ return min;
17942
+ }
17943
+ if ('TEAMCITY_VERSION' in env) return /^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(env.TEAMCITY_VERSION) ? 1 : 0;
17944
+ if ('truecolor' === env.COLORTERM) return 3;
17945
+ if ('xterm-kitty' === env.TERM) return 3;
17946
+ if ('xterm-ghostty' === env.TERM) return 3;
17947
+ if ('wezterm' === env.TERM) return 3;
17948
+ if ('TERM_PROGRAM' in env) {
17949
+ const version = Number.parseInt((env.TERM_PROGRAM_VERSION || '').split('.')[0], 10);
17950
+ switch(env.TERM_PROGRAM){
17951
+ case 'iTerm.app':
17952
+ return version >= 3 ? 3 : 2;
17953
+ case 'Apple_Terminal':
17954
+ return 2;
17955
+ }
17956
+ }
17957
+ if (/-256(color)?$/i.test(env.TERM)) return 2;
17958
+ if (/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(env.TERM)) return 1;
17959
+ if ('COLORTERM' in env) return 1;
17960
+ return min;
17961
+ }
17962
+ function createSupportsColor(stream, options = {}) {
17963
+ const level = _supportsColor(stream, {
17964
+ streamIsTTY: stream && stream.isTTY,
17965
+ ...options
17966
+ });
17967
+ return translateLevel(level);
17968
+ }
17969
+ const supportsColor = {
17970
+ stdout: createSupportsColor({
17971
+ isTTY: tty_browserify.isatty(1)
17972
+ }),
17973
+ stderr: createSupportsColor({
17974
+ isTTY: tty_browserify.isatty(2)
17975
+ })
17976
+ };
17977
+ const supports_color = supportsColor;
17978
+ const colorLevel = supports_color.stdout ? supports_color.stdout.level : 0;
17979
+ let errorStackRegExp = /at [^\r\n]{0,200}:\d+:\d+[\s\)]*$/;
17980
+ let anonymousErrorStackRegExp = /at [^\r\n]{0,200}\(<anonymous>\)$/;
17981
+ let indexErrorStackRegExp = /at [^\r\n]{0,200}\(index\s\d+\)$/;
17982
+ let isErrorStackMessage = (message)=>errorStackRegExp.test(message) || anonymousErrorStackRegExp.test(message) || indexErrorStackRegExp.test(message);
17983
+ let formatter = (open, close, replace = open)=>colorLevel >= 2 ? (input)=>{
17984
+ let string = '' + input;
17985
+ let index = string.indexOf(close, open.length);
17986
+ return ~index ? open + replaceClose(string, close, replace, index) + close : open + string + close;
17987
+ } : String;
17988
+ let replaceClose = (string, close, replace, index)=>{
17989
+ let start = string.substring(0, index) + replace;
17990
+ let end = string.substring(index + close.length);
17991
+ let nextIndex = end.indexOf(close);
17992
+ return ~nextIndex ? start + replaceClose(end, close, replace, nextIndex) : start + end;
17993
+ };
17994
+ const bold = formatter('\x1b[1m', '\x1b[22m', '\x1b[22m\x1b[1m');
17995
+ const red = formatter('\x1b[31m', '\x1b[39m');
17996
+ const green = formatter('\x1b[32m', '\x1b[39m');
17997
+ const yellow = formatter('\x1b[33m', '\x1b[39m');
17998
+ const magenta = formatter('\x1b[35m', '\x1b[39m');
17999
+ const cyan = formatter('\x1b[36m', '\x1b[39m');
18000
+ const gray = formatter('\x1b[90m', '\x1b[39m');
18001
+ let startColor = [
18002
+ 189,
18003
+ 255,
18004
+ 243
18005
+ ];
18006
+ let endColor = [
18007
+ 74,
18008
+ 194,
18009
+ 154
18010
+ ];
18011
+ let isWord = (char)=>!/[\s\n]/.test(char);
18012
+ let gradient = (message)=>{
18013
+ if (colorLevel < 3) return 2 === colorLevel ? bold(cyan(message)) : message;
18014
+ let chars = [
18015
+ ...message
18016
+ ];
18017
+ let steps = chars.filter(isWord).length;
18018
+ let r = startColor[0];
18019
+ let g = startColor[1];
18020
+ let b = startColor[2];
18021
+ let rStep = (endColor[0] - r) / steps;
18022
+ let gStep = (endColor[1] - g) / steps;
18023
+ let bStep = (endColor[2] - b) / steps;
18024
+ let output = '';
18025
+ for (let char of chars){
18026
+ if (isWord(char)) {
18027
+ r += rStep;
18028
+ g += gStep;
18029
+ b += bStep;
18030
+ }
18031
+ output += `\x1b[38;2;${Math.round(r)};${Math.round(g)};${Math.round(b)}m${char}\x1b[39m`;
18032
+ }
18033
+ return bold(output);
18034
+ };
18035
+ let LOG_LEVEL = {
18036
+ silent: -1,
18037
+ error: 0,
18038
+ warn: 1,
18039
+ info: 2,
18040
+ log: 2,
18041
+ verbose: 3
18042
+ };
18043
+ let LOG_TYPES = {
18044
+ error: {
18045
+ label: 'error',
18046
+ level: 'error',
18047
+ color: red
18048
+ },
18049
+ warn: {
18050
+ label: 'warn',
18051
+ level: 'warn',
18052
+ color: yellow
18053
+ },
18054
+ info: {
18055
+ label: 'info',
18056
+ level: 'info',
18057
+ color: cyan
18058
+ },
18059
+ start: {
18060
+ label: 'start',
18061
+ level: 'info',
18062
+ color: cyan
18063
+ },
18064
+ ready: {
18065
+ label: 'ready',
18066
+ level: 'info',
18067
+ color: green
18068
+ },
18069
+ success: {
18070
+ label: 'success',
18071
+ level: 'info',
18072
+ color: green
18073
+ },
18074
+ log: {
18075
+ level: 'info'
18076
+ },
18077
+ debug: {
18078
+ label: 'debug',
18079
+ level: 'verbose',
18080
+ color: magenta
18081
+ }
18082
+ };
18083
+ const dist_normalizeErrorMessage = (err)=>{
18084
+ if (err.stack) {
18085
+ let [name, ...rest] = err.stack.split('\n');
18086
+ if (name.startsWith('Error: ')) name = name.slice(7);
18087
+ return `${name}\n${gray(rest.join('\n'))}`;
18088
+ }
18089
+ return err.message;
18090
+ };
18091
+ let createLogger = (options = {})=>{
18092
+ let maxLevel = options.level || 'info';
18093
+ let log = (type, message, ...args)=>{
18094
+ let logType = LOG_TYPES[type];
18095
+ const { level } = logType;
18096
+ if (LOG_LEVEL[level] > LOG_LEVEL[maxLevel]) return;
18097
+ if (null == message) return console.log();
18098
+ let label = '';
18099
+ let text = '';
18100
+ if ('label' in logType) {
18101
+ label = (logType.label || '').padEnd(7);
18102
+ label = bold(logType.color ? logType.color(label) : label);
18103
+ }
18104
+ if (message instanceof Error) {
18105
+ text += dist_normalizeErrorMessage(message);
18106
+ const { cause } = message;
18107
+ if (cause) {
18108
+ text += yellow('\n [cause]: ');
18109
+ text += cause instanceof Error ? dist_normalizeErrorMessage(cause) : String(cause);
18110
+ }
18111
+ } else if ('error' === level && 'string' == typeof message) {
18112
+ let lines = message.split('\n');
18113
+ text = lines.map((line)=>isErrorStackMessage(line) ? gray(line) : line).join('\n');
18114
+ } else text = `${message}`;
18115
+ const method = 'error' === level || 'warn' === level ? level : 'log';
18116
+ console[method](label.length ? `${label} ${text}` : text, ...args);
18117
+ };
18118
+ let logger = {
18119
+ greet: (message)=>log('log', gradient(message))
18120
+ };
18121
+ Object.keys(LOG_TYPES).forEach((key)=>{
18122
+ logger[key] = (...args)=>log(key, ...args);
18123
+ });
18124
+ Object.defineProperty(logger, 'level', {
18125
+ get: ()=>maxLevel,
18126
+ set (val) {
18127
+ maxLevel = val;
18128
+ }
18129
+ });
18130
+ logger.override = (customLogger)=>{
18131
+ Object.assign(logger, customLogger);
18132
+ };
18133
+ return logger;
18134
+ };
18135
+ let src_logger = createLogger();
18136
+ const picocolors_browser = __webpack_require__("../../node_modules/.pnpm/picocolors@1.1.1/node_modules/picocolors/picocolors.browser.js");
18137
+ var logger_process = __webpack_require__("../../node_modules/.pnpm/process@0.11.10/node_modules/process/browser.js");
18138
+ const isDebug = ()=>{
18139
+ if (!logger_process.env.DEBUG) return false;
18140
+ const values = logger_process.env.DEBUG.toLocaleLowerCase().split(',');
18141
+ return [
18142
+ 'rstest',
18143
+ 'rsbuild',
18144
+ 'builder',
18145
+ '*'
18146
+ ].some((key)=>values.includes(key));
18147
+ };
18148
+ const logger_color = (0, picocolors_browser.createColors)();
18149
+ if (isDebug()) src_logger.level = 'verbose';
18150
+ function getTime() {
18151
+ const now = new Date();
18152
+ const hours = String(now.getHours()).padStart(2, '0');
18153
+ const minutes = String(now.getMinutes()).padStart(2, '0');
18154
+ const seconds = String(now.getSeconds()).padStart(2, '0');
18155
+ return `${hours}:${minutes}:${seconds}`;
18156
+ }
18157
+ src_logger.override({
18158
+ debug: (message, ...args)=>{
18159
+ if ('verbose' !== src_logger.level) return;
18160
+ const time = logger_color.gray(getTime());
18161
+ console.log(` ${logger_color.magenta('rstest')} ${time} ${message}`, ...args);
18162
+ }
18163
+ });
18164
+ ({
18165
+ ...src_logger,
18166
+ stderr: (message, ...args)=>{
18167
+ console.error(message, ...args);
18168
+ }
18169
+ });
17763
18170
  var helper_process = __webpack_require__("../../node_modules/.pnpm/process@0.11.10/node_modules/process/browser.js");
17764
18171
  const helper_isObject = (obj)=>'[object Object]' === Object.prototype.toString.call(obj);
17765
18172
  const castArray = (arr)=>{
@@ -18079,11 +18486,11 @@ const pathe_M_eThtNZ_isAbsolute = function(p) {
18079
18486
  };
18080
18487
  var snapshot_dist_process = __webpack_require__("../../node_modules/.pnpm/process@0.11.10/node_modules/process/browser.js");
18081
18488
  const comma = ','.charCodeAt(0);
18082
- const chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
18489
+ const dist_chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
18083
18490
  const intToChar = new Uint8Array(64);
18084
18491
  const charToInt = new Uint8Array(128);
18085
- for(let i = 0; i < chars.length; i++){
18086
- const c = chars.charCodeAt(i);
18492
+ for(let i = 0; i < dist_chars.length; i++){
18493
+ const c = dist_chars.charCodeAt(i);
18087
18494
  intToChar[i] = c;
18088
18495
  charToInt[c] = i;
18089
18496
  }
@@ -18589,10 +18996,10 @@ function parseSingleV8Stack(raw) {
18589
18996
  if (!CHROME_IE_STACK_REGEXP.test(line)) return null;
18590
18997
  if (line.includes("(eval ")) line = line.replace(/eval code/g, "eval").replace(/(\(eval at [^()]*)|(,.*$)/g, "");
18591
18998
  let sanitizedLine = line.replace(/^\s+/, "").replace(/\(eval code/g, "(").replace(/^.*?\s+/, "");
18592
- const location = sanitizedLine.match(/ (\(.+\)$)/);
18593
- sanitizedLine = location ? sanitizedLine.replace(location[0], "") : sanitizedLine;
18594
- const [url, lineNumber, columnNumber] = extractLocation(location ? location[1] : sanitizedLine);
18595
- let method = location && sanitizedLine || "";
18999
+ const location1 = sanitizedLine.match(/ (\(.+\)$)/);
19000
+ sanitizedLine = location1 ? sanitizedLine.replace(location1[0], "") : sanitizedLine;
19001
+ const [url, lineNumber, columnNumber] = extractLocation(location1 ? location1[1] : sanitizedLine);
19002
+ let method = location1 && sanitizedLine || "";
18596
19003
  let file = url && [
18597
19004
  "eval",
18598
19005
  "<anonymous>"
@@ -21151,7 +21558,7 @@ class RunnerRuntime {
21151
21558
  type: 'suite'
21152
21559
  };
21153
21560
  }
21154
- describe({ name, fn, runMode = 'run', each = false, concurrent, sequential, location }) {
21561
+ describe({ name, fn, runMode = 'run', each = false, concurrent, sequential, location: location1 }) {
21155
21562
  this.checkStatus(name, 'suite');
21156
21563
  const currentSuite = {
21157
21564
  project: this.project,
@@ -21163,7 +21570,7 @@ class RunnerRuntime {
21163
21570
  testPath: this.testPath,
21164
21571
  concurrent,
21165
21572
  sequential,
21166
- location
21573
+ location: location1
21167
21574
  };
21168
21575
  if (!fn) {
21169
21576
  this.addTest(currentSuite);
@@ -21232,7 +21639,7 @@ class RunnerRuntime {
21232
21639
  ensureRootSuite() {
21233
21640
  if (0 === this._currentTest.length) this.addTest(this.getDefaultRootSuite());
21234
21641
  }
21235
- it({ name, fn, originalFn = fn, fixtures, timeout = this.runtimeConfig.testTimeout, runMode = 'run', fails = false, each = false, concurrent, sequential, location }) {
21642
+ it({ name, fn, originalFn = fn, fixtures, timeout = this.runtimeConfig.testTimeout, runMode = 'run', fails = false, each = false, concurrent, sequential, location: location1 }) {
21236
21643
  this.checkStatus(name, 'case');
21237
21644
  this.addTestCase({
21238
21645
  project: this.project,
@@ -21250,7 +21657,7 @@ class RunnerRuntime {
21250
21657
  fails,
21251
21658
  onFinished: [],
21252
21659
  onFailed: [],
21253
- location
21660
+ location: location1
21254
21661
  });
21255
21662
  }
21256
21663
  describeEach({ cases, ...options }) {
@@ -21705,6 +22112,152 @@ class FakeTimers {
21705
22112
  this._fakeTimers = (0, fake_timers_src.withGlobal)(global);
21706
22113
  }
21707
22114
  }
22115
+ function getTypeName(value) {
22116
+ return Object.prototype.toString.call(value).slice(8, -1);
22117
+ }
22118
+ function mockObject_isPlainObject(value) {
22119
+ if (!value || 'object' != typeof value) return false;
22120
+ const type = getTypeName(value);
22121
+ return 'Object' === type || 'Module' === type;
22122
+ }
22123
+ function isFunction(value) {
22124
+ return 'function' == typeof value;
22125
+ }
22126
+ function isBuiltinReadonly(target, prop) {
22127
+ const builtinFunctionProps = [
22128
+ 'arguments',
22129
+ 'callee',
22130
+ 'caller',
22131
+ 'length',
22132
+ 'name'
22133
+ ];
22134
+ const builtinRegExpProps = [
22135
+ 'source',
22136
+ 'global',
22137
+ 'flags'
22138
+ ];
22139
+ const type = getTypeName(target);
22140
+ if (builtinFunctionProps.includes(prop)) return 'Function' === type || 'AsyncFunction' === type;
22141
+ if (builtinRegExpProps.includes(prop)) return 'RegExp' === type;
22142
+ return false;
22143
+ }
22144
+ function collectPrototypeMethods(proto) {
22145
+ const methods = [];
22146
+ let current = proto;
22147
+ while(current && current !== Object.prototype){
22148
+ for (const key of [
22149
+ ...Object.getOwnPropertyNames(current),
22150
+ ...Object.getOwnPropertySymbols(current)
22151
+ ]){
22152
+ if ('constructor' === key) continue;
22153
+ const descriptor = Object.getOwnPropertyDescriptor(current, key);
22154
+ if (descriptor?.value && 'function' == typeof descriptor.value) methods.push(key);
22155
+ }
22156
+ current = Object.getPrototypeOf(current);
22157
+ }
22158
+ return methods;
22159
+ }
22160
+ function getEnumerableProperties(obj, constructors) {
22161
+ const props = new Set();
22162
+ const isModule = 'Module' === getTypeName(obj) || obj.__esModule;
22163
+ if (isModule) {
22164
+ for (const k of Object.getOwnPropertyNames(obj))props.add(k);
22165
+ for (const k of Object.getOwnPropertySymbols(obj))props.add(k);
22166
+ return [
22167
+ ...props
22168
+ ];
22169
+ }
22170
+ const builtinPrototypes = [
22171
+ constructors.Object.prototype,
22172
+ constructors.Function.prototype,
22173
+ constructors.Array.prototype,
22174
+ constructors.Map.prototype,
22175
+ constructors.RegExp.prototype
22176
+ ];
22177
+ let current = obj;
22178
+ while(current && !builtinPrototypes.includes(current)){
22179
+ for (const key of [
22180
+ ...Object.getOwnPropertyNames(current),
22181
+ ...Object.getOwnPropertySymbols(current)
22182
+ ])if ('constructor' !== key) props.add(key);
22183
+ current = Object.getPrototypeOf(current);
22184
+ }
22185
+ return [
22186
+ ...props
22187
+ ];
22188
+ }
22189
+ function mockObject(options, object, mockExports = {}) {
22190
+ const { createMockInstance, globalConstructors, type } = options;
22191
+ const isSpyMode = 'autospy' === type;
22192
+ const processedRefs = new WeakMap();
22193
+ const deferredAssignments = [];
22194
+ const createFunctionMock = (fn)=>{
22195
+ const prototypeMembers = fn.prototype ? collectPrototypeMethods(fn.prototype) : [];
22196
+ return createMockInstance({
22197
+ name: fn.name,
22198
+ prototypeMembers,
22199
+ originalImplementation: isSpyMode ? fn : void 0,
22200
+ keepMembersImplementation: isSpyMode
22201
+ });
22202
+ };
22203
+ const processValue = (value)=>{
22204
+ if (null == value) return value;
22205
+ if ('object' != typeof value && 'function' != typeof value) return value;
22206
+ if (value._isMockFunction) return value;
22207
+ if ('object' == typeof value && processedRefs.has(value)) return processedRefs.get(value);
22208
+ if (isFunction(value)) {
22209
+ const mock = createFunctionMock(value);
22210
+ processProperties(value, mock);
22211
+ return mock;
22212
+ }
22213
+ if (Array.isArray(value)) {
22214
+ if (!isSpyMode) return [];
22215
+ return value.map(processValue);
22216
+ }
22217
+ if (mockObject_isPlainObject(value)) {
22218
+ const result = {};
22219
+ processedRefs.set(value, result);
22220
+ processProperties(value, result);
22221
+ return result;
22222
+ }
22223
+ return value;
22224
+ };
22225
+ const processProperties = (source, target)=>{
22226
+ const props = getEnumerableProperties(source, globalConstructors);
22227
+ const isModule = 'Module' === getTypeName(source) || source.__esModule;
22228
+ for (const prop of props){
22229
+ if (isBuiltinReadonly(source, prop)) continue;
22230
+ const descriptor = Object.getOwnPropertyDescriptor(source, prop);
22231
+ if (!descriptor) continue;
22232
+ if (!isModule && descriptor.get) {
22233
+ try {
22234
+ if (isSpyMode) Object.defineProperty(target, prop, descriptor);
22235
+ else Object.defineProperty(target, prop, {
22236
+ configurable: descriptor.configurable,
22237
+ enumerable: descriptor.enumerable,
22238
+ get: ()=>void 0,
22239
+ set: descriptor.set ? ()=>{} : void 0
22240
+ });
22241
+ } catch {}
22242
+ continue;
22243
+ }
22244
+ const value = source[prop];
22245
+ if (value && 'object' == typeof value && processedRefs.has(value)) {
22246
+ deferredAssignments.push(()=>{
22247
+ target[prop] = processedRefs.get(value);
22248
+ });
22249
+ continue;
22250
+ }
22251
+ try {
22252
+ target[prop] = processValue(value);
22253
+ } catch {}
22254
+ }
22255
+ };
22256
+ processedRefs.set(object, mockExports);
22257
+ processProperties(object, mockExports);
22258
+ for (const assign of deferredAssignments)assign();
22259
+ return mockExports;
22260
+ }
21708
22261
  const spy_isMockFunction = (fn)=>'function' == typeof fn && '_isMockFunction' in fn && fn._isMockFunction;
21709
22262
  const initSpy = ()=>{
21710
22263
  let callOrder = 0;
@@ -21843,11 +22396,46 @@ const initSpy = ()=>{
21843
22396
  } : methodName;
21844
22397
  return wrapSpy(obj, method);
21845
22398
  };
22399
+ const createMockInstance = (options)=>{
22400
+ const { name, originalImplementation, prototypeMembers = [], keepMembersImplementation = false } = options || {};
22401
+ const mockName = name ? String(name) : 'rstest.fn()';
22402
+ const isClass = originalImplementation && /^class\s/.test(Function.prototype.toString.call(originalImplementation));
22403
+ if (isClass && originalImplementation) {
22404
+ const classWrapper = function(...args) {
22405
+ const instance = Reflect.construct(originalImplementation, args, new.target || originalImplementation);
22406
+ if (keepMembersImplementation && prototypeMembers.length > 0) for (const memberName of prototypeMembers){
22407
+ const originalMethod = instance[memberName];
22408
+ if ('function' == typeof originalMethod) {
22409
+ const methodSpy = wrapSpy(instance, memberName, originalMethod.bind(instance));
22410
+ instance[memberName] = methodSpy;
22411
+ }
22412
+ }
22413
+ return instance;
22414
+ };
22415
+ Object.defineProperty(classWrapper, 'name', {
22416
+ value: mockName,
22417
+ configurable: true
22418
+ });
22419
+ classWrapper.prototype = originalImplementation.prototype;
22420
+ const mock = wrapSpy({
22421
+ [mockName]: classWrapper
22422
+ }, mockName, classWrapper);
22423
+ Object.setPrototypeOf(mock, Function.prototype);
22424
+ mock.prototype = originalImplementation.prototype;
22425
+ return mock;
22426
+ }
22427
+ const mock = wrapSpy({
22428
+ [mockName]: originalImplementation
22429
+ }, mockName, originalImplementation);
22430
+ if (prototypeMembers.length > 0 && originalImplementation?.prototype) Object.setPrototypeOf(mock.prototype, originalImplementation.prototype);
22431
+ return mock;
22432
+ };
21846
22433
  return {
21847
22434
  isMockFunction: spy_isMockFunction,
21848
22435
  spyOn,
21849
22436
  fn,
21850
- mocks
22437
+ mocks,
22438
+ createMockInstance
21851
22439
  };
21852
22440
  };
21853
22441
  var utilities_process = __webpack_require__("../../node_modules/.pnpm/process@0.11.10/node_modules/process/browser.js");
@@ -21862,11 +22450,25 @@ const createRstestUtilities = async (workerState)=>{
21862
22450
  });
21863
22451
  return _timers;
21864
22452
  };
21865
- const { fn, spyOn, isMockFunction, mocks } = initSpy();
22453
+ const { fn, spyOn, isMockFunction, mocks, createMockInstance } = initSpy();
21866
22454
  const rstest = {
21867
22455
  fn,
21868
22456
  spyOn,
21869
22457
  isMockFunction,
22458
+ mockObject: (value, options)=>mockObject({
22459
+ globalConstructors: {
22460
+ Object,
22461
+ Function,
22462
+ Array,
22463
+ Map,
22464
+ RegExp
22465
+ },
22466
+ createMockInstance,
22467
+ type: options?.spy ? 'autospy' : 'automock'
22468
+ }, {
22469
+ value
22470
+ }, {}).value,
22471
+ mocked: (item)=>item,
21870
22472
  clearAllMocks: ()=>{
21871
22473
  for (const mock of mocks)mock.mockClear();
21872
22474
  return rstest;