@rstest/core 0.7.2 → 0.7.4

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.
@@ -0,0 +1,9 @@
1
+ export declare const runGlobalTeardown: () => Promise<{
2
+ success: boolean;
3
+ error?: string;
4
+ }>;
5
+
6
+ declare function runInPool(options: any): Promise<any>;
7
+ export default runInPool;
8
+
9
+ export { }
@@ -0,0 +1,115 @@
1
+ import 'module';
2
+ /*#__PURE__*/ import.meta.url;
3
+ import { __webpack_require__ } from "./rslib-runtime.js";
4
+ import { formatTestError } from "./913.js";
5
+ import "./664.js";
6
+ const source_map_support = __webpack_require__("../../node_modules/.pnpm/source-map-support@0.5.21/node_modules/source-map-support/source-map-support.js");
7
+ const picocolors = __webpack_require__("../../node_modules/.pnpm/picocolors@1.1.1/node_modules/picocolors/picocolors.js");
8
+ var picocolors_default = /*#__PURE__*/ __webpack_require__.n(picocolors);
9
+ let teardownCallbacks = [];
10
+ let initialEnv = {};
11
+ let envChanges = {};
12
+ function trackEnvChanges() {
13
+ initialEnv = {
14
+ ...process.env
15
+ };
16
+ }
17
+ function captureEnvChanges() {
18
+ const changes = {};
19
+ for(const key in process.env)if (process.env[key] !== initialEnv[key]) changes[key] = process.env[key];
20
+ for(const key in initialEnv)if (!(key in process.env) && void 0 !== initialEnv[key]) changes[key] = void 0;
21
+ return changes;
22
+ }
23
+ const runGlobalSetup = async (data)=>{
24
+ try {
25
+ if (0 === data.entries.length) return {
26
+ success: true,
27
+ hasTeardown: false
28
+ };
29
+ (0, source_map_support.install)({
30
+ environment: 'node',
31
+ handleUncaughtExceptions: false,
32
+ retrieveSourceMap: (source)=>{
33
+ if (data.sourceMaps[source]) return {
34
+ url: source,
35
+ map: JSON.parse(data.sourceMaps[source])
36
+ };
37
+ return null;
38
+ }
39
+ });
40
+ trackEnvChanges();
41
+ for (const entry of data.entries){
42
+ const { distPath, testPath } = entry;
43
+ const setupCodeContent = data.assetFiles[distPath];
44
+ const { loadModule } = data.outputModule ? await import("./0~923.js").then((mod)=>({
45
+ EsmMode: mod.loadEsModule_EsmMode,
46
+ asModule: mod.asModule,
47
+ loadModule: mod.loadModule
48
+ })) : await import("./0~835.js").then((mod)=>({
49
+ cacheableLoadModule: mod.cacheableLoadModule,
50
+ loadModule: mod.loadModule
51
+ }));
52
+ const module = await loadModule({
53
+ codeContent: setupCodeContent,
54
+ distPath,
55
+ testPath,
56
+ rstestContext: {
57
+ global,
58
+ console: global.console,
59
+ Error
60
+ },
61
+ assetFiles: data.assetFiles,
62
+ interopDefault: data.interopDefault
63
+ });
64
+ let teardownCallback;
65
+ if (module && 'object' == typeof module) {
66
+ if (module.setup && 'function' == typeof module.setup) {
67
+ await module.setup();
68
+ if (module.teardown && 'function' == typeof module.teardown) teardownCallback = module.teardown;
69
+ } else if (module.default && 'function' == typeof module.default) teardownCallback = await module.default();
70
+ }
71
+ if (teardownCallback) teardownCallbacks.push(teardownCallback);
72
+ }
73
+ envChanges = captureEnvChanges();
74
+ return {
75
+ success: true,
76
+ hasTeardown: teardownCallbacks.length > 0,
77
+ teardownCount: teardownCallbacks.length,
78
+ envChanges: envChanges
79
+ };
80
+ } catch (error) {
81
+ return {
82
+ success: false,
83
+ hasTeardown: false,
84
+ errors: formatTestError(error)
85
+ };
86
+ }
87
+ };
88
+ async function runInPool(options) {
89
+ switch(options.type){
90
+ case 'setup':
91
+ return runGlobalSetup(options);
92
+ case 'teardown':
93
+ return runGlobalTeardown();
94
+ }
95
+ }
96
+ const runGlobalTeardown = async ()=>{
97
+ try {
98
+ const callbacks = [
99
+ ...teardownCallbacks
100
+ ];
101
+ teardownCallbacks = [];
102
+ for (const teardown of callbacks.reverse())await teardown();
103
+ return {
104
+ success: true
105
+ };
106
+ } catch (error) {
107
+ const message = error instanceof Error && error.stack ? error.stack : String(error);
108
+ console.error(picocolors_default().red(`Error during global teardown: ${message}`));
109
+ return {
110
+ success: false
111
+ };
112
+ }
113
+ };
114
+ export default runInPool;
115
+ export { runGlobalTeardown };
package/dist/index.d.ts CHANGED
@@ -20,11 +20,7 @@ declare type AfterAllListener = (ctx: SuiteContext) => MaybePromise<void>;
20
20
 
21
21
  export declare const afterEach: Rstest['afterEach'];
22
22
 
23
- declare type AfterEachListener = (params: {
24
- task: {
25
- result: Readonly<TestResult>;
26
- };
27
- }) => MaybePromise<void>;
23
+ declare type AfterEachListener = (ctx: TestContext) => MaybePromise<void>;
28
24
 
29
25
  export declare const assert: Rstest['assert'];
30
26
 
@@ -259,7 +255,7 @@ declare type BeforeAllListener = (ctx: SuiteContext) => MaybePromise<void | Afte
259
255
 
260
256
  export declare const beforeEach: Rstest['beforeEach'];
261
257
 
262
- declare type BeforeEachListener = () => MaybePromise<void | AfterEachListener>;
258
+ declare type BeforeEachListener = (ctx: TestContext) => MaybePromise<void | AfterEachListener>;
263
259
 
264
260
  declare interface BranchMapping {
265
261
  loc: Range_2;
@@ -364,6 +360,59 @@ declare interface Constructable {
364
360
  new (...args: any[]): any;
365
361
  }
366
362
 
363
+ /**
364
+ * Base class for writing content
365
+ */
366
+ declare class ContentWriter {
367
+ /**
368
+ * returns the colorized version of a string. Typically,
369
+ * content writers that write to files will return the
370
+ * same string and ones writing to a tty will wrap it in
371
+ * appropriate escape sequences.
372
+ */
373
+ colorize(str: string, clazz?: string): string;
374
+ /**
375
+ * writes a string appended with a newline to the destination
376
+ */
377
+ println(str: string): void;
378
+ /**
379
+ * closes this content writer. Should be called after all writes are complete.
380
+ */
381
+ close(): void;
382
+ }
383
+
384
+ declare interface Context {
385
+ data: any;
386
+ dir: string;
387
+ sourceFinder(filepath: string): string;
388
+ watermarks: Watermarks;
389
+ writer: FileWriter;
390
+ /**
391
+ * returns the coverage class given a coverage
392
+ * types and a percentage value.
393
+ */
394
+ classForPercent(type: keyof Watermarks, value: number): string;
395
+ /**
396
+ * returns the source code for the specified file path or throws if
397
+ * the source could not be found.
398
+ */
399
+ getSource(filepath: string): string;
400
+ getTree(summarizer?: Summarizers): Tree;
401
+ /**
402
+ * returns a full visitor given a partial one.
403
+ */
404
+ getVisitor<N extends Node_2 = Node_2>(visitor: Partial<Visitor<N>>): Visitor<N>;
405
+ /**
406
+ * returns a FileWriter implementation for reporting use. Also available
407
+ * as the `writer` property on the context.
408
+ */
409
+ getWriter(): FileWriter;
410
+ /**
411
+ * returns an XML writer for the supplied content writer
412
+ */
413
+ getXmlWriter(contentWriter: ContentWriter): XmlWriter;
414
+ }
415
+
367
416
  declare class CounterMap<K> extends DefaultMap<K, number> {
368
417
  constructor();
369
418
  // compat for jest-image-snapshot https://github.com/vitest-dev/vitest/issues/7322
@@ -435,7 +484,7 @@ export declare type CoverageOptions = {
435
484
  * The reporters to use for coverage collection.
436
485
  * @default ['text', 'html', 'clover', 'json']
437
486
  */
438
- reporters?: (keyof ReportOptions | ReportWithOptions)[];
487
+ reporters?: (keyof ReportOptions | ReportWithOptions | ReportBase)[];
439
488
  /**
440
489
  * The directory to store coverage reports.
441
490
  * @default './coverage'
@@ -591,12 +640,13 @@ declare class DefaultReporter implements Reporter {
591
640
  onTestCaseResult(): void;
592
641
  onUserConsoleLog(log: UserConsoleLog): void;
593
642
  onExit(): Promise<void>;
594
- onTestRunEnd({ results, testResults, duration, getSourcemap, snapshotSummary, filterRerunTestPaths, }: {
643
+ onTestRunEnd({ results, testResults, duration, getSourcemap, snapshotSummary, filterRerunTestPaths, unhandledErrors, }: {
595
644
  results: TestFileResult[];
596
645
  testResults: TestResult[];
597
646
  duration: Duration;
598
647
  snapshotSummary: SnapshotSummary;
599
648
  getSourcemap: GetSourcemap;
649
+ unhandledErrors?: Error[];
600
650
  filterRerunTestPaths?: string[];
601
651
  }): Promise<void>;
602
652
  }
@@ -848,6 +898,29 @@ declare interface FileOptions {
848
898
  file: string;
849
899
  }
850
900
 
901
+ /**
902
+ * utility for writing files under a specific directory
903
+ */
904
+ declare class FileWriter {
905
+ constructor(baseDir: string);
906
+ static startCapture(): void;
907
+ static stopCapture(): void;
908
+ static getOutput(): string;
909
+ static resetOutput(): void;
910
+ /**
911
+ * returns a FileWriter that is rooted at the supplied subdirectory
912
+ */
913
+ writeForDir(subdir: string): FileWriter;
914
+ /**
915
+ * copies a file from a source directory to a destination name
916
+ */
917
+ copyFile(source: string, dest: string, header?: string): void;
918
+ /**
919
+ * returns a content writer for writing content to the supplied file.
920
+ */
921
+ writeFile(file: string | null): ContentWriter;
922
+ }
923
+
851
924
  declare type Fixture<T, K extends keyof T, ExtraContext = object> = ((...args: any) => any) extends T[K] ? T[K] extends any ? FixtureFn<T, K, Omit<ExtraContext, Exclude<keyof T, K>>> : never : T[K] | (T[K] extends any ? FixtureFn<T, K, Omit<ExtraContext, Exclude<keyof T, K>>> : never);
852
925
 
853
926
  declare type FixtureFn<T, K extends keyof T, ExtraContext> = (context: Omit<T, K> & ExtraContext, use: Use<T[K]>) => Promise<void>;
@@ -1394,6 +1467,15 @@ declare interface LinkMapper {
1394
1467
  declare type ListCommandOptions = {
1395
1468
  filesOnly?: boolean;
1396
1469
  json?: boolean | string;
1470
+ includeSuites?: boolean;
1471
+ printLocation?: boolean;
1472
+ };
1473
+
1474
+ declare type ListCommandResult = {
1475
+ tests: Test_2[];
1476
+ testPath: string;
1477
+ project: string;
1478
+ errors?: FormattedError[];
1397
1479
  };
1398
1480
 
1399
1481
  export declare function loadConfig({ cwd, path, envMode, configLoader, }: {
@@ -1406,7 +1488,12 @@ export declare function loadConfig({ cwd, path, envMode, configLoader, }: {
1406
1488
  filePath: string | null;
1407
1489
  }>;
1408
1490
 
1409
- declare interface Location_2 {
1491
+ declare type Location_2 = {
1492
+ line: number;
1493
+ column: number;
1494
+ };
1495
+
1496
+ declare interface Location_3 {
1410
1497
  line: number;
1411
1498
  column: number;
1412
1499
  }
@@ -1463,6 +1550,8 @@ declare interface MatcherState_2 extends MatcherState {
1463
1550
 
1464
1551
  declare type MaybePromise<T> = T | Promise<T>;
1465
1552
 
1553
+ export declare const mergeProjectConfig: (...configs: ProjectConfig[]) => ProjectConfig;
1554
+
1466
1555
  export declare const mergeRstestConfig: (...configs: RstestConfig[]) => RstestConfig;
1467
1556
 
1468
1557
  export declare interface Mock<T extends FunctionLike = FunctionLike> extends MockInstance_2<T> {
@@ -1925,10 +2014,11 @@ declare interface Node_2 {
1925
2014
  visit(visitor: Visitor, state: any): void;
1926
2015
  }
1927
2016
 
1928
- declare type NormalizedConfig = Required<Omit<RstestConfig, OptionalKeys | 'pool' | 'projects' | 'coverage' | 'setupFiles' | 'exclude'>> & Partial<Pick<RstestConfig, OptionalKeys>> & {
2017
+ declare type NormalizedConfig = Required<Omit<RstestConfig, OptionalKeys | 'pool' | 'projects' | 'coverage' | 'setupFiles' | 'globalSetup' | 'exclude'>> & Partial<Pick<RstestConfig, OptionalKeys>> & {
1929
2018
  pool: RstestPoolOptions;
1930
2019
  coverage: NormalizedCoverageOptions;
1931
2020
  setupFiles: string[];
2021
+ globalSetup: string[];
1932
2022
  exclude: {
1933
2023
  patterns: string[];
1934
2024
  override?: boolean;
@@ -1940,12 +2030,22 @@ export declare type NormalizedCoverageOptions = Required<Omit<CoverageOptions, '
1940
2030
  include?: string[];
1941
2031
  };
1942
2032
 
2033
+ declare type NormalizedFixture = {
2034
+ isFn: boolean;
2035
+ deps?: string[];
2036
+ value: FixtureFn<any, any, any> | any;
2037
+ options?: FixtureOptions;
2038
+ };
2039
+
2040
+ declare type NormalizedFixtures = Record<string, NormalizedFixture>;
2041
+
1943
2042
  declare type NormalizedProcedure<T extends Procedure> = (...args: Parameters<T>) => ReturnType<T>;
1944
2043
 
1945
2044
  declare type NormalizedProcedure_2<T extends Procedure_2> = (...args: Parameters<T>) => ReturnType<T>;
1946
2045
 
1947
- declare type NormalizedProjectConfig = Required<Omit<NormalizedConfig, OptionalKeys | 'projects' | 'reporters' | 'pool' | 'setupFiles'>> & Pick<NormalizedConfig, OptionalKeys> & {
2046
+ declare type NormalizedProjectConfig = Required<Omit<NormalizedConfig, OptionalKeys | 'projects' | 'reporters' | 'pool' | 'setupFiles' | 'globalSetup'>> & Pick<NormalizedConfig, OptionalKeys> & {
1948
2047
  setupFiles: string[];
2048
+ globalSetup: string[];
1949
2049
  };
1950
2050
 
1951
2051
  declare interface OldPlugin {
@@ -1955,19 +2055,11 @@ declare interface OldPlugin {
1955
2055
 
1956
2056
  export declare const onTestFailed: Rstest['onTestFailed'];
1957
2057
 
1958
- declare type OnTestFailedHandler = (params: {
1959
- task: {
1960
- result: Readonly<TestResult>;
1961
- };
1962
- }) => MaybePromise<void>;
2058
+ declare type OnTestFailedHandler = (ctx: TestContext) => MaybePromise<void>;
1963
2059
 
1964
2060
  export declare const onTestFinished: Rstest['onTestFinished'];
1965
2061
 
1966
- declare type OnTestFinishedHandler = (params: {
1967
- task: {
1968
- result: Readonly<TestResult>;
1969
- };
1970
- }) => MaybePromise<void>;
2062
+ declare type OnTestFinishedHandler = (ctx: TestContext) => MaybePromise<void>;
1971
2063
 
1972
2064
  declare type OptionalKeys = 'testNamePattern' | 'plugins' | 'source' | 'resolve' | 'output' | 'performance' | 'tools' | 'dev' | 'onConsoleLog' | 'chaiConfig' | 'resolveSnapshotPath';
1973
2065
 
@@ -2051,6 +2143,7 @@ declare type ProjectContext = {
2051
2143
  outputModule: boolean;
2052
2144
  configFilePath?: string;
2053
2145
  normalizedConfig: NormalizedProjectConfig;
2146
+ _globalSetups: boolean;
2054
2147
  };
2055
2148
 
2056
2149
  declare interface ProjectOptions {
@@ -2068,8 +2161,8 @@ declare type PromisifyAssertion<T> = Promisify<Assertion_2<T>>;
2068
2161
  declare type PromisifyAssertion_2<T> = Promisify_2<Assertion<T>>;
2069
2162
 
2070
2163
  declare interface Range_2 {
2071
- start: Location_2;
2072
- end: Location_2;
2164
+ start: Location_3;
2165
+ end: Location_3;
2073
2166
  }
2074
2167
 
2075
2168
  declare interface RawMatcherFn<
@@ -2087,11 +2180,24 @@ declare interface RawSnapshotInfo {
2087
2180
 
2088
2181
  declare type Refs = Array<unknown>;
2089
2182
 
2183
+ declare class ReportBase {
2184
+ constructor(options?: Partial<ReportBaseOptions>);
2185
+ execute(context: Context): void;
2186
+ }
2187
+
2188
+ declare interface ReportBaseOptions {
2189
+ summarizer: Summarizers;
2190
+ }
2191
+
2090
2192
  export declare interface Reporter {
2091
2193
  /**
2092
2194
  * Called before test file run.
2093
2195
  */
2094
2196
  onTestFileStart?: (test: TestFileInfo) => void;
2197
+ /**
2198
+ * Called after tests in file collected.
2199
+ */
2200
+ onTestFileReady?: (test: TestFileInfo) => void;
2095
2201
  /**
2096
2202
  * Called when the test file has finished running.
2097
2203
  */
@@ -2117,11 +2223,12 @@ export declare interface Reporter {
2117
2223
  /**
2118
2224
  * Called after all tests have finished running.
2119
2225
  */
2120
- onTestRunEnd?: ({ results, testResults, duration, getSourcemap, snapshotSummary, }: {
2226
+ onTestRunEnd?: ({ results, testResults, duration, getSourcemap, snapshotSummary, unhandledErrors, }: {
2121
2227
  results: TestFileResult[];
2122
2228
  testResults: TestResult[];
2123
2229
  duration: Duration;
2124
2230
  getSourcemap: GetSourcemap;
2231
+ unhandledErrors?: Error[];
2125
2232
  snapshotSummary: SnapshotSummary;
2126
2233
  filterRerunTestPaths?: string[];
2127
2234
  }) => MaybePromise<void>;
@@ -2231,6 +2338,12 @@ export declare interface RstestConfig {
2231
2338
  * Path to setup files. They will be run before each test file.
2232
2339
  */
2233
2340
  setupFiles?: string[] | string;
2341
+ /**
2342
+ * Path to global setup files, relative to project root.
2343
+ * A global setup file can either export named functions `setup` and `teardown`
2344
+ * or a `default` function that returns a teardown function.
2345
+ */
2346
+ globalSetup?: string[] | string;
2234
2347
  /**
2235
2348
  * Retry the test specific number of times if it fails.
2236
2349
  * @default 0
@@ -2376,6 +2489,10 @@ export declare interface RstestConfig {
2376
2489
  * chai configuration options
2377
2490
  */
2378
2491
  chaiConfig?: ChaiConfig;
2492
+ /**
2493
+ * Include `location` property in `TestInfo` received by reporters
2494
+ */
2495
+ includeTaskLocation?: boolean;
2379
2496
  plugins?: RsbuildConfig['plugins'];
2380
2497
  source?: Pick<NonNullable<RsbuildConfig['source']>, 'define' | 'tsconfigPath' | 'decorators' | 'include' | 'exclude'>;
2381
2498
  performance?: Pick<NonNullable<RsbuildConfig['performance']>, 'bundleAnalyze'>;
@@ -2428,7 +2545,7 @@ declare type RstestContext = {
2428
2545
  declare type RstestInstance = {
2429
2546
  context: RstestContext;
2430
2547
  runTests: () => Promise<void>;
2431
- listTests: (options: ListCommandOptions) => Promise<void>;
2548
+ listTests: (options: ListCommandOptions) => Promise<ListCommandResult[]>;
2432
2549
  };
2433
2550
 
2434
2551
  declare type RstestPoolOptions = {
@@ -2490,6 +2607,10 @@ export declare interface RstestUtilities {
2490
2607
  * Mock a module, not hoisted.
2491
2608
  */
2492
2609
  doMockRequire: <T = unknown>(moduleName: string, moduleFactory?: () => T) => void;
2610
+ /**
2611
+ * Hoisted mock function.
2612
+ */
2613
+ hoisted: <T = unknown>(fn: () => T) => T;
2493
2614
  /**
2494
2615
  * Removes module from the mocked registry.
2495
2616
  */
@@ -2596,7 +2717,7 @@ declare type RunningModules = Map<string, {
2596
2717
  results: TestResult[];
2597
2718
  }>;
2598
2719
 
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'>;
2720
+ 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
2721
 
2601
2722
  declare type RuntimeOptions = Partial<Pick<RuntimeConfig, 'testTimeout' | 'hookTimeout' | 'clearMocks' | 'resetMocks' | 'restoreMocks' | 'maxConcurrency' | 'retry'>>;
2602
2723
 
@@ -2793,6 +2914,8 @@ declare type SuiteContext = {
2793
2914
  filepath: TestPath;
2794
2915
  };
2795
2916
 
2917
+ declare type Summarizers = "flat" | "nested" | "pkg" | "defaultSummarizer";
2918
+
2796
2919
  declare interface SyncExpectationResult {
2797
2920
  pass: boolean;
2798
2921
  message: () => string;
@@ -2800,6 +2923,23 @@ declare interface SyncExpectationResult {
2800
2923
  expected?: any;
2801
2924
  }
2802
2925
 
2926
+ declare interface TaskResult {
2927
+ /**
2928
+ * State of the task. Inherits the `task.mode` during collection.
2929
+ * When the task has finished, it will be changed to `pass` or `fail`.
2930
+ * - **pass**: task ran successfully
2931
+ * - **fail**: task failed
2932
+ */
2933
+ state: TaskState;
2934
+ /**
2935
+ * Errors that occurred during the task execution. It is possible to have several errors
2936
+ * if `expect.soft()` failed multiple times or `retry` was triggered.
2937
+ */
2938
+ errors?: FormattedError[];
2939
+ }
2940
+
2941
+ declare type TaskState = 'pass' | 'fail';
2942
+
2803
2943
  declare interface TeamcityOptions extends FileOptions {
2804
2944
  blockName: string;
2805
2945
  }
@@ -2808,6 +2948,8 @@ declare type Test = (arg0: any) => boolean;
2808
2948
 
2809
2949
  export declare const test: Rstest['test'];
2810
2950
 
2951
+ declare type Test_2 = TestSuite | TestCase;
2952
+
2811
2953
  declare type TestAPI<ExtraContext = object> = TestFn<ExtraContext> & {
2812
2954
  each: TestEachFn;
2813
2955
  for: TestForFn<ExtraContext>;
@@ -2829,6 +2971,34 @@ declare type TestAPIs<ExtraContext = object> = TestAPI<ExtraContext> & {
2829
2971
 
2830
2972
  declare type TestCallbackFn<ExtraContext = object> = (context: TestContext & ExtraContext) => MaybePromise<void>;
2831
2973
 
2974
+ declare type TestCase = TestCaseInfo & {
2975
+ originalFn?: (context: TestContext) => void | Promise<void>;
2976
+ fn?: (context: TestContext) => void | Promise<void>;
2977
+ runMode: TestRunMode;
2978
+ fails?: boolean;
2979
+ each?: boolean;
2980
+ fixtures?: NormalizedFixtures;
2981
+ concurrent?: boolean;
2982
+ sequential?: boolean;
2983
+ inTestEach?: boolean;
2984
+ context: TestContext;
2985
+ only?: boolean;
2986
+ onFinished: OnTestFinishedHandler[];
2987
+ onFailed: OnTestFailedHandler[];
2988
+ /**
2989
+ * Store promises (from async expects) to wait for them before finishing the test
2990
+ */
2991
+ promises?: Promise<any>[];
2992
+ /**
2993
+ * Store stack trace error created when test is registered, used for trace original position
2994
+ */
2995
+ stackTraceError: Error;
2996
+ /**
2997
+ * Result of the task. if `expect.soft()` failed multiple times or `retry` was triggered.
2998
+ */
2999
+ result?: TaskResult;
3000
+ };
3001
+
2832
3002
  export declare type TestCaseInfo = {
2833
3003
  testId: string;
2834
3004
  testPath: TestPath;
@@ -2837,9 +3007,21 @@ export declare type TestCaseInfo = {
2837
3007
  parentNames?: string[];
2838
3008
  project: string;
2839
3009
  startTime?: number;
3010
+ /** Only included when `includeTaskLocation` config is enabled */
3011
+ location?: Location_2;
3012
+ type: 'case';
2840
3013
  };
2841
3014
 
2842
3015
  declare type TestContext = {
3016
+ /**
3017
+ * Metadata of the current test
3018
+ */
3019
+ task: {
3020
+ /** Test name provided by user */
3021
+ name: string;
3022
+ /** Result of the current test, undefined if the test is not run yet */
3023
+ result?: TestResult;
3024
+ };
2843
3025
  expect: Expect;
2844
3026
  onTestFinished: RunnerAPI['onTestFinished'];
2845
3027
  onTestFailed: RunnerAPI['onTestFailed'];
@@ -2859,6 +3041,7 @@ declare interface TesterContext {
2859
3041
 
2860
3042
  export declare type TestFileInfo = {
2861
3043
  testPath: TestPath;
3044
+ tests: TestInfo[];
2862
3045
  };
2863
3046
 
2864
3047
  export declare type TestFileResult = TestResult & {
@@ -2871,6 +3054,10 @@ declare type TestFn<ExtraContext = object> = (description: string, fn?: TestCall
2871
3054
 
2872
3055
  declare type TestForFn<ExtraContext = object> = <T>(cases: readonly T[]) => (description: string, fn?: (param: T, context: TestContext & ExtraContext) => MaybePromise<void>, timeout?: number) => void;
2873
3056
 
3057
+ export declare type TestInfo = TestCaseInfo | (TestSuiteInfo & {
3058
+ tests: TestInfo[];
3059
+ });
3060
+
2874
3061
  /** The test file original path */
2875
3062
  declare type TestPath = string;
2876
3063
 
@@ -2891,6 +3078,8 @@ export declare type TestResult = {
2891
3078
 
2892
3079
  declare type TestResultStatus = 'skip' | 'pass' | 'fail' | 'todo';
2893
3080
 
3081
+ declare type TestRunMode = 'run' | 'skip' | 'todo' | 'only';
3082
+
2894
3083
  declare class TestStateManager {
2895
3084
  runningModules: Map<string, {
2896
3085
  runningTests: TestCaseInfo[];
@@ -2905,12 +3094,29 @@ declare class TestStateManager {
2905
3094
  reset(): void;
2906
3095
  }
2907
3096
 
3097
+ declare type TestSuite = TestSuiteInfo & {
3098
+ runMode: TestRunMode;
3099
+ each?: boolean;
3100
+ inTestEach?: boolean;
3101
+ concurrent?: boolean;
3102
+ sequential?: boolean;
3103
+ /** nested cases and suite could in a suite */
3104
+ tests: Test_2[];
3105
+ afterAllListeners?: AfterAllListener[];
3106
+ beforeAllListeners?: BeforeAllListener[];
3107
+ afterEachListeners?: AfterEachListener[];
3108
+ beforeEachListeners?: BeforeEachListener[];
3109
+ };
3110
+
2908
3111
  export declare type TestSuiteInfo = {
2909
3112
  testId: string;
2910
3113
  name: string;
2911
3114
  parentNames?: string[];
2912
3115
  testPath: TestPath;
2913
3116
  project: string;
3117
+ type: 'suite';
3118
+ /** Only included when `includeTaskLocation` config is enabled */
3119
+ location?: Location_2;
2914
3120
  };
2915
3121
 
2916
3122
  declare type TextLcovOptions = ProjectOptions;
@@ -2956,6 +3162,11 @@ declare class TraceMap implements SourceMap {
2956
3162
  constructor(map: Ro<SourceMapInput>, mapUrl?: string | null);
2957
3163
  }
2958
3164
 
3165
+ declare interface Tree<N extends Node_2 = Node_2> {
3166
+ getRoot(): N;
3167
+ visit(visitor: Partial<Visitor<N>>, state: any): void;
3168
+ }
3169
+
2959
3170
  declare interface UncheckedSnapshot {
2960
3171
  filePath: string;
2961
3172
  keys: Array<string>;
@@ -2988,10 +3199,39 @@ declare type VitestAssertion<
2988
3199
  T
2989
3200
  > = { [K in keyof A] : A[K] extends Chai.Assertion ? Assertion_2<T> : A[K] extends (...args: any[]) => any ? A[K] : VitestAssertion<A[K], T> } & ((type: string, message?: string) => Assertion_2);
2990
3201
 
3202
+ declare type Watermark = [number, number];
3203
+
3204
+ declare interface Watermarks {
3205
+ statements: Watermark;
3206
+ functions: Watermark;
3207
+ branches: Watermark;
3208
+ lines: Watermark;
3209
+ }
3210
+
2991
3211
  declare type WithAsymmetricMatcher<T> = T | AsymmetricMatcher<unknown>;
2992
3212
 
2993
3213
  declare type XInput = {
2994
3214
  x_google_ignoreList?: SourceMapV3['ignoreList'];
2995
3215
  };
2996
3216
 
3217
+ declare interface XmlWriter {
3218
+ indent(str: string): string;
3219
+ /**
3220
+ * writes the opening XML tag with the supplied attributes
3221
+ */
3222
+ openTag(name: string, attrs?: any): void;
3223
+ /**
3224
+ * closes an open XML tag.
3225
+ */
3226
+ closeTag(name: string): void;
3227
+ /**
3228
+ * writes a tag and its value opening and closing it at the same time
3229
+ */
3230
+ inlineTag(name: string, attrs?: any, content?: string): void;
3231
+ /**
3232
+ * closes all open tags and ends the document
3233
+ */
3234
+ closeAll(): void;
3235
+ }
3236
+
2997
3237
  export { }
package/dist/index.js CHANGED
@@ -1,3 +1,3 @@
1
1
  import 'module';
2
2
  /*#__PURE__*/ import.meta.url;
3
- export { afterAll, afterEach, assert, beforeAll, beforeEach, createRstest, defineConfig, defineProject, describe, expect, initCli, it, loadConfig, mergeRstestConfig, onTestFailed, onTestFinished, rs, rstest, runCLI, test } from "./131.js";
3
+ export { afterAll, afterEach, assert, beforeAll, beforeEach, createRstest, defineConfig, defineProject, describe, expect, initCli, it, loadConfig, mergeProjectConfig, mergeRstestConfig, onTestFailed, onTestFinished, rs, rstest, runCLI, test } from "./131.js";
@@ -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();