@rstest/core 0.7.1 → 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/734.js CHANGED
@@ -2,7 +2,7 @@ import 'module';
2
2
  /*#__PURE__*/ import.meta.url;
3
3
  import { __webpack_require__ } from "./rslib-runtime.js";
4
4
  import { external_node_module_createRequire } from "./946.js";
5
- import { pathToFileURL } from "./770.js";
5
+ import { pathToFileURL } from "./404.js";
6
6
  const picocolors = __webpack_require__("../../node_modules/.pnpm/picocolors@1.1.1/node_modules/picocolors/picocolors.js");
7
7
  var picocolors_default = /*#__PURE__*/ __webpack_require__.n(picocolors);
8
8
  const CoverageProviderMap = {
package/dist/946.js CHANGED
@@ -1,10 +1,10 @@
1
1
  import 'module';
2
2
  /*#__PURE__*/ import.meta.url;
3
- import * as __WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__ from "node:fs";
4
- import * as __WEBPACK_EXTERNAL_MODULE_node_os_74b4b876__ from "node:os";
5
- import * as __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__ from "node:path";
6
- import * as __WEBPACK_EXTERNAL_MODULE_node_tty_c64aab7e__ from "node:tty";
7
- import * as __WEBPACK_EXTERNAL_MODULE_node_util_1b29d436__ from "node:util";
3
+ import * as __rspack_external_node_fs_5ea92f0c from "node:fs";
4
+ import * as __rspack_external_node_os_74b4b876 from "node:os";
5
+ import * as __rspack_external_node_path_c5b9b54f from "node:path";
6
+ import * as __rspack_external_node_tty_c64aab7e from "node:tty";
7
+ import * as __rspack_external_node_util_1b29d436 from "node:util";
8
8
  import { __webpack_require__ } from "./rslib-runtime.js";
9
9
  import node_process from "node:process";
10
10
  import { fileURLToPath } from "url";
@@ -12,7 +12,7 @@ import { createRequire } from "module";
12
12
  import promises, { lstat, readdir, realpath, stat as promises_stat, writeFile } from "node:fs/promises";
13
13
  import { createRequire as external_node_module_createRequire, isBuiltin } from "node:module";
14
14
  __webpack_require__.add({
15
- "../../node_modules/.pnpm/picocolors@1.1.1/node_modules/picocolors/picocolors.js": function(module) {
15
+ "../../node_modules/.pnpm/picocolors@1.1.1/node_modules/picocolors/picocolors.js" (module) {
16
16
  let p = process || {}, argv = p.argv || [], env = p.env || {};
17
17
  let isColorSupported = !(!!env.NO_COLOR || argv.includes("--no-color")) && (!!env.FORCE_COLOR || argv.includes("--color") || "win32" === p.platform || (p.stdout || {}).isTTY && "dumb" !== env.TERM || !!env.CI);
18
18
  let formatter = (open, close, replace = open)=>(input)=>{
@@ -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": function(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) {
@@ -91,7 +91,7 @@ __webpack_require__.add({
91
91
  Object.assign(picomatch, pico);
92
92
  module.exports = picomatch;
93
93
  },
94
- "../../node_modules/.pnpm/picomatch@4.0.3/node_modules/picomatch/lib/constants.js": function(module) {
94
+ "../../node_modules/.pnpm/picomatch@4.0.3/node_modules/picomatch/lib/constants.js" (module) {
95
95
  const WIN_SLASH = '\\\\/';
96
96
  const WIN_NO_SLASH = `[^${WIN_SLASH}]`;
97
97
  const DOT_LITERAL = '\\.';
@@ -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": function(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": function(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": function(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": function(__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);
@@ -1484,20 +1484,20 @@ __webpack_require__.add({
1484
1484
  return last;
1485
1485
  };
1486
1486
  },
1487
- "node:fs": function(module) {
1488
- module.exports = __WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__;
1487
+ "node:fs" (module) {
1488
+ module.exports = __rspack_external_node_fs_5ea92f0c;
1489
1489
  },
1490
- "node:os": function(module) {
1491
- module.exports = __WEBPACK_EXTERNAL_MODULE_node_os_74b4b876__;
1490
+ "node:os" (module) {
1491
+ module.exports = __rspack_external_node_os_74b4b876;
1492
1492
  },
1493
- "node:path": function(module) {
1494
- module.exports = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__;
1493
+ path (module) {
1494
+ module.exports = __rspack_external_node_path_c5b9b54f;
1495
1495
  },
1496
- "node:tty": function(module) {
1497
- module.exports = __WEBPACK_EXTERNAL_MODULE_node_tty_c64aab7e__;
1496
+ "node:tty" (module) {
1497
+ module.exports = __rspack_external_node_tty_c64aab7e;
1498
1498
  },
1499
- "node:util": function(module) {
1500
- module.exports = __WEBPACK_EXTERNAL_MODULE_node_util_1b29d436__;
1499
+ "node:util" (module) {
1500
+ module.exports = __rspack_external_node_util_1b29d436;
1501
1501
  }
1502
1502
  });
1503
1503
  const external_node_os_ = __webpack_require__("node:os");
@@ -1604,9 +1604,10 @@ const supportsColor = {
1604
1604
  };
1605
1605
  const supports_color = supportsColor;
1606
1606
  const colorLevel = supports_color.stdout ? supports_color.stdout.level : 0;
1607
- let errorStackRegExp = /at\s.*:\d+:\d+[\s\)]*$/;
1608
- let anonymousErrorStackRegExp = /at\s.*\(<anonymous>\)$/;
1609
- let isErrorStackMessage = (message)=>errorStackRegExp.test(message) || anonymousErrorStackRegExp.test(message);
1607
+ let errorStackRegExp = /at [^\r\n]{0,200}:\d+:\d+[\s\)]*$/;
1608
+ let anonymousErrorStackRegExp = /at [^\r\n]{0,200}\(<anonymous>\)$/;
1609
+ let indexErrorStackRegExp = /at [^\r\n]{0,200}\(index\s\d+\)$/;
1610
+ let isErrorStackMessage = (message)=>errorStackRegExp.test(message) || anonymousErrorStackRegExp.test(message) || indexErrorStackRegExp.test(message);
1610
1611
  let formatter = (open, close, replace = open)=>colorLevel >= 2 ? (input)=>{
1611
1612
  let string = '' + input;
1612
1613
  let index = string.indexOf(close, open.length);
@@ -1718,9 +1719,10 @@ const normalizeErrorMessage = (err)=>{
1718
1719
  let createLogger = (options = {})=>{
1719
1720
  let maxLevel = options.level || 'info';
1720
1721
  let log = (type, message, ...args)=>{
1721
- if (LOG_LEVEL[LOG_TYPES[type].level] > LOG_LEVEL[maxLevel]) return;
1722
- if (null == message) return console.log();
1723
1722
  let logType = LOG_TYPES[type];
1723
+ const { level } = logType;
1724
+ if (LOG_LEVEL[level] > LOG_LEVEL[maxLevel]) return;
1725
+ if (null == message) return console.log();
1724
1726
  let label = '';
1725
1727
  let text = '';
1726
1728
  if ('label' in logType) {
@@ -1734,11 +1736,12 @@ let createLogger = (options = {})=>{
1734
1736
  text += yellow('\n [cause]: ');
1735
1737
  text += cause instanceof Error ? normalizeErrorMessage(cause) : String(cause);
1736
1738
  }
1737
- } else if ('error' === logType.level && 'string' == typeof message) {
1739
+ } else if ('error' === level && 'string' == typeof message) {
1738
1740
  let lines = message.split('\n');
1739
1741
  text = lines.map((line)=>isErrorStackMessage(line) ? gray(line) : line).join('\n');
1740
1742
  } else text = `${message}`;
1741
- console.log(label.length ? `${label} ${text}` : text, ...args);
1743
+ const method = 'error' === level || 'warn' === level ? level : 'log';
1744
+ console[method](label.length ? `${label} ${text}` : text, ...args);
1742
1745
  };
1743
1746
  let logger = {
1744
1747
  greet: (message)=>log('log', gradient(message))
@@ -1788,6 +1791,12 @@ src_logger.override({
1788
1791
  const clearScreen = (force = false)=>{
1789
1792
  if (!isDebug() || force) console.log('\x1Bc');
1790
1793
  };
1794
+ const logger_logger = {
1795
+ ...src_logger,
1796
+ stderr: (message, ...args)=>{
1797
+ console.error(message, ...args);
1798
+ }
1799
+ };
1791
1800
  let _lazyMatch = ()=>{
1792
1801
  var __lib__ = (()=>{
1793
1802
  var m = Object.defineProperty, V = Object.getOwnPropertyDescriptor, G = Object.getOwnPropertyNames, T = Object.prototype.hasOwnProperty, q = (r, e)=>{
@@ -2336,8 +2345,15 @@ const ADDITIONAL_NODE_BUILTINS = [
2336
2345
  /^node:/,
2337
2346
  'pnpapi'
2338
2347
  ];
2348
+ const bgColor = (background, str)=>{
2349
+ if ([
2350
+ 'bgRed',
2351
+ 'bgBlack'
2352
+ ].includes(background)) return picocolors_default()[background](picocolors_default().white(picocolors_default().bold(str)));
2353
+ return picocolors_default()[background](picocolors_default().blackBright(picocolors_default().bold(str)));
2354
+ };
2339
2355
  const isTTY = (type = 'stdout')=>('stdin' === type ? process.stdin.isTTY : process.stdout.isTTY) && !process.env.CI;
2340
- const external_node_path_ = __webpack_require__("node:path");
2356
+ const external_node_path_ = __webpack_require__("path");
2341
2357
  const external_node_fs_ = __webpack_require__("node:fs");
2342
2358
  var __require = /* @__PURE__ */ createRequire(import.meta.url);
2343
2359
  function cleanPath(path) {
@@ -3249,4 +3265,4 @@ const formatTestPath = (root, testFilePath)=>{
3249
3265
  return prettyTestPath(testPath);
3250
3266
  };
3251
3267
  const picomatch = __webpack_require__("../../node_modules/.pnpm/picomatch@4.0.3/node_modules/picomatch/index.js");
3252
- 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, 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
@@ -3,6 +3,7 @@ import type { config } from 'chai';
3
3
  import { LoadConfigOptions } from '@rsbuild/core';
4
4
  import type { RsbuildConfig } from '@rsbuild/core';
5
5
  import type { RsbuildPlugin } from '@rsbuild/core';
6
+ import type { Writable } from 'node:stream';
6
7
 
7
8
  /**
8
9
  * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
@@ -519,16 +520,7 @@ declare type CoverageThreshold = {
519
520
  lines?: number;
520
521
  };
521
522
 
522
- declare type CoverageThresholds = CoverageThreshold | (CoverageThreshold & {
523
- /** check thresholds for matched files */
524
- [glob: string]: CoverageThreshold & {
525
- /**
526
- * check thresholds per file
527
- * @default false
528
- */
529
- perFile?: boolean;
530
- };
531
- });
523
+ declare type CoverageThresholds = CoverageThreshold | (CoverageThreshold & ThresholdGlobRecord);
532
524
 
533
525
  export declare function createRstest({ config, projects, configFilePath, }: {
534
526
  config: RstestConfig;
@@ -615,6 +607,11 @@ declare type DefaultReporterOptions = {
615
607
  * @default true
616
608
  */
617
609
  summary?: boolean;
610
+ /**
611
+ * logger which write messages to
612
+ * @default process.stdout/process.stderr
613
+ */
614
+ logger?: Options['logger'];
618
615
  };
619
616
 
620
617
  /**
@@ -872,6 +869,8 @@ declare type FormattedError = {
872
869
  name?: string;
873
870
  stack?: string;
874
871
  diff?: string;
872
+ expected?: string;
873
+ actual?: string;
875
874
  };
876
875
 
877
876
  declare interface Formatter {
@@ -1395,6 +1394,15 @@ declare interface LinkMapper {
1395
1394
  declare type ListCommandOptions = {
1396
1395
  filesOnly?: boolean;
1397
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[];
1398
1406
  };
1399
1407
 
1400
1408
  export declare function loadConfig({ cwd, path, envMode, configLoader, }: {
@@ -1407,7 +1415,12 @@ export declare function loadConfig({ cwd, path, envMode, configLoader, }: {
1407
1415
  filePath: string | null;
1408
1416
  }>;
1409
1417
 
1410
- declare interface Location_2 {
1418
+ declare type Location_2 = {
1419
+ line: number;
1420
+ column: number;
1421
+ };
1422
+
1423
+ declare interface Location_3 {
1411
1424
  line: number;
1412
1425
  column: number;
1413
1426
  }
@@ -1926,9 +1939,7 @@ declare interface Node_2 {
1926
1939
  visit(visitor: Visitor, state: any): void;
1927
1940
  }
1928
1941
 
1929
- declare type NormalizedConfig = Required<Omit<RstestConfig, OptionalKeys | 'pool' | 'projects' | 'coverage' | 'setupFiles' | 'exclude'>> & {
1930
- [key in OptionalKeys]?: RstestConfig[key];
1931
- } & {
1942
+ declare type NormalizedConfig = Required<Omit<RstestConfig, OptionalKeys | 'pool' | 'projects' | 'coverage' | 'setupFiles' | 'exclude'>> & Partial<Pick<RstestConfig, OptionalKeys>> & {
1932
1943
  pool: RstestPoolOptions;
1933
1944
  coverage: NormalizedCoverageOptions;
1934
1945
  setupFiles: string[];
@@ -1943,13 +1954,20 @@ export declare type NormalizedCoverageOptions = Required<Omit<CoverageOptions, '
1943
1954
  include?: string[];
1944
1955
  };
1945
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
+
1946
1966
  declare type NormalizedProcedure<T extends Procedure> = (...args: Parameters<T>) => ReturnType<T>;
1947
1967
 
1948
1968
  declare type NormalizedProcedure_2<T extends Procedure_2> = (...args: Parameters<T>) => ReturnType<T>;
1949
1969
 
1950
- declare type NormalizedProjectConfig = Required<Omit<NormalizedConfig, OptionalKeys | 'projects' | 'reporters' | 'pool' | 'setupFiles'>> & {
1951
- [key in OptionalKeys]?: NormalizedConfig[key];
1952
- } & {
1970
+ declare type NormalizedProjectConfig = Required<Omit<NormalizedConfig, OptionalKeys | 'projects' | 'reporters' | 'pool' | 'setupFiles'>> & Pick<NormalizedConfig, OptionalKeys> & {
1953
1971
  setupFiles: string[];
1954
1972
  };
1955
1973
 
@@ -1976,6 +1994,16 @@ declare type OnTestFinishedHandler = (params: {
1976
1994
 
1977
1995
  declare type OptionalKeys = 'testNamePattern' | 'plugins' | 'source' | 'resolve' | 'output' | 'performance' | 'tools' | 'dev' | 'onConsoleLog' | 'chaiConfig' | 'resolveSnapshotPath';
1978
1996
 
1997
+ declare interface Options {
1998
+ logger: {
1999
+ outputStream: Writable;
2000
+ errorStream: Writable;
2001
+ getColumns: () => number;
2002
+ };
2003
+ interval?: number;
2004
+ getWindow: () => string[];
2005
+ }
2006
+
1979
2007
  declare type OptionsReceived = PrettyFormatOptions;
1980
2008
 
1981
2009
  declare interface ParsedStack {
@@ -2063,8 +2091,8 @@ declare type PromisifyAssertion<T> = Promisify<Assertion_2<T>>;
2063
2091
  declare type PromisifyAssertion_2<T> = Promisify_2<Assertion<T>>;
2064
2092
 
2065
2093
  declare interface Range_2 {
2066
- start: Location_2;
2067
- end: Location_2;
2094
+ start: Location_3;
2095
+ end: Location_3;
2068
2096
  }
2069
2097
 
2070
2098
  declare interface RawMatcherFn<
@@ -2087,10 +2115,24 @@ export declare interface Reporter {
2087
2115
  * Called before test file run.
2088
2116
  */
2089
2117
  onTestFileStart?: (test: TestFileInfo) => void;
2118
+ /**
2119
+ * Called after tests in file collected.
2120
+ */
2121
+ onTestFileReady?: (test: TestFileInfo) => void;
2090
2122
  /**
2091
2123
  * Called when the test file has finished running.
2092
2124
  */
2093
2125
  onTestFileResult?: (test: TestFileResult) => void;
2126
+ /**
2127
+ * Called before running the test suite.
2128
+ */
2129
+ onTestSuiteStart?: (test: TestSuiteInfo) => void;
2130
+ /**
2131
+ * Called when the suite has finished running or was just skipped.
2132
+ *
2133
+ * `result.errors` contains only suite hooks errors
2134
+ */
2135
+ onTestSuiteResult?: (result: TestResult) => void;
2094
2136
  /**
2095
2137
  * Called when the test has finished running or was just skipped.
2096
2138
  */
@@ -2361,6 +2403,10 @@ export declare interface RstestConfig {
2361
2403
  * chai configuration options
2362
2404
  */
2363
2405
  chaiConfig?: ChaiConfig;
2406
+ /**
2407
+ * Include `location` property in `TestInfo` received by reporters
2408
+ */
2409
+ includeTaskLocation?: boolean;
2364
2410
  plugins?: RsbuildConfig['plugins'];
2365
2411
  source?: Pick<NonNullable<RsbuildConfig['source']>, 'define' | 'tsconfigPath' | 'decorators' | 'include' | 'exclude'>;
2366
2412
  performance?: Pick<NonNullable<RsbuildConfig['performance']>, 'bundleAnalyze'>;
@@ -2413,7 +2459,7 @@ declare type RstestContext = {
2413
2459
  declare type RstestInstance = {
2414
2460
  context: RstestContext;
2415
2461
  runTests: () => Promise<void>;
2416
- listTests: (options: ListCommandOptions) => Promise<void>;
2462
+ listTests: (options: ListCommandOptions) => Promise<ListCommandResult[]>;
2417
2463
  };
2418
2464
 
2419
2465
  declare type RstestPoolOptions = {
@@ -2475,6 +2521,10 @@ export declare interface RstestUtilities {
2475
2521
  * Mock a module, not hoisted.
2476
2522
  */
2477
2523
  doMockRequire: <T = unknown>(moduleName: string, moduleFactory?: () => T) => void;
2524
+ /**
2525
+ * Hoisted mock function.
2526
+ */
2527
+ hoisted: <T = unknown>(fn: () => T) => T;
2478
2528
  /**
2479
2529
  * Removes module from the mocked registry.
2480
2530
  */
@@ -2581,7 +2631,7 @@ declare type RunningModules = Map<string, {
2581
2631
  results: TestResult[];
2582
2632
  }>;
2583
2633
 
2584
- 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'>;
2585
2635
 
2586
2636
  declare type RuntimeOptions = Partial<Pick<RuntimeConfig, 'testTimeout' | 'hookTimeout' | 'clearMocks' | 'resetMocks' | 'restoreMocks' | 'maxConcurrency' | 'retry'>>;
2587
2637
 
@@ -2760,7 +2810,7 @@ declare class StatusRenderer {
2760
2810
  private renderer;
2761
2811
  private startTime;
2762
2812
  private testState;
2763
- constructor(rootPath: string, state: RstestTestState);
2813
+ constructor(rootPath: string, state: RstestTestState, logger?: Options['logger']);
2764
2814
  getContent(): string[];
2765
2815
  onTestFileStart(): void;
2766
2816
  onTestCaseResult(): void;
@@ -2785,6 +2835,23 @@ declare interface SyncExpectationResult {
2785
2835
  expected?: any;
2786
2836
  }
2787
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
+
2788
2855
  declare interface TeamcityOptions extends FileOptions {
2789
2856
  blockName: string;
2790
2857
  }
@@ -2793,6 +2860,8 @@ declare type Test = (arg0: any) => boolean;
2793
2860
 
2794
2861
  export declare const test: Rstest['test'];
2795
2862
 
2863
+ declare type Test_2 = TestSuite | TestCase;
2864
+
2796
2865
  declare type TestAPI<ExtraContext = object> = TestFn<ExtraContext> & {
2797
2866
  each: TestEachFn;
2798
2867
  for: TestForFn<ExtraContext>;
@@ -2814,6 +2883,34 @@ declare type TestAPIs<ExtraContext = object> = TestAPI<ExtraContext> & {
2814
2883
 
2815
2884
  declare type TestCallbackFn<ExtraContext = object> = (context: TestContext & ExtraContext) => MaybePromise<void>;
2816
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
+
2817
2914
  export declare type TestCaseInfo = {
2818
2915
  testId: string;
2819
2916
  testPath: TestPath;
@@ -2822,6 +2919,9 @@ export declare type TestCaseInfo = {
2822
2919
  parentNames?: string[];
2823
2920
  project: string;
2824
2921
  startTime?: number;
2922
+ /** Only included when `includeTaskLocation` config is enabled */
2923
+ location?: Location_2;
2924
+ type: 'case';
2825
2925
  };
2826
2926
 
2827
2927
  declare type TestContext = {
@@ -2844,6 +2944,7 @@ declare interface TesterContext {
2844
2944
 
2845
2945
  export declare type TestFileInfo = {
2846
2946
  testPath: TestPath;
2947
+ tests: TestInfo[];
2847
2948
  };
2848
2949
 
2849
2950
  export declare type TestFileResult = TestResult & {
@@ -2856,6 +2957,10 @@ declare type TestFn<ExtraContext = object> = (description: string, fn?: TestCall
2856
2957
 
2857
2958
  declare type TestForFn<ExtraContext = object> = <T>(cases: readonly T[]) => (description: string, fn?: (param: T, context: TestContext & ExtraContext) => MaybePromise<void>, timeout?: number) => void;
2858
2959
 
2960
+ export declare type TestInfo = TestCaseInfo | (TestSuiteInfo & {
2961
+ tests: TestInfo[];
2962
+ });
2963
+
2859
2964
  /** The test file original path */
2860
2965
  declare type TestPath = string;
2861
2966
 
@@ -2876,6 +2981,8 @@ export declare type TestResult = {
2876
2981
 
2877
2982
  declare type TestResultStatus = 'skip' | 'pass' | 'fail' | 'todo';
2878
2983
 
2984
+ declare type TestRunMode = 'run' | 'skip' | 'todo' | 'only';
2985
+
2879
2986
  declare class TestStateManager {
2880
2987
  runningModules: Map<string, {
2881
2988
  runningTests: TestCaseInfo[];
@@ -2890,6 +2997,31 @@ declare class TestStateManager {
2890
2997
  reset(): void;
2891
2998
  }
2892
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
+
3014
+ export declare type TestSuiteInfo = {
3015
+ testId: string;
3016
+ name: string;
3017
+ parentNames?: string[];
3018
+ testPath: TestPath;
3019
+ project: string;
3020
+ type: 'suite';
3021
+ /** Only included when `includeTaskLocation` config is enabled */
3022
+ location?: Location_2;
3023
+ };
3024
+
2893
3025
  declare type TextLcovOptions = ProjectOptions;
2894
3026
 
2895
3027
  declare interface TextOptions extends FileOptions {
@@ -2900,6 +3032,15 @@ declare interface TextOptions extends FileOptions {
2900
3032
 
2901
3033
  declare type TextSummaryOptions = FileOptions;
2902
3034
 
3035
+ /** check thresholds for matched files */
3036
+ declare type ThresholdGlobRecord = Record<string, CoverageThreshold & {
3037
+ /**
3038
+ * check thresholds per file
3039
+ * @default false
3040
+ */
3041
+ perFile?: boolean;
3042
+ }>;
3043
+
2903
3044
  declare interface Totals {
2904
3045
  total: number;
2905
3046
  covered: number;
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 "./155.js";
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";
@@ -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();