@rstest/core 0.7.8 → 0.7.9

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.
Files changed (56) hide show
  1. package/LICENSE.md +294 -0
  2. package/dist/0~130.js +2 -2
  3. package/dist/0~1472.js +48 -0
  4. package/dist/0~1981.js +3 -0
  5. package/dist/0~2173.js +25 -10
  6. package/dist/0~2255.js +2 -2
  7. package/dist/0~3062.js +0 -5
  8. package/dist/0~3919.js +1 -1
  9. package/dist/0~4403.js +6 -5
  10. package/dist/0~4809.js +1 -1
  11. package/dist/0~5835.js +2 -2
  12. package/dist/0~62.js +1 -1
  13. package/dist/0~6588.js +3 -3
  14. package/dist/0~6923.js +2 -2
  15. package/dist/0~7583.js +9 -8
  16. package/dist/0~7882.js +1144 -0
  17. package/dist/0~8426.js +1 -2
  18. package/dist/0~89.js +24 -21
  19. package/dist/0~9348.js +953 -0
  20. package/dist/0~9634.js +58 -10
  21. package/dist/1157.js +12 -117
  22. package/dist/{7913.js → 1294.js} +51 -1745
  23. package/dist/2672.js +647 -0
  24. package/dist/3278.js +3 -450
  25. package/dist/4484.js +38 -0
  26. package/dist/487.js +1739 -0
  27. package/dist/4899.js +11 -0
  28. package/dist/5734.js +1 -1
  29. package/dist/{0~6151.js → 6151.js} +169 -13
  30. package/dist/{0~6973.js → 6973.js} +5 -5
  31. package/dist/721.js +9 -0
  32. package/dist/9131.js +554 -502
  33. package/dist/browser-runtime/2~907.js +1211 -0
  34. package/dist/browser-runtime/2~907.js.map +1 -0
  35. package/dist/browser-runtime/389.js +22071 -0
  36. package/dist/browser-runtime/389.js.LICENSE.txt +329 -0
  37. package/dist/browser-runtime/389.js.map +1 -0
  38. package/dist/browser-runtime/index.d.ts +2806 -0
  39. package/dist/browser-runtime/index.js +1 -0
  40. package/dist/browser-runtime/rslib-runtime.js +50 -0
  41. package/dist/browser-runtime/rslib-runtime.js.map +1 -0
  42. package/dist/browser.d.ts +3329 -0
  43. package/dist/browser.js +14 -0
  44. package/dist/globalSetupWorker.js +3 -2
  45. package/dist/index.d.ts +58 -1
  46. package/dist/index.js +2 -1
  47. package/dist/rslib-runtime.js +27 -0
  48. package/dist/rstestSuppressWarnings.cjs +9 -0
  49. package/dist/worker.d.ts +57 -1
  50. package/dist/worker.js +415 -1
  51. package/package.json +28 -13
  52. package/dist/0~8957.js +0 -149
  53. package/dist/554.js +0 -417
  54. package/dist/5693.js +0 -91
  55. /package/dist/{7913.js.LICENSE.txt → 1294.js.LICENSE.txt} +0 -0
  56. /package/dist/{0~6151.js.LICENSE.txt → 6151.js.LICENSE.txt} +0 -0
package/dist/4899.js ADDED
@@ -0,0 +1,11 @@
1
+ import __rslib_shim_module__ from 'module';
2
+ const require = /*#__PURE__*/ __rslib_shim_module__.createRequire(import.meta.url);
3
+ import { __webpack_require__ } from "./rslib-runtime.js";
4
+ __webpack_require__.add({
5
+ timers (module) {
6
+ module.exports = require("timers");
7
+ },
8
+ "timers/promises" (module) {
9
+ module.exports = require("timers/promises");
10
+ }
11
+ });
package/dist/5734.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import 'module';
2
2
  /*#__PURE__*/ import.meta.url;
3
3
  import { __webpack_require__ } from "./rslib-runtime.js";
4
- import "./5693.js";
4
+ import "./2672.js";
5
5
  import { createRequire } from "./4881.js";
6
6
  import { pathToFileURL } from "./6198.js";
7
7
  import "./1157.js";
@@ -1,14 +1,13 @@
1
- /*! For license information please see 0~6151.js.LICENSE.txt */
1
+ /*! For license information please see 6151.js.LICENSE.txt */
2
2
  import 'module';
3
3
  /*#__PURE__*/ import.meta.url;
4
4
  import { __webpack_require__ } from "./rslib-runtime.js";
5
- import "./5693.js";
6
- import { getRealTimers, TestRegisterError, formatTestError, formatName } from "./7913.js";
7
- import { resolve as pathe_M_eThtNZ_resolve } from "./3278.js";
8
- import { getTaskNameWithPrefix, isObject as helper_isObject, castArray, ROOT_SUITE_NAME } from "./1157.js";
9
- import { fileURLToPath } from "./6198.js";
5
+ import { getTaskNameWithPrefix, isObject as helper_isObject, castArray, resolve as pathe_M_eThtNZ_resolve, normalize } from "./2672.js";
6
+ import { getRealTimers, TestRegisterError, formatTestError, formatName } from "./1294.js";
7
+ import { ROOT_SUITE_NAME } from "./1157.js";
10
8
  import { parse } from "./1672.js";
11
- import "./554.js";
9
+ import "./4899.js";
10
+ import "./721.js";
12
11
  __webpack_require__.add({
13
12
  "../../node_modules/.pnpm/@sinonjs+commons@3.0.1/node_modules/@sinonjs/commons/lib/called-in-order.js" (module, __unused_rspack_exports, __webpack_require__) {
14
13
  var every = __webpack_require__("../../node_modules/.pnpm/@sinonjs+commons@3.0.1/node_modules/@sinonjs/commons/lib/prototypes/array.js").every;
@@ -12581,7 +12580,22 @@ class TestRunner {
12581
12580
  if (true === isExpectingAssertions && 0 === assertionCalls) throw isExpectingAssertionsError;
12582
12581
  }
12583
12582
  }
12584
- const external_node_path_ = __webpack_require__("node:path");
12583
+ const url_extras_isWindows = globalThis.process?.platform === 'win32';
12584
+ function fileURLToPath(url, options) {
12585
+ if ('string' != typeof url && !(url instanceof URL)) throw new TypeError(`Expected \`string\` or \`URL\`, got \`${typeof url}\``);
12586
+ const useWindowsRules = options?.windows ?? url_extras_isWindows;
12587
+ const urlObject = new URL(url);
12588
+ if ('file:' !== urlObject.protocol) throw new TypeError('The URL must be a file URL');
12589
+ const { hostname, pathname } = urlObject;
12590
+ if (/%2[Ff]/.test(pathname)) throw new TypeError('File URL path must not include encoded / characters');
12591
+ const path = decodeURIComponent(pathname);
12592
+ if (useWindowsRules && /^\/[A-Za-z]:/.test(path)) return path.slice(1).replaceAll('/', '\\');
12593
+ if (hostname && 'localhost' !== hostname) {
12594
+ if (!useWindowsRules) throw new TypeError('File URL host must be "localhost" or empty');
12595
+ return `\\\\${hostname}${path.replaceAll('/', '\\')}`;
12596
+ }
12597
+ return path;
12598
+ }
12585
12599
  class RunnerRuntime {
12586
12600
  tests = [];
12587
12601
  _currentTest = [];
@@ -12835,7 +12849,7 @@ const createRuntimeAPI = ({ testPath, runtimeConfig, project })=>{
12835
12849
  for (const frame of frames){
12836
12850
  let filename = frame.file ?? '';
12837
12851
  if (filename.startsWith('file://')) filename = fileURLToPath(filename);
12838
- filename = filename.replaceAll(external_node_path_["default"].sep, '/');
12852
+ filename = normalize(filename);
12839
12853
  if (filename === testPath) {
12840
12854
  const line = frame.lineNumber;
12841
12855
  const column = frame.column;
@@ -13181,6 +13195,151 @@ class FakeTimers {
13181
13195
  return this._fakingTime;
13182
13196
  }
13183
13197
  }
13198
+ const spy_isMockFunction = (fn)=>'function' == typeof fn && '_isMockFunction' in fn && fn._isMockFunction;
13199
+ const initSpy = ()=>{
13200
+ let callOrder = 0;
13201
+ const mocks = new Set();
13202
+ const wrapSpy = (obj, methodName, mockFn)=>{
13203
+ const spyImpl = M(obj, methodName, mockFn);
13204
+ const spyFn = spyImpl;
13205
+ let mockImplementationOnce = [];
13206
+ let implementation = mockFn;
13207
+ let mockName = mockFn?.name;
13208
+ const initMockState = ()=>({
13209
+ instances: [],
13210
+ contexts: [],
13211
+ invocationCallOrder: []
13212
+ });
13213
+ let mockState = initMockState();
13214
+ const spyState = T(spyImpl);
13215
+ spyFn.getMockName = ()=>mockName || methodName;
13216
+ spyFn.mockName = (name)=>{
13217
+ mockName = name;
13218
+ return spyFn;
13219
+ };
13220
+ spyFn.getMockImplementation = ()=>mockImplementationOnce.length ? mockImplementationOnce[mockImplementationOnce.length - 1] : implementation;
13221
+ function withImplementation(fn, cb) {
13222
+ const originalImplementation = implementation;
13223
+ const originalMockImplementationOnce = mockImplementationOnce;
13224
+ implementation = fn;
13225
+ mockImplementationOnce = [];
13226
+ spyState.willCall(willCall);
13227
+ const reset = ()=>{
13228
+ implementation = originalImplementation;
13229
+ mockImplementationOnce = originalMockImplementationOnce;
13230
+ };
13231
+ const result = cb();
13232
+ if (result instanceof Promise) return result.then(()=>{
13233
+ reset();
13234
+ });
13235
+ reset();
13236
+ }
13237
+ spyFn.withImplementation = withImplementation;
13238
+ spyFn.mockImplementation = (fn)=>{
13239
+ implementation = fn;
13240
+ return spyFn;
13241
+ };
13242
+ spyFn.mockImplementationOnce = (fn)=>{
13243
+ mockImplementationOnce.push(fn);
13244
+ return spyFn;
13245
+ };
13246
+ spyFn.mockReturnValue = (value)=>spyFn.mockImplementation(()=>value);
13247
+ spyFn.mockReturnValueOnce = (value)=>spyFn.mockImplementationOnce(()=>value);
13248
+ spyFn.mockResolvedValue = (value)=>spyFn.mockImplementation(()=>Promise.resolve(value));
13249
+ spyFn.mockResolvedValueOnce = (value)=>spyFn.mockImplementationOnce(()=>Promise.resolve(value));
13250
+ spyFn.mockRejectedValue = (value)=>spyFn.mockImplementation(()=>Promise.reject(value));
13251
+ spyFn.mockRejectedValueOnce = (value)=>spyFn.mockImplementationOnce(()=>Promise.reject(value));
13252
+ spyFn.mockReturnThis = ()=>spyFn.mockImplementation(function() {
13253
+ return this;
13254
+ });
13255
+ function willCall(...args) {
13256
+ let impl = implementation || spyState.getOriginal();
13257
+ mockState.instances.push(this);
13258
+ mockState.contexts.push(this);
13259
+ mockState.invocationCallOrder.push(++callOrder);
13260
+ if (mockImplementationOnce.length) impl = mockImplementationOnce.shift();
13261
+ return impl?.apply(this, args);
13262
+ }
13263
+ spyState.willCall(willCall);
13264
+ Object.defineProperty(spyFn, 'mock', {
13265
+ get: ()=>({
13266
+ get calls () {
13267
+ return spyState.calls;
13268
+ },
13269
+ get lastCall () {
13270
+ return spyState.calls[spyState.callCount - 1];
13271
+ },
13272
+ get instances () {
13273
+ return mockState.instances;
13274
+ },
13275
+ get contexts () {
13276
+ return mockState.contexts;
13277
+ },
13278
+ get invocationCallOrder () {
13279
+ return mockState.invocationCallOrder;
13280
+ },
13281
+ get results () {
13282
+ return spyState.results.map(([resultType, value])=>{
13283
+ const type = 'error' === resultType ? 'throw' : 'return';
13284
+ return {
13285
+ type: type,
13286
+ value
13287
+ };
13288
+ });
13289
+ },
13290
+ get settledResults () {
13291
+ return spyState.resolves.map(([resultType, value])=>{
13292
+ const type = 'error' === resultType ? 'rejected' : 'fulfilled';
13293
+ return {
13294
+ type,
13295
+ value
13296
+ };
13297
+ });
13298
+ }
13299
+ })
13300
+ });
13301
+ spyFn.mockClear = ()=>{
13302
+ mockState = initMockState();
13303
+ spyState.reset();
13304
+ return spyFn;
13305
+ };
13306
+ spyFn.mockReset = ()=>{
13307
+ spyFn.mockClear();
13308
+ implementation = mockFn;
13309
+ mockImplementationOnce = [];
13310
+ return spyFn;
13311
+ };
13312
+ spyFn.mockRestore = ()=>{
13313
+ spyFn.mockReset();
13314
+ spyState.restore();
13315
+ mockName = mockFn?.name;
13316
+ };
13317
+ mocks.add(spyFn);
13318
+ return spyFn;
13319
+ };
13320
+ const fn = (mockFn)=>{
13321
+ const defaultName = 'rstest.fn()';
13322
+ return wrapSpy({
13323
+ [defaultName]: mockFn
13324
+ }, defaultName, mockFn);
13325
+ };
13326
+ const spyOn = (obj, methodName, accessType)=>{
13327
+ const accessTypeMap = {
13328
+ get: 'getter',
13329
+ set: 'setter'
13330
+ };
13331
+ const method = accessType ? {
13332
+ [accessTypeMap[accessType]]: methodName
13333
+ } : methodName;
13334
+ return wrapSpy(obj, method);
13335
+ };
13336
+ return {
13337
+ isMockFunction: spy_isMockFunction,
13338
+ spyOn,
13339
+ fn,
13340
+ mocks
13341
+ };
13342
+ };
13184
13343
  const createRstestUtilities = async (workerState)=>{
13185
13344
  const originalEnvValues = new Map();
13186
13345
  const originalGlobalValues = new Map();
@@ -13192,9 +13351,6 @@ const createRstestUtilities = async (workerState)=>{
13192
13351
  });
13193
13352
  return _timers;
13194
13353
  };
13195
- const { initSpy } = await import("./0~8957.js").then((mod)=>({
13196
- initSpy: mod.initSpy
13197
- }));
13198
13354
  const { fn, spyOn, isMockFunction, mocks } = initSpy();
13199
13355
  const rstest = {
13200
13356
  fn,
@@ -13365,4 +13521,4 @@ const createRstestRuntime = async (workerState)=>{
13365
13521
  globalThis.RSTEST_API = runtime.api;
13366
13522
  return runtime;
13367
13523
  };
13368
- export { M, T, createRstestRuntime };
13524
+ export { createRstestRuntime };
@@ -1,16 +1,16 @@
1
1
  import 'module';
2
2
  /*#__PURE__*/ import.meta.url;
3
3
  import { __webpack_require__ } from "./rslib-runtime.js";
4
- import "./5693.js";
4
+ import { getAbsolutePath } from "./2672.js";
5
5
  import { fileURLToPath } from "./6198.js";
6
- import { rspack } from "./9131.js";
7
- import { getAbsolutePath, formatTestEntryName } from "./1157.js";
6
+ import { rsbuild as __rspack_external__rsbuild_core_1b356efc } from "./4484.js";
7
+ import { formatTestEntryName } from "./1157.js";
8
8
  import { posix } from "./3278.js";
9
- const external_node_fs_ = __webpack_require__("node:fs");
9
+ const external_node_fs_ = __webpack_require__("fs");
10
10
  const picocolors = __webpack_require__("../../node_modules/.pnpm/picocolors@1.1.1/node_modules/picocolors/picocolors.js");
11
11
  var picocolors_default = /*#__PURE__*/ __webpack_require__.n(picocolors);
12
12
  const tryResolve = (request, rootPath)=>{
13
- const { resolver } = rspack.experiments;
13
+ const { resolver } = __rspack_external__rsbuild_core_1b356efc.rspack.experiments;
14
14
  const esmFirstResolver = new resolver.ResolverFactory({
15
15
  conditionNames: [
16
16
  'node',
package/dist/721.js ADDED
@@ -0,0 +1,9 @@
1
+ import 'module';
2
+ /*#__PURE__*/ import.meta.url;
3
+ import * as __rspack_external_node_util_1b29d436 from "node:util";
4
+ import { __webpack_require__ } from "./rslib-runtime.js";
5
+ __webpack_require__.add({
6
+ "node:util" (module) {
7
+ module.exports = __rspack_external_node_util_1b29d436;
8
+ }
9
+ });