@rstest/core 0.9.5 → 0.9.7

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.
@@ -74,5 +74,4 @@ async function generateCoverageForUntestedFiles(environmentName, uncoveredFiles,
74
74
  coverageMap.addFileCoverage(coverageData);
75
75
  });
76
76
  }
77
- var generate_getIncludedFiles = void 0;
78
- export { generateCoverage, generate_getIncludedFiles as getIncludedFiles };
77
+ export { generateCoverage };
@@ -3,7 +3,50 @@ import { mkdirSync, writeFileSync } from "node:fs";
3
3
  import { dirname, isAbsolute, join, relative } from "node:path";
4
4
  import { prepareRsbuild, createPool, createRsbuildServer, runGlobalTeardown, runGlobalSetup } from "./0~8843.js";
5
5
  import { resolveShardedEntries, getTestEntries, prettyTestPath } from "./4411.js";
6
- import { getTaskNameWithPrefix, logger as logger_logger, color as logger_color, ROOT_SUITE_NAME, bgColor } from "./6830.js";
6
+ import { logger as logger_logger, color as logger_color, getTaskNameWithPrefix, ROOT_SUITE_NAME, bgColor } from "./6830.js";
7
+ const SummaryProjectLabel = logger_color.gray('Projects'.padStart(11));
8
+ const SummaryTestFileLabel = logger_color.gray('Test Files'.padStart(11));
9
+ const SummarySuiteLabel = logger_color.gray('Suites'.padStart(11));
10
+ const SummaryTestLabel = logger_color.gray('Tests'.padStart(11));
11
+ const getListSummaryCounts = (tests)=>{
12
+ const projects = new Set();
13
+ const files = new Set();
14
+ let suites = 0;
15
+ let testCases = 0;
16
+ for (const test of tests){
17
+ if (test.project) projects.add(test.project);
18
+ files.add(`${test.project ?? ''}\0${test.file}`);
19
+ if ('suite' === test.type) suites += 1;
20
+ if ('case' === test.type) testCases += 1;
21
+ }
22
+ return {
23
+ projects: projects.size,
24
+ files: files.size,
25
+ suites,
26
+ testCases
27
+ };
28
+ };
29
+ const printListSummary = ({ tests, filesOnly, includeSuites, showProject, write })=>{
30
+ const counts = getListSummaryCounts(tests);
31
+ write('');
32
+ if (showProject) write(`${SummaryProjectLabel} ${logger_color.bold(`${counts.projects} matched`)}`);
33
+ write(`${SummaryTestFileLabel} ${logger_color.bold(`${counts.files} matched`)}`);
34
+ if (filesOnly) return;
35
+ if (includeSuites) write(`${SummarySuiteLabel} ${logger_color.bold(`${counts.suites} matched`)}`);
36
+ write(`${SummaryTestLabel} ${logger_color.bold(`${counts.testCases} matched`)}`);
37
+ };
38
+ const createListSummaryPayload = ({ tests, filesOnly, includeSuites, showProject })=>{
39
+ const counts = getListSummaryCounts(tests);
40
+ const summary = {
41
+ files: counts.files
42
+ };
43
+ if (showProject) summary.projects = counts.projects;
44
+ if (!filesOnly) {
45
+ if (includeSuites) summary.suites = counts.suites;
46
+ summary.tests = counts.testCases;
47
+ }
48
+ return summary;
49
+ };
7
50
  const collectNodeTests = async ({ context, nodeProjects, globTestSourceEntries })=>{
8
51
  const { getSetupFiles } = await import("./255.js");
9
52
  if (0 === nodeProjects.length) return {
@@ -161,7 +204,7 @@ const collectAllTests = async ({ context, globTestSourceEntries, shardedEntries
161
204
  }
162
205
  };
163
206
  };
164
- async function listTests(context, { filesOnly, json, printLocation, includeSuites }) {
207
+ async function listTests(context, { filesOnly, json, printLocation, includeSuites, summary }) {
165
208
  const { rootPath } = context;
166
209
  const { shard } = context.normalizedConfig;
167
210
  const shardedEntries = await resolveShardedEntries(context);
@@ -255,7 +298,15 @@ async function listTests(context, { filesOnly, json, printLocation, includeSuite
255
298
  for (const test of file.tests)traverseTests(test);
256
299
  }
257
300
  if (json && 'false' !== json) {
258
- const content = JSON.stringify(tests, null, 2);
301
+ const content = JSON.stringify(summary ? {
302
+ items: tests,
303
+ summary: createListSummaryPayload({
304
+ tests,
305
+ filesOnly,
306
+ includeSuites,
307
+ showProject
308
+ })
309
+ } : tests, null, 2);
259
310
  if (true !== json && 'true' !== json) {
260
311
  const jsonPath = isAbsolute(json) ? json : join(rootPath, json);
261
312
  mkdirSync(dirname(jsonPath), {
@@ -263,10 +314,19 @@ async function listTests(context, { filesOnly, json, printLocation, includeSuite
263
314
  });
264
315
  writeFileSync(jsonPath, content);
265
316
  } else logger_logger.log(content);
266
- } else for (const test of tests){
267
- let shortPath = relative(rootPath, test.file);
268
- if (test.location && printLocation) shortPath = `${shortPath}:${test.location.line}:${test.location.column}`;
269
- logger_logger.log(test.name ? `${logger_color.dim(`${shortPath} > `)}${test.name}` : prettyTestPath(shortPath));
317
+ } else {
318
+ for (const test of tests){
319
+ let shortPath = relative(rootPath, test.file);
320
+ if (test.location && printLocation) shortPath = `${shortPath}:${test.location.line}:${test.location.column}`;
321
+ logger_logger.log(test.name ? `${logger_color.dim(`${shortPath} > `)}${test.name}` : prettyTestPath(shortPath));
322
+ }
323
+ if (summary) printListSummary({
324
+ tests,
325
+ filesOnly,
326
+ includeSuites,
327
+ showProject,
328
+ write: logger_logger.log
329
+ });
270
330
  }
271
331
  await close();
272
332
  return list;
@@ -946,185 +946,5 @@ class MagicString {
946
946
  return this._replaceRegexp(searchValue, replacement);
947
947
  }
948
948
  }
949
- const hasOwnProp = Object.prototype.hasOwnProperty;
950
- class Bundle {
951
- constructor(options = {}){
952
- this.intro = options.intro || '';
953
- this.separator = void 0 !== options.separator ? options.separator : '\n';
954
- this.sources = [];
955
- this.uniqueSources = [];
956
- this.uniqueSourceIndexByFilename = {};
957
- }
958
- addSource(source) {
959
- if (source instanceof MagicString) return this.addSource({
960
- content: source,
961
- filename: source.filename,
962
- separator: this.separator
963
- });
964
- if (!isObject(source) || !source.content) throw new Error('bundle.addSource() takes an object with a `content` property, which should be an instance of MagicString, and an optional `filename`');
965
- [
966
- 'filename',
967
- 'ignoreList',
968
- 'indentExclusionRanges',
969
- 'separator'
970
- ].forEach((option)=>{
971
- if (!hasOwnProp.call(source, option)) source[option] = source.content[option];
972
- });
973
- if (void 0 === source.separator) source.separator = this.separator;
974
- if (source.filename) if (hasOwnProp.call(this.uniqueSourceIndexByFilename, source.filename)) {
975
- const uniqueSource = this.uniqueSources[this.uniqueSourceIndexByFilename[source.filename]];
976
- if (source.content.original !== uniqueSource.content) throw new Error(`Illegal source: same filename (${source.filename}), different contents`);
977
- } else {
978
- this.uniqueSourceIndexByFilename[source.filename] = this.uniqueSources.length;
979
- this.uniqueSources.push({
980
- filename: source.filename,
981
- content: source.content.original
982
- });
983
- }
984
- this.sources.push(source);
985
- return this;
986
- }
987
- append(str, options) {
988
- this.addSource({
989
- content: new MagicString(str),
990
- separator: options && options.separator || ''
991
- });
992
- return this;
993
- }
994
- clone() {
995
- const bundle = new Bundle({
996
- intro: this.intro,
997
- separator: this.separator
998
- });
999
- this.sources.forEach((source)=>{
1000
- bundle.addSource({
1001
- filename: source.filename,
1002
- content: source.content.clone(),
1003
- separator: source.separator
1004
- });
1005
- });
1006
- return bundle;
1007
- }
1008
- generateDecodedMap(options = {}) {
1009
- const names = [];
1010
- let x_google_ignoreList;
1011
- this.sources.forEach((source)=>{
1012
- Object.keys(source.content.storedNames).forEach((name)=>{
1013
- if (!~names.indexOf(name)) names.push(name);
1014
- });
1015
- });
1016
- const mappings = new Mappings(options.hires);
1017
- if (this.intro) mappings.advance(this.intro);
1018
- this.sources.forEach((source, i)=>{
1019
- if (i > 0) mappings.advance(this.separator);
1020
- const sourceIndex = source.filename ? this.uniqueSourceIndexByFilename[source.filename] : -1;
1021
- const magicString = source.content;
1022
- const locate = getLocator(magicString.original);
1023
- if (magicString.intro) mappings.advance(magicString.intro);
1024
- magicString.firstChunk.eachNext((chunk)=>{
1025
- const loc = locate(chunk.start);
1026
- if (chunk.intro.length) mappings.advance(chunk.intro);
1027
- if (source.filename) if (chunk.edited) mappings.addEdit(sourceIndex, chunk.content, loc, chunk.storeName ? names.indexOf(chunk.original) : -1);
1028
- else mappings.addUneditedChunk(sourceIndex, chunk, magicString.original, loc, magicString.sourcemapLocations);
1029
- else mappings.advance(chunk.content);
1030
- if (chunk.outro.length) mappings.advance(chunk.outro);
1031
- });
1032
- if (magicString.outro) mappings.advance(magicString.outro);
1033
- if (source.ignoreList && -1 !== sourceIndex) {
1034
- if (void 0 === x_google_ignoreList) x_google_ignoreList = [];
1035
- x_google_ignoreList.push(sourceIndex);
1036
- }
1037
- });
1038
- return {
1039
- file: options.file ? options.file.split(/[/\\]/).pop() : void 0,
1040
- sources: this.uniqueSources.map((source)=>options.file ? getRelativePath(options.file, source.filename) : source.filename),
1041
- sourcesContent: this.uniqueSources.map((source)=>options.includeContent ? source.content : null),
1042
- names,
1043
- mappings: mappings.raw,
1044
- x_google_ignoreList
1045
- };
1046
- }
1047
- generateMap(options) {
1048
- return new SourceMap(this.generateDecodedMap(options));
1049
- }
1050
- getIndentString() {
1051
- const indentStringCounts = {};
1052
- this.sources.forEach((source)=>{
1053
- const indentStr = source.content._getRawIndentString();
1054
- if (null === indentStr) return;
1055
- if (!indentStringCounts[indentStr]) indentStringCounts[indentStr] = 0;
1056
- indentStringCounts[indentStr] += 1;
1057
- });
1058
- return Object.keys(indentStringCounts).sort((a, b)=>indentStringCounts[a] - indentStringCounts[b])[0] || '\t';
1059
- }
1060
- indent(indentStr) {
1061
- if (!arguments.length) indentStr = this.getIndentString();
1062
- if ('' === indentStr) return this;
1063
- let trailingNewline = !this.intro || '\n' === this.intro.slice(-1);
1064
- this.sources.forEach((source, i)=>{
1065
- const separator = void 0 !== source.separator ? source.separator : this.separator;
1066
- const indentStart = trailingNewline || i > 0 && /\r?\n$/.test(separator);
1067
- source.content.indent(indentStr, {
1068
- exclude: source.indentExclusionRanges,
1069
- indentStart
1070
- });
1071
- trailingNewline = '\n' === source.content.lastChar();
1072
- });
1073
- if (this.intro) this.intro = indentStr + this.intro.replace(/^[^\n]/gm, (match, index)=>index > 0 ? indentStr + match : match);
1074
- return this;
1075
- }
1076
- prepend(str) {
1077
- this.intro = str + this.intro;
1078
- return this;
1079
- }
1080
- toString() {
1081
- const body = this.sources.map((source, i)=>{
1082
- const separator = void 0 !== source.separator ? source.separator : this.separator;
1083
- const str = (i > 0 ? separator : '') + source.content.toString();
1084
- return str;
1085
- }).join('');
1086
- return this.intro + body;
1087
- }
1088
- isEmpty() {
1089
- if (this.intro.length && this.intro.trim()) return false;
1090
- if (this.sources.some((source)=>!source.content.isEmpty())) return false;
1091
- return true;
1092
- }
1093
- length() {
1094
- return this.sources.reduce((length, source)=>length + source.content.length(), this.intro.length);
1095
- }
1096
- trimLines() {
1097
- return this.trim('[\\r\\n]');
1098
- }
1099
- trim(charType) {
1100
- return this.trimStart(charType).trimEnd(charType);
1101
- }
1102
- trimStart(charType) {
1103
- const rx = new RegExp('^' + (charType || '\\s') + '+');
1104
- this.intro = this.intro.replace(rx, '');
1105
- if (!this.intro) {
1106
- let source;
1107
- let i = 0;
1108
- do {
1109
- source = this.sources[i++];
1110
- if (!source) break;
1111
- }while (!source.content.trimStartAborted(charType));
1112
- }
1113
- return this;
1114
- }
1115
- trimEnd(charType) {
1116
- const rx = new RegExp((charType || '\\s') + '+$');
1117
- let source;
1118
- let i = this.sources.length - 1;
1119
- do {
1120
- source = this.sources[i--];
1121
- if (!source) {
1122
- this.intro = this.intro.replace(rx, '');
1123
- break;
1124
- }
1125
- }while (!source.content.trimEndAborted(charType));
1126
- return this;
1127
- }
1128
- }
949
+ Object.prototype.hasOwnProperty;
1129
950
  export default MagicString;
1130
- export { Bundle, SourceMap };
package/dist/0~restart.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import "node:module";
2
- import { __webpack_require__ } from "./rslib-runtime.js";
2
+ import { __webpack_require__ } from "./0~rslib-runtime.js";
3
3
  import node_path from "node:path";
4
4
  import { color as logger_color, logger as logger_logger, isTTY } from "./6830.js";
5
5
  import { runRest } from "./3145.js";
@@ -1,6 +1,6 @@
1
1
  /*! LICENSE: 0~snapshot.js.LICENSE.txt */
2
2
  import "node:module";
3
- import { __webpack_require__ } from "./rslib-runtime.js";
3
+ import { __webpack_require__ } from "./0~rslib-runtime.js";
4
4
  import { resolve as pathe_M_eThtNZ_resolve, getTaskNameWithPrefix } from "./6830.js";
5
5
  import { format, dist_plugins } from "./9784.js";
6
6
  import { iterableEquality, dist_equals, subsetEquality } from "./1949.js";
package/dist/1255.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import "node:module";
2
- import * as __rspack_external_node_fs_5ea92f0c from "node:fs";
3
- import * as __rspack_external_node_path_c5b9b54f from "node:path";
4
- import { __webpack_require__ } from "./rslib-runtime.js";
2
+ import { __webpack_require__ } from "./0~rslib-runtime.js";
3
+ import { createRequire as __rspack_createRequire } from "node:module";
4
+ const __rspack_createRequire_require = __rspack_createRequire(import.meta.url);
5
5
  __webpack_require__.add({
6
6
  "../../node_modules/.pnpm/buffer-from@1.1.2/node_modules/buffer-from/index.js" (module) {
7
7
  var toString = Object.prototype.toString;
@@ -36,10 +36,10 @@ __webpack_require__.add({
36
36
  "../../node_modules/.pnpm/source-map-support@0.5.21/node_modules/source-map-support/source-map-support.js" (module, exports, __webpack_require__) {
37
37
  module = __webpack_require__.nmd(module);
38
38
  var SourceMapConsumer = __webpack_require__("../../node_modules/.pnpm/source-map@0.6.1/node_modules/source-map/source-map.js").YK;
39
- var path = __webpack_require__("path?7a8d");
39
+ var path = __webpack_require__("path?435f");
40
40
  var fs;
41
41
  try {
42
- fs = __webpack_require__("fs?6bb1");
42
+ fs = __webpack_require__("fs?9592");
43
43
  if (!fs.existsSync || !fs.readFileSync) fs = null;
44
44
  } catch (err) {}
45
45
  var bufferFrom = __webpack_require__("../../node_modules/.pnpm/buffer-from@1.1.2/node_modules/buffer-from/index.js");
@@ -741,7 +741,7 @@ __webpack_require__.add({
741
741
  }
742
742
  return mappings;
743
743
  };
744
- exports.SourceMapConsumer = SourceMapConsumer;
744
+ exports.YK = SourceMapConsumer;
745
745
  function BasicSourceMapConsumer(aSourceMap, aSourceMapURL) {
746
746
  var sourceMap = aSourceMap;
747
747
  if ('string' == typeof aSourceMap) sourceMap = util.parseSourceMapInput(aSourceMap);
@@ -1729,14 +1729,14 @@ __webpack_require__.add({
1729
1729
  },
1730
1730
  "../../node_modules/.pnpm/source-map@0.6.1/node_modules/source-map/source-map.js" (__unused_rspack_module, exports, __webpack_require__) {
1731
1731
  __webpack_require__("../../node_modules/.pnpm/source-map@0.6.1/node_modules/source-map/lib/source-map-generator.js").x;
1732
- exports.YK = __webpack_require__("../../node_modules/.pnpm/source-map@0.6.1/node_modules/source-map/lib/source-map-consumer.js").SourceMapConsumer;
1732
+ exports.YK = __webpack_require__("../../node_modules/.pnpm/source-map@0.6.1/node_modules/source-map/lib/source-map-consumer.js").YK;
1733
1733
  __webpack_require__("../../node_modules/.pnpm/source-map@0.6.1/node_modules/source-map/lib/source-node.js");
1734
1734
  },
1735
- "fs?6bb1" (module) {
1736
- module.exports = __rspack_external_node_fs_5ea92f0c;
1735
+ "fs?9592" (module) {
1736
+ module.exports = __rspack_createRequire_require("node:fs");
1737
1737
  },
1738
- "path?7a8d" (module) {
1739
- module.exports = __rspack_external_node_path_c5b9b54f;
1738
+ "path?435f" (module) {
1739
+ module.exports = __rspack_createRequire_require("node:path");
1740
1740
  }
1741
1741
  });
1742
1742
  const gracefulExit = process.execArgv.some((execArg)=>execArg.startsWith('--perf') || execArg.startsWith('--prof') || execArg.startsWith('--cpu-prof') || execArg.startsWith('--heap-prof') || execArg.startsWith('--diagnostic-dir'));