@rstest/core 0.7.7 → 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 (57) 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 +4 -4
  11. package/dist/0~5835.js +2 -2
  12. package/dist/0~62.js +3 -3
  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 +33 -24
  19. package/dist/0~9348.js +953 -0
  20. package/dist/0~9634.js +58 -10
  21. package/dist/1157.js +13 -118
  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 -21
  30. package/dist/{0~6973.js → 6973.js} +5 -5
  31. package/dist/721.js +9 -0
  32. package/dist/9131.js +559 -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/cssFilterLoader.mjs +1 -1
  45. package/dist/globalSetupWorker.js +3 -2
  46. package/dist/index.d.ts +67 -2
  47. package/dist/index.js +2 -1
  48. package/dist/rslib-runtime.js +27 -0
  49. package/dist/rstestSuppressWarnings.cjs +9 -0
  50. package/dist/worker.d.ts +66 -2
  51. package/dist/worker.js +415 -1
  52. package/package.json +29 -14
  53. package/dist/0~8957.js +0 -149
  54. package/dist/554.js +0 -417
  55. package/dist/5693.js +0 -91
  56. /package/dist/{7913.js.LICENSE.txt → 1294.js.LICENSE.txt} +0 -0
  57. /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;
@@ -11774,10 +11773,6 @@ const SnapshotPlugin = (workerState)=>{
11774
11773
  const isNot = utils.flag(this, 'negate');
11775
11774
  if (isNot) throw new Error('toMatchInlineSnapshot cannot be used with "not"');
11776
11775
  const test = getTest(this);
11777
- if (test) {
11778
- const isInsideEach = test.each || test.inTestEach;
11779
- if (isInsideEach) throw new Error('InlineSnapshot cannot be used inside of test.each or describe.each');
11780
- }
11781
11776
  const expected = utils.flag(this, 'object');
11782
11777
  const error = utils.flag(this, 'error');
11783
11778
  if ('string' == typeof properties) {
@@ -11821,10 +11816,6 @@ const SnapshotPlugin = (workerState)=>{
11821
11816
  const isNot = utils.flag(this, 'negate');
11822
11817
  if (isNot) throw new Error('toThrowErrorMatchingInlineSnapshot cannot be used with "not"');
11823
11818
  const test = getTest(this);
11824
- if (test) {
11825
- const isInsideEach = test.each || test.inTestEach;
11826
- if (isInsideEach) throw new Error('InlineSnapshot cannot be used inside of test.each or describe.each');
11827
- }
11828
11819
  const expected = utils.flag(this, 'object');
11829
11820
  const error = utils.flag(this, 'error');
11830
11821
  const promise = utils.flag(this, 'promise');
@@ -12589,7 +12580,22 @@ class TestRunner {
12589
12580
  if (true === isExpectingAssertions && 0 === assertionCalls) throw isExpectingAssertionsError;
12590
12581
  }
12591
12582
  }
12592
- 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
+ }
12593
12599
  class RunnerRuntime {
12594
12600
  tests = [];
12595
12601
  _currentTest = [];
@@ -12843,7 +12849,7 @@ const createRuntimeAPI = ({ testPath, runtimeConfig, project })=>{
12843
12849
  for (const frame of frames){
12844
12850
  let filename = frame.file ?? '';
12845
12851
  if (filename.startsWith('file://')) filename = fileURLToPath(filename);
12846
- filename = filename.replaceAll(external_node_path_["default"].sep, '/');
12852
+ filename = normalize(filename);
12847
12853
  if (filename === testPath) {
12848
12854
  const line = frame.lineNumber;
12849
12855
  const column = frame.column;
@@ -13189,6 +13195,151 @@ class FakeTimers {
13189
13195
  return this._fakingTime;
13190
13196
  }
13191
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
+ };
13192
13343
  const createRstestUtilities = async (workerState)=>{
13193
13344
  const originalEnvValues = new Map();
13194
13345
  const originalGlobalValues = new Map();
@@ -13200,9 +13351,6 @@ const createRstestUtilities = async (workerState)=>{
13200
13351
  });
13201
13352
  return _timers;
13202
13353
  };
13203
- const { initSpy } = await import("./0~8957.js").then((mod)=>({
13204
- initSpy: mod.initSpy
13205
- }));
13206
13354
  const { fn, spyOn, isMockFunction, mocks } = initSpy();
13207
13355
  const rstest = {
13208
13356
  fn,
@@ -13373,4 +13521,4 @@ const createRstestRuntime = async (workerState)=>{
13373
13521
  globalThis.RSTEST_API = runtime.api;
13374
13522
  return runtime;
13375
13523
  };
13376
- 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
+ });