@rstest/core 0.7.2 → 0.7.3

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/672.js ADDED
@@ -0,0 +1,91 @@
1
+ import 'module';
2
+ /*#__PURE__*/ import.meta.url;
3
+ var UNKNOWN_FUNCTION = '<unknown>';
4
+ function parse(stackString) {
5
+ var lines = stackString.split('\n');
6
+ return lines.reduce(function(stack, line) {
7
+ var parseResult = parseChrome(line) || parseWinjs(line) || parseGecko(line) || parseNode(line) || parseJSC(line);
8
+ if (parseResult) stack.push(parseResult);
9
+ return stack;
10
+ }, []);
11
+ }
12
+ var chromeRe = /^\s*at (.*?) ?\(((?:file|https?|blob|chrome-extension|native|eval|webpack|rsc|<anonymous>|\/|[a-z]:\\|\\\\).*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i;
13
+ var chromeEvalRe = /\((\S*)(?::(\d+))(?::(\d+))\)/;
14
+ function parseChrome(line) {
15
+ var parts = chromeRe.exec(line);
16
+ if (!parts) return null;
17
+ var isNative = parts[2] && 0 === parts[2].indexOf('native');
18
+ var isEval = parts[2] && 0 === parts[2].indexOf('eval');
19
+ var submatch = chromeEvalRe.exec(parts[2]);
20
+ if (isEval && null != submatch) {
21
+ parts[2] = submatch[1];
22
+ parts[3] = submatch[2];
23
+ parts[4] = submatch[3];
24
+ }
25
+ return {
26
+ file: isNative ? null : parts[2],
27
+ methodName: parts[1] || UNKNOWN_FUNCTION,
28
+ arguments: isNative ? [
29
+ parts[2]
30
+ ] : [],
31
+ lineNumber: parts[3] ? +parts[3] : null,
32
+ column: parts[4] ? +parts[4] : null
33
+ };
34
+ }
35
+ var winjsRe = /^\s*at (?:((?:\[object object\])?.+) )?\(?((?:file|ms-appx|https?|webpack|rsc|blob):.*?):(\d+)(?::(\d+))?\)?\s*$/i;
36
+ function parseWinjs(line) {
37
+ var parts = winjsRe.exec(line);
38
+ if (!parts) return null;
39
+ return {
40
+ file: parts[2],
41
+ methodName: parts[1] || UNKNOWN_FUNCTION,
42
+ arguments: [],
43
+ lineNumber: +parts[3],
44
+ column: parts[4] ? +parts[4] : null
45
+ };
46
+ }
47
+ var geckoRe = /^\s*(.*?)(?:\((.*?)\))?(?:^|@)((?:file|https?|blob|chrome|webpack|rsc|resource|\[native).*?|[^@]*bundle)(?::(\d+))?(?::(\d+))?\s*$/i;
48
+ var geckoEvalRe = /(\S+) line (\d+)(?: > eval line \d+)* > eval/i;
49
+ function parseGecko(line) {
50
+ var parts = geckoRe.exec(line);
51
+ if (!parts) return null;
52
+ var isEval = parts[3] && parts[3].indexOf(' > eval') > -1;
53
+ var submatch = geckoEvalRe.exec(parts[3]);
54
+ if (isEval && null != submatch) {
55
+ parts[3] = submatch[1];
56
+ parts[4] = submatch[2];
57
+ parts[5] = null;
58
+ }
59
+ return {
60
+ file: parts[3],
61
+ methodName: parts[1] || UNKNOWN_FUNCTION,
62
+ arguments: parts[2] ? parts[2].split(',') : [],
63
+ lineNumber: parts[4] ? +parts[4] : null,
64
+ column: parts[5] ? +parts[5] : null
65
+ };
66
+ }
67
+ var javaScriptCoreRe = /^\s*(?:([^@]*)(?:\((.*?)\))?@)?(\S.*?):(\d+)(?::(\d+))?\s*$/i;
68
+ function parseJSC(line) {
69
+ var parts = javaScriptCoreRe.exec(line);
70
+ if (!parts) return null;
71
+ return {
72
+ file: parts[3],
73
+ methodName: parts[1] || UNKNOWN_FUNCTION,
74
+ arguments: [],
75
+ lineNumber: +parts[4],
76
+ column: parts[5] ? +parts[5] : null
77
+ };
78
+ }
79
+ var nodeRe = /^\s*at (?:((?:\[object object\])?[^\\/]+(?: \[as \S+\])?) )?\(?(.*?):(\d+)(?::(\d+))?\)?\s*$/i;
80
+ function parseNode(line) {
81
+ var parts = nodeRe.exec(line);
82
+ if (!parts) return null;
83
+ return {
84
+ file: parts[2],
85
+ methodName: parts[1] || UNKNOWN_FUNCTION,
86
+ arguments: [],
87
+ lineNumber: +parts[3],
88
+ column: parts[4] ? +parts[4] : null
89
+ };
90
+ }
91
+ export { parse };
package/dist/946.js CHANGED
@@ -78,7 +78,7 @@ __webpack_require__.add({
78
78
  module.exports = createColors();
79
79
  module.exports.createColors = createColors;
80
80
  },
81
- "../../node_modules/.pnpm/picomatch@4.0.3/node_modules/picomatch/index.js" (module, __unused_webpack_exports, __webpack_require__) {
81
+ "../../node_modules/.pnpm/picomatch@4.0.3/node_modules/picomatch/index.js" (module, __unused_rspack_exports, __webpack_require__) {
82
82
  const pico = __webpack_require__("../../node_modules/.pnpm/picomatch@4.0.3/node_modules/picomatch/lib/picomatch.js");
83
83
  const utils = __webpack_require__("../../node_modules/.pnpm/picomatch@4.0.3/node_modules/picomatch/lib/utils.js");
84
84
  function picomatch(glob, options, returnState = false) {
@@ -251,7 +251,7 @@ __webpack_require__.add({
251
251
  }
252
252
  };
253
253
  },
254
- "../../node_modules/.pnpm/picomatch@4.0.3/node_modules/picomatch/lib/parse.js" (module, __unused_webpack_exports, __webpack_require__) {
254
+ "../../node_modules/.pnpm/picomatch@4.0.3/node_modules/picomatch/lib/parse.js" (module, __unused_rspack_exports, __webpack_require__) {
255
255
  const constants = __webpack_require__("../../node_modules/.pnpm/picomatch@4.0.3/node_modules/picomatch/lib/constants.js");
256
256
  const utils = __webpack_require__("../../node_modules/.pnpm/picomatch@4.0.3/node_modules/picomatch/lib/utils.js");
257
257
  const { MAX_LENGTH, POSIX_REGEX_SOURCE, REGEX_NON_SPECIAL_CHARS, REGEX_SPECIAL_CHARS_BACKREF, REPLACEMENTS } = constants;
@@ -1039,7 +1039,7 @@ __webpack_require__.add({
1039
1039
  };
1040
1040
  module.exports = parse;
1041
1041
  },
1042
- "../../node_modules/.pnpm/picomatch@4.0.3/node_modules/picomatch/lib/picomatch.js" (module, __unused_webpack_exports, __webpack_require__) {
1042
+ "../../node_modules/.pnpm/picomatch@4.0.3/node_modules/picomatch/lib/picomatch.js" (module, __unused_rspack_exports, __webpack_require__) {
1043
1043
  const scan = __webpack_require__("../../node_modules/.pnpm/picomatch@4.0.3/node_modules/picomatch/lib/scan.js");
1044
1044
  const parse = __webpack_require__("../../node_modules/.pnpm/picomatch@4.0.3/node_modules/picomatch/lib/parse.js");
1045
1045
  const utils = __webpack_require__("../../node_modules/.pnpm/picomatch@4.0.3/node_modules/picomatch/lib/utils.js");
@@ -1172,7 +1172,7 @@ __webpack_require__.add({
1172
1172
  picomatch.constants = constants;
1173
1173
  module.exports = picomatch;
1174
1174
  },
1175
- "../../node_modules/.pnpm/picomatch@4.0.3/node_modules/picomatch/lib/scan.js" (module, __unused_webpack_exports, __webpack_require__) {
1175
+ "../../node_modules/.pnpm/picomatch@4.0.3/node_modules/picomatch/lib/scan.js" (module, __unused_rspack_exports, __webpack_require__) {
1176
1176
  const utils = __webpack_require__("../../node_modules/.pnpm/picomatch@4.0.3/node_modules/picomatch/lib/utils.js");
1177
1177
  const { CHAR_ASTERISK, CHAR_AT, CHAR_BACKWARD_SLASH, CHAR_COMMA, CHAR_DOT, CHAR_EXCLAMATION_MARK, CHAR_FORWARD_SLASH, CHAR_LEFT_CURLY_BRACE, CHAR_LEFT_PARENTHESES, CHAR_LEFT_SQUARE_BRACKET, CHAR_PLUS, CHAR_QUESTION_MARK, CHAR_RIGHT_CURLY_BRACE, CHAR_RIGHT_PARENTHESES, CHAR_RIGHT_SQUARE_BRACKET } = __webpack_require__("../../node_modules/.pnpm/picomatch@4.0.3/node_modules/picomatch/lib/constants.js");
1178
1178
  const isPathSeparator = (code)=>code === CHAR_FORWARD_SLASH || code === CHAR_BACKWARD_SLASH;
@@ -1440,7 +1440,7 @@ __webpack_require__.add({
1440
1440
  };
1441
1441
  module.exports = scan;
1442
1442
  },
1443
- "../../node_modules/.pnpm/picomatch@4.0.3/node_modules/picomatch/lib/utils.js" (__unused_webpack_module, exports, __webpack_require__) {
1443
+ "../../node_modules/.pnpm/picomatch@4.0.3/node_modules/picomatch/lib/utils.js" (__unused_rspack_module, exports, __webpack_require__) {
1444
1444
  const { REGEX_BACKSLASH, REGEX_REMOVE_BACKSLASH, REGEX_SPECIAL_CHARS, REGEX_SPECIAL_CHARS_GLOBAL } = __webpack_require__("../../node_modules/.pnpm/picomatch@4.0.3/node_modules/picomatch/lib/constants.js");
1445
1445
  exports.isObject = (val)=>null !== val && 'object' == typeof val && !Array.isArray(val);
1446
1446
  exports.hasRegexChars = (str)=>REGEX_SPECIAL_CHARS.test(str);
@@ -1490,7 +1490,7 @@ __webpack_require__.add({
1490
1490
  "node:os" (module) {
1491
1491
  module.exports = __rspack_external_node_os_74b4b876;
1492
1492
  },
1493
- "node:path" (module) {
1493
+ path (module) {
1494
1494
  module.exports = __rspack_external_node_path_c5b9b54f;
1495
1495
  },
1496
1496
  "node:tty" (module) {
@@ -1791,6 +1791,12 @@ src_logger.override({
1791
1791
  const clearScreen = (force = false)=>{
1792
1792
  if (!isDebug() || force) console.log('\x1Bc');
1793
1793
  };
1794
+ const logger_logger = {
1795
+ ...src_logger,
1796
+ stderr: (message, ...args)=>{
1797
+ console.error(message, ...args);
1798
+ }
1799
+ };
1794
1800
  let _lazyMatch = ()=>{
1795
1801
  var __lib__ = (()=>{
1796
1802
  var m = Object.defineProperty, V = Object.getOwnPropertyDescriptor, G = Object.getOwnPropertyNames, T = Object.prototype.hasOwnProperty, q = (r, e)=>{
@@ -2347,7 +2353,7 @@ const bgColor = (background, str)=>{
2347
2353
  return picocolors_default()[background](picocolors_default().blackBright(picocolors_default().bold(str)));
2348
2354
  };
2349
2355
  const isTTY = (type = 'stdout')=>('stdin' === type ? process.stdin.isTTY : process.stdout.isTTY) && !process.env.CI;
2350
- const external_node_path_ = __webpack_require__("node:path");
2356
+ const external_node_path_ = __webpack_require__("path");
2351
2357
  const external_node_fs_ = __webpack_require__("node:fs");
2352
2358
  var __require = /* @__PURE__ */ createRequire(import.meta.url);
2353
2359
  function cleanPath(path) {
@@ -3259,4 +3265,4 @@ const formatTestPath = (root, testFilePath)=>{
3259
3265
  return prettyTestPath(testPath);
3260
3266
  };
3261
3267
  const picomatch = __webpack_require__("../../node_modules/.pnpm/picomatch@4.0.3/node_modules/picomatch/index.js");
3262
- export { ADDITIONAL_NODE_BUILTINS, DEFAULT_CONFIG_EXTENSIONS, DEFAULT_CONFIG_NAME, ROOT_SUITE_NAME, TEMP_RSTEST_OUTPUT_DIR, TEMP_RSTEST_OUTPUT_DIR_GLOB, TS_CONFIG_FILE, basename, bgColor, castArray, clearScreen, dirname, external_node_module_createRequire, filterProjects, formatError, formatRootStr, formatTestPath, getAbsolutePath, getSetupFiles, getTaskNameWithPrefix, getTestEntries, glob, globalApis, isAbsolute, isBuiltin, isDebug, isDynamicPattern, isObject, isTTY, join, lstat, needFlagExperimentalDetectModule, node_process, normalize, pathe_M_eThtNZ_relative, posix, prettyTestPath, prettyTime, promises_stat, readdir, realpath, resolve, serializableConfig, src_logger, undoSerializableConfig, writeFile };
3268
+ export { ADDITIONAL_NODE_BUILTINS, DEFAULT_CONFIG_EXTENSIONS, DEFAULT_CONFIG_NAME, ROOT_SUITE_NAME, TEMP_RSTEST_OUTPUT_DIR, TEMP_RSTEST_OUTPUT_DIR_GLOB, TS_CONFIG_FILE, basename, bgColor, castArray, clearScreen, dirname, external_node_module_createRequire, filterProjects, formatError, formatRootStr, formatTestPath, getAbsolutePath, getSetupFiles, getTaskNameWithPrefix, getTestEntries, glob, globalApis, isAbsolute, isBuiltin, isDebug, isDynamicPattern, isObject, isTTY, join, logger_logger, lstat, needFlagExperimentalDetectModule, node_process, normalize, pathe_M_eThtNZ_relative, posix, prettyTestPath, prettyTime, promises_stat, readdir, realpath, resolve, serializableConfig, undoSerializableConfig, writeFile };
package/dist/index.d.ts CHANGED
@@ -1394,6 +1394,15 @@ declare interface LinkMapper {
1394
1394
  declare type ListCommandOptions = {
1395
1395
  filesOnly?: boolean;
1396
1396
  json?: boolean | string;
1397
+ includeSuites?: boolean;
1398
+ printLocation?: boolean;
1399
+ };
1400
+
1401
+ declare type ListCommandResult = {
1402
+ tests: Test_2[];
1403
+ testPath: string;
1404
+ project: string;
1405
+ errors?: FormattedError[];
1397
1406
  };
1398
1407
 
1399
1408
  export declare function loadConfig({ cwd, path, envMode, configLoader, }: {
@@ -1406,7 +1415,12 @@ export declare function loadConfig({ cwd, path, envMode, configLoader, }: {
1406
1415
  filePath: string | null;
1407
1416
  }>;
1408
1417
 
1409
- declare interface Location_2 {
1418
+ declare type Location_2 = {
1419
+ line: number;
1420
+ column: number;
1421
+ };
1422
+
1423
+ declare interface Location_3 {
1410
1424
  line: number;
1411
1425
  column: number;
1412
1426
  }
@@ -1940,6 +1954,15 @@ export declare type NormalizedCoverageOptions = Required<Omit<CoverageOptions, '
1940
1954
  include?: string[];
1941
1955
  };
1942
1956
 
1957
+ declare type NormalizedFixture = {
1958
+ isFn: boolean;
1959
+ deps?: string[];
1960
+ value: FixtureFn<any, any, any> | any;
1961
+ options?: FixtureOptions;
1962
+ };
1963
+
1964
+ declare type NormalizedFixtures = Record<string, NormalizedFixture>;
1965
+
1943
1966
  declare type NormalizedProcedure<T extends Procedure> = (...args: Parameters<T>) => ReturnType<T>;
1944
1967
 
1945
1968
  declare type NormalizedProcedure_2<T extends Procedure_2> = (...args: Parameters<T>) => ReturnType<T>;
@@ -2068,8 +2091,8 @@ declare type PromisifyAssertion<T> = Promisify<Assertion_2<T>>;
2068
2091
  declare type PromisifyAssertion_2<T> = Promisify_2<Assertion<T>>;
2069
2092
 
2070
2093
  declare interface Range_2 {
2071
- start: Location_2;
2072
- end: Location_2;
2094
+ start: Location_3;
2095
+ end: Location_3;
2073
2096
  }
2074
2097
 
2075
2098
  declare interface RawMatcherFn<
@@ -2092,6 +2115,10 @@ export declare interface Reporter {
2092
2115
  * Called before test file run.
2093
2116
  */
2094
2117
  onTestFileStart?: (test: TestFileInfo) => void;
2118
+ /**
2119
+ * Called after tests in file collected.
2120
+ */
2121
+ onTestFileReady?: (test: TestFileInfo) => void;
2095
2122
  /**
2096
2123
  * Called when the test file has finished running.
2097
2124
  */
@@ -2376,6 +2403,10 @@ export declare interface RstestConfig {
2376
2403
  * chai configuration options
2377
2404
  */
2378
2405
  chaiConfig?: ChaiConfig;
2406
+ /**
2407
+ * Include `location` property in `TestInfo` received by reporters
2408
+ */
2409
+ includeTaskLocation?: boolean;
2379
2410
  plugins?: RsbuildConfig['plugins'];
2380
2411
  source?: Pick<NonNullable<RsbuildConfig['source']>, 'define' | 'tsconfigPath' | 'decorators' | 'include' | 'exclude'>;
2381
2412
  performance?: Pick<NonNullable<RsbuildConfig['performance']>, 'bundleAnalyze'>;
@@ -2428,7 +2459,7 @@ declare type RstestContext = {
2428
2459
  declare type RstestInstance = {
2429
2460
  context: RstestContext;
2430
2461
  runTests: () => Promise<void>;
2431
- listTests: (options: ListCommandOptions) => Promise<void>;
2462
+ listTests: (options: ListCommandOptions) => Promise<ListCommandResult[]>;
2432
2463
  };
2433
2464
 
2434
2465
  declare type RstestPoolOptions = {
@@ -2490,6 +2521,10 @@ export declare interface RstestUtilities {
2490
2521
  * Mock a module, not hoisted.
2491
2522
  */
2492
2523
  doMockRequire: <T = unknown>(moduleName: string, moduleFactory?: () => T) => void;
2524
+ /**
2525
+ * Hoisted mock function.
2526
+ */
2527
+ hoisted: <T = unknown>(fn: () => T) => T;
2493
2528
  /**
2494
2529
  * Removes module from the mocked registry.
2495
2530
  */
@@ -2596,7 +2631,7 @@ declare type RunningModules = Map<string, {
2596
2631
  results: TestResult[];
2597
2632
  }>;
2598
2633
 
2599
- declare type RuntimeConfig = Pick<RstestContext['normalizedConfig'], 'testTimeout' | 'testNamePattern' | 'globals' | 'passWithNoTests' | 'retry' | 'clearMocks' | 'resetMocks' | 'restoreMocks' | 'unstubEnvs' | 'unstubGlobals' | 'maxConcurrency' | 'printConsoleTrace' | 'disableConsoleIntercept' | 'testEnvironment' | 'isolate' | 'hookTimeout' | 'coverage' | 'snapshotFormat' | 'env' | 'logHeapUsage' | 'bail' | 'chaiConfig'>;
2634
+ declare type RuntimeConfig = Pick<RstestContext['normalizedConfig'], 'testTimeout' | 'testNamePattern' | 'globals' | 'passWithNoTests' | 'retry' | 'clearMocks' | 'resetMocks' | 'restoreMocks' | 'unstubEnvs' | 'unstubGlobals' | 'maxConcurrency' | 'printConsoleTrace' | 'disableConsoleIntercept' | 'testEnvironment' | 'isolate' | 'hookTimeout' | 'coverage' | 'snapshotFormat' | 'env' | 'logHeapUsage' | 'bail' | 'chaiConfig' | 'includeTaskLocation'>;
2600
2635
 
2601
2636
  declare type RuntimeOptions = Partial<Pick<RuntimeConfig, 'testTimeout' | 'hookTimeout' | 'clearMocks' | 'resetMocks' | 'restoreMocks' | 'maxConcurrency' | 'retry'>>;
2602
2637
 
@@ -2800,6 +2835,23 @@ declare interface SyncExpectationResult {
2800
2835
  expected?: any;
2801
2836
  }
2802
2837
 
2838
+ declare interface TaskResult {
2839
+ /**
2840
+ * State of the task. Inherits the `task.mode` during collection.
2841
+ * When the task has finished, it will be changed to `pass` or `fail`.
2842
+ * - **pass**: task ran successfully
2843
+ * - **fail**: task failed
2844
+ */
2845
+ state: TaskState;
2846
+ /**
2847
+ * Errors that occurred during the task execution. It is possible to have several errors
2848
+ * if `expect.soft()` failed multiple times or `retry` was triggered.
2849
+ */
2850
+ errors?: FormattedError[];
2851
+ }
2852
+
2853
+ declare type TaskState = 'pass' | 'fail';
2854
+
2803
2855
  declare interface TeamcityOptions extends FileOptions {
2804
2856
  blockName: string;
2805
2857
  }
@@ -2808,6 +2860,8 @@ declare type Test = (arg0: any) => boolean;
2808
2860
 
2809
2861
  export declare const test: Rstest['test'];
2810
2862
 
2863
+ declare type Test_2 = TestSuite | TestCase;
2864
+
2811
2865
  declare type TestAPI<ExtraContext = object> = TestFn<ExtraContext> & {
2812
2866
  each: TestEachFn;
2813
2867
  for: TestForFn<ExtraContext>;
@@ -2829,6 +2883,34 @@ declare type TestAPIs<ExtraContext = object> = TestAPI<ExtraContext> & {
2829
2883
 
2830
2884
  declare type TestCallbackFn<ExtraContext = object> = (context: TestContext & ExtraContext) => MaybePromise<void>;
2831
2885
 
2886
+ declare type TestCase = TestCaseInfo & {
2887
+ originalFn?: (context: TestContext) => void | Promise<void>;
2888
+ fn?: (context: TestContext) => void | Promise<void>;
2889
+ runMode: TestRunMode;
2890
+ fails?: boolean;
2891
+ each?: boolean;
2892
+ fixtures?: NormalizedFixtures;
2893
+ concurrent?: boolean;
2894
+ sequential?: boolean;
2895
+ inTestEach?: boolean;
2896
+ context: TestContext;
2897
+ only?: boolean;
2898
+ onFinished: OnTestFinishedHandler[];
2899
+ onFailed: OnTestFailedHandler[];
2900
+ /**
2901
+ * Store promises (from async expects) to wait for them before finishing the test
2902
+ */
2903
+ promises?: Promise<any>[];
2904
+ /**
2905
+ * Store stack trace error created when test is registered, used for trace original position
2906
+ */
2907
+ stackTraceError: Error;
2908
+ /**
2909
+ * Result of the task. if `expect.soft()` failed multiple times or `retry` was triggered.
2910
+ */
2911
+ result?: TaskResult;
2912
+ };
2913
+
2832
2914
  export declare type TestCaseInfo = {
2833
2915
  testId: string;
2834
2916
  testPath: TestPath;
@@ -2837,6 +2919,9 @@ export declare type TestCaseInfo = {
2837
2919
  parentNames?: string[];
2838
2920
  project: string;
2839
2921
  startTime?: number;
2922
+ /** Only included when `includeTaskLocation` config is enabled */
2923
+ location?: Location_2;
2924
+ type: 'case';
2840
2925
  };
2841
2926
 
2842
2927
  declare type TestContext = {
@@ -2859,6 +2944,7 @@ declare interface TesterContext {
2859
2944
 
2860
2945
  export declare type TestFileInfo = {
2861
2946
  testPath: TestPath;
2947
+ tests: TestInfo[];
2862
2948
  };
2863
2949
 
2864
2950
  export declare type TestFileResult = TestResult & {
@@ -2871,6 +2957,10 @@ declare type TestFn<ExtraContext = object> = (description: string, fn?: TestCall
2871
2957
 
2872
2958
  declare type TestForFn<ExtraContext = object> = <T>(cases: readonly T[]) => (description: string, fn?: (param: T, context: TestContext & ExtraContext) => MaybePromise<void>, timeout?: number) => void;
2873
2959
 
2960
+ export declare type TestInfo = TestCaseInfo | (TestSuiteInfo & {
2961
+ tests: TestInfo[];
2962
+ });
2963
+
2874
2964
  /** The test file original path */
2875
2965
  declare type TestPath = string;
2876
2966
 
@@ -2891,6 +2981,8 @@ export declare type TestResult = {
2891
2981
 
2892
2982
  declare type TestResultStatus = 'skip' | 'pass' | 'fail' | 'todo';
2893
2983
 
2984
+ declare type TestRunMode = 'run' | 'skip' | 'todo' | 'only';
2985
+
2894
2986
  declare class TestStateManager {
2895
2987
  runningModules: Map<string, {
2896
2988
  runningTests: TestCaseInfo[];
@@ -2905,12 +2997,29 @@ declare class TestStateManager {
2905
2997
  reset(): void;
2906
2998
  }
2907
2999
 
3000
+ declare type TestSuite = TestSuiteInfo & {
3001
+ runMode: TestRunMode;
3002
+ each?: boolean;
3003
+ inTestEach?: boolean;
3004
+ concurrent?: boolean;
3005
+ sequential?: boolean;
3006
+ /** nested cases and suite could in a suite */
3007
+ tests: Test_2[];
3008
+ afterAllListeners?: AfterAllListener[];
3009
+ beforeAllListeners?: BeforeAllListener[];
3010
+ afterEachListeners?: AfterEachListener[];
3011
+ beforeEachListeners?: BeforeEachListener[];
3012
+ };
3013
+
2908
3014
  export declare type TestSuiteInfo = {
2909
3015
  testId: string;
2910
3016
  name: string;
2911
3017
  parentNames?: string[];
2912
3018
  testPath: TestPath;
2913
3019
  project: string;
3020
+ type: 'suite';
3021
+ /** Only included when `includeTaskLocation` config is enabled */
3022
+ location?: Location_2;
2914
3023
  };
2915
3024
 
2916
3025
  declare type TextLcovOptions = ProjectOptions;
@@ -123,3 +123,4 @@ __webpack_require__.rstest_reset_modules = ()=>{
123
123
  if (!mockedIds.includes(id)) delete __webpack_module_cache__[id];
124
124
  });
125
125
  };
126
+ __webpack_require__.rstest_hoisted = (fn)=>fn();
package/dist/worker.d.ts CHANGED
@@ -1213,7 +1213,12 @@ declare interface LinkMapper {
1213
1213
  assetPath(node: Node_2, name: string): string;
1214
1214
  }
1215
1215
 
1216
- declare interface Location_2 {
1216
+ declare type Location_2 = {
1217
+ line: number;
1218
+ column: number;
1219
+ };
1220
+
1221
+ declare interface Location_3 {
1217
1222
  line: number;
1218
1223
  column: number;
1219
1224
  }
@@ -1714,8 +1719,8 @@ declare type PromisifyAssertion<T> = Promisify<Assertion<T>>;
1714
1719
  declare type PromisifyAssertion_2<T> = Promisify_2<Assertion_2<T>>;
1715
1720
 
1716
1721
  declare interface Range_2 {
1717
- start: Location_2;
1718
- end: Location_2;
1722
+ start: Location_3;
1723
+ end: Location_3;
1719
1724
  }
1720
1725
 
1721
1726
  declare interface RawMatcherFn<
@@ -1738,6 +1743,10 @@ declare interface Reporter {
1738
1743
  * Called before test file run.
1739
1744
  */
1740
1745
  onTestFileStart?: (test: TestFileInfo) => void;
1746
+ /**
1747
+ * Called after tests in file collected.
1748
+ */
1749
+ onTestFileReady?: (test: TestFileInfo) => void;
1741
1750
  /**
1742
1751
  * Called when the test file has finished running.
1743
1752
  */
@@ -2009,6 +2018,10 @@ declare interface RstestConfig {
2009
2018
  * chai configuration options
2010
2019
  */
2011
2020
  chaiConfig?: ChaiConfig;
2021
+ /**
2022
+ * Include `location` property in `TestInfo` received by reporters
2023
+ */
2024
+ includeTaskLocation?: boolean;
2012
2025
  plugins?: RsbuildConfig['plugins'];
2013
2026
  source?: Pick<NonNullable<RsbuildConfig['source']>, 'define' | 'tsconfigPath' | 'decorators' | 'include' | 'exclude'>;
2014
2027
  performance?: Pick<NonNullable<RsbuildConfig['performance']>, 'bundleAnalyze'>;
@@ -2095,11 +2108,12 @@ declare type RunningModules = Map<string, {
2095
2108
  results: TestResult[];
2096
2109
  }>;
2097
2110
 
2098
- declare type RuntimeConfig = Pick<RstestContext['normalizedConfig'], 'testTimeout' | 'testNamePattern' | 'globals' | 'passWithNoTests' | 'retry' | 'clearMocks' | 'resetMocks' | 'restoreMocks' | 'unstubEnvs' | 'unstubGlobals' | 'maxConcurrency' | 'printConsoleTrace' | 'disableConsoleIntercept' | 'testEnvironment' | 'isolate' | 'hookTimeout' | 'coverage' | 'snapshotFormat' | 'env' | 'logHeapUsage' | 'bail' | 'chaiConfig'>;
2111
+ declare type RuntimeConfig = Pick<RstestContext['normalizedConfig'], 'testTimeout' | 'testNamePattern' | 'globals' | 'passWithNoTests' | 'retry' | 'clearMocks' | 'resetMocks' | 'restoreMocks' | 'unstubEnvs' | 'unstubGlobals' | 'maxConcurrency' | 'printConsoleTrace' | 'disableConsoleIntercept' | 'testEnvironment' | 'isolate' | 'hookTimeout' | 'coverage' | 'snapshotFormat' | 'env' | 'logHeapUsage' | 'bail' | 'chaiConfig' | 'includeTaskLocation'>;
2099
2112
 
2100
2113
  /** Runtime to Server */
2101
2114
  declare type RuntimeRPC = {
2102
2115
  onTestFileStart: (test: TestFileInfo) => Promise<void>;
2116
+ onTestFileReady: (test: TestFileInfo) => Promise<void>;
2103
2117
  getAssetsByEntry: () => Promise<{
2104
2118
  assetFiles: Record<string, string>;
2105
2119
  sourceMaps: Record<string, string>;
@@ -2389,11 +2403,14 @@ declare type TestCase = TestCaseInfo & {
2389
2403
  only?: boolean;
2390
2404
  onFinished: OnTestFinishedHandler[];
2391
2405
  onFailed: OnTestFailedHandler[];
2392
- type: 'case';
2393
2406
  /**
2394
2407
  * Store promises (from async expects) to wait for them before finishing the test
2395
2408
  */
2396
2409
  promises?: Promise<any>[];
2410
+ /**
2411
+ * Store stack trace error created when test is registered, used for trace original position
2412
+ */
2413
+ stackTraceError: Error;
2397
2414
  /**
2398
2415
  * Result of the task. if `expect.soft()` failed multiple times or `retry` was triggered.
2399
2416
  */
@@ -2408,6 +2425,9 @@ declare type TestCaseInfo = {
2408
2425
  parentNames?: string[];
2409
2426
  project: string;
2410
2427
  startTime?: number;
2428
+ /** Only included when `includeTaskLocation` config is enabled */
2429
+ location?: Location_2;
2430
+ type: 'case';
2411
2431
  };
2412
2432
 
2413
2433
  declare type TestContext = {
@@ -2430,6 +2450,7 @@ declare interface TesterContext {
2430
2450
 
2431
2451
  declare type TestFileInfo = {
2432
2452
  testPath: TestPath;
2453
+ tests: TestInfo[];
2433
2454
  };
2434
2455
 
2435
2456
  declare type TestFileResult = TestResult & {
@@ -2442,6 +2463,10 @@ declare type TestFn<ExtraContext = object> = (description: string, fn?: TestCall
2442
2463
 
2443
2464
  declare type TestForFn<ExtraContext = object> = <T>(cases: readonly T[]) => (description: string, fn?: (param: T, context: TestContext & ExtraContext) => MaybePromise<void>, timeout?: number) => void;
2444
2465
 
2466
+ declare type TestInfo = TestCaseInfo | (TestSuiteInfo & {
2467
+ tests: TestInfo[];
2468
+ });
2469
+
2445
2470
  /** The test file original path */
2446
2471
  declare type TestPath = string;
2447
2472
 
@@ -2485,8 +2510,7 @@ declare type TestSuite = TestSuiteInfo & {
2485
2510
  concurrent?: boolean;
2486
2511
  sequential?: boolean;
2487
2512
  /** nested cases and suite could in a suite */
2488
- tests: (TestSuite | TestCase)[];
2489
- type: 'suite';
2513
+ tests: Test_2[];
2490
2514
  afterAllListeners?: AfterAllListener[];
2491
2515
  beforeAllListeners?: BeforeAllListener[];
2492
2516
  afterEachListeners?: AfterEachListener[];
@@ -2499,6 +2523,9 @@ declare type TestSuiteInfo = {
2499
2523
  parentNames?: string[];
2500
2524
  testPath: TestPath;
2501
2525
  project: string;
2526
+ type: 'suite';
2527
+ /** Only included when `includeTaskLocation` config is enabled */
2528
+ location?: Location_2;
2502
2529
  };
2503
2530
 
2504
2531
  declare type TextLcovOptions = ProjectOptions;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rstest/core",
3
- "version": "0.7.2",
3
+ "version": "0.7.3",
4
4
  "description": "The Rsbuild-based test tool.",
5
5
  "bugs": {
6
6
  "url": "https://github.com/web-infra-dev/rstest/issues"
@@ -60,7 +60,7 @@
60
60
  "@jridgewell/trace-mapping": "0.3.31",
61
61
  "@microsoft/api-extractor": "^7.53.3",
62
62
  "@rslib/core": "0.18.3",
63
- "@sinonjs/fake-timers": "^14.0.0",
63
+ "@sinonjs/fake-timers": "^15.0.0",
64
64
  "@types/babel__code-frame": "^7.0.6",
65
65
  "@types/istanbul-reports": "^3.0.4",
66
66
  "@types/istanbul-lib-coverage": "^2.0.6",