@rstest/core 0.9.4 → 0.9.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (52) hide show
  1. package/LICENSE.md +54 -202
  2. package/dist/0~8843.js +32 -14
  3. package/dist/{0~lib.js → 0~@babel/code-frame.js} +2 -2
  4. package/dist/0~@clack/prompts.js +1044 -0
  5. package/dist/0~browserLoader.js +1 -1
  6. package/dist/0~browser~1.js +19 -19
  7. package/dist/0~checkThresholds.js +2 -2
  8. package/dist/0~chokidar.js +43 -42
  9. package/dist/0~console.js +1 -1
  10. package/dist/0~fake-timers.js +1586 -0
  11. package/dist/0~generate.js +5 -5
  12. package/dist/0~happyDom.js +1 -1
  13. package/dist/0~jsdom.js +1 -1
  14. package/dist/0~listTests.js +3 -3
  15. package/dist/0~loadModule.js +1 -1
  16. package/dist/0~magic-string.es.js +1 -181
  17. package/dist/0~restart.js +1 -1
  18. package/dist/0~runTests.js +11 -4
  19. package/dist/0~snapshot.js +2140 -0
  20. package/dist/0~snapshot.js.LICENSE.txt +7 -0
  21. package/dist/0~utils.js +1 -1
  22. package/dist/1255.js +11 -11
  23. package/dist/1949.js +2919 -9808
  24. package/dist/1949.js.LICENSE.txt +1 -49
  25. package/dist/3145.js +415 -40
  26. package/dist/4411.js +245 -60
  27. package/dist/6830.js +62 -10
  28. package/dist/6887.js +15 -0
  29. package/dist/7552.js +22 -4918
  30. package/dist/9743.js +1982 -0
  31. package/dist/9784.js +1343 -0
  32. package/dist/{7552.js.LICENSE.txt → 9784.js.LICENSE.txt} +19 -8
  33. package/dist/browser-runtime/2~fake-timers.js +1760 -0
  34. package/dist/browser-runtime/2~magic-string.es.js +3 -189
  35. package/dist/browser-runtime/2~snapshot.js +2138 -0
  36. package/dist/browser-runtime/2~snapshot.js.LICENSE.txt +7 -0
  37. package/dist/browser-runtime/723.js +1818 -10300
  38. package/dist/browser-runtime/723.js.LICENSE.txt +0 -17
  39. package/dist/browser-runtime/index.d.ts +205 -16
  40. package/dist/browser.d.ts +55 -10
  41. package/dist/browser.js +2 -2
  42. package/dist/globalSetupWorker.js +2 -2
  43. package/dist/index.d.ts +78 -16
  44. package/dist/index.js +1 -1
  45. package/dist/mockRuntimeCode.js +2 -0
  46. package/dist/worker.d.ts +47 -10
  47. package/dist/worker.js +12 -10
  48. package/package.json +27 -28
  49. package/dist/0~dist.js +0 -1014
  50. package/dist/4899.js +0 -11
  51. package/dist/browser-runtime/rslib-runtime.js +0 -56
  52. /package/dist/{rslib-runtime.js → 0~rslib-runtime.js} +0 -0
@@ -27,7 +27,7 @@ async function generateCoverage(context, results, coverageProvider) {
27
27
  return normalizedFile.startsWith(normalize(rootPath));
28
28
  });
29
29
  if (coverage.include?.length) {
30
- const coveredFiles = finalCoverageMap.files().map(normalize);
30
+ const coveredFilesSet = new Set(finalCoverageMap.files().map(normalize));
31
31
  let isTimeout = false;
32
32
  const timeoutId = setTimeout(()=>{
33
33
  isTimeout = true;
@@ -35,13 +35,14 @@ async function generateCoverage(context, results, coverageProvider) {
35
35
  }, 1000);
36
36
  const allFiles = (await Promise.all(projects.map(async (p)=>{
37
37
  const includedFiles = await getIncludedFiles(coverage, p.rootPath);
38
- const uncoveredFiles = includedFiles.filter((file)=>!coveredFiles.includes(normalize(file)));
38
+ const uncoveredFiles = includedFiles.filter((file)=>!coveredFilesSet.has(normalize(file)));
39
39
  if (uncoveredFiles.length) await generateCoverageForUntestedFiles(p.environmentName, uncoveredFiles, finalCoverageMap, coverageProvider);
40
40
  return includedFiles;
41
41
  }))).flat();
42
42
  clearTimeout(timeoutId);
43
43
  if (isTimeout) logger_logger.info('Coverage for untested files generated.');
44
- finalCoverageMap.filter((file)=>allFiles.includes(normalize(file)));
44
+ const allFilesSet = new Set(allFiles.map(normalize));
45
+ finalCoverageMap.filter((file)=>allFilesSet.has(normalize(file)));
45
46
  }
46
47
  await coverageProvider.generateReports(finalCoverageMap, coverage);
47
48
  if (coverage.thresholds) {
@@ -73,5 +74,4 @@ async function generateCoverageForUntestedFiles(environmentName, uncoveredFiles,
73
74
  coverageMap.addFileCoverage(coverageData);
74
75
  });
75
76
  }
76
- var generate_getIncludedFiles = void 0;
77
- export { generateCoverage, generate_getIncludedFiles as getIncludedFiles };
77
+ export { generateCoverage };
@@ -1,6 +1,6 @@
1
1
  import "node:module";
2
- import { checkPkgInstalled } from "./7552.js";
3
2
  import { installGlobal, addDefaultErrorHandler } from "./0~utils.js";
3
+ import { checkPkgInstalled } from "./7552.js";
4
4
  const environment = {
5
5
  name: 'happy-dom',
6
6
  setup: async (global, options = {})=>{
package/dist/0~jsdom.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import "node:module";
2
- import { checkPkgInstalled } from "./7552.js";
3
2
  import { installGlobal, addDefaultErrorHandler } from "./0~utils.js";
3
+ import { checkPkgInstalled } from "./7552.js";
4
4
  const environment = {
5
5
  name: 'jsdom',
6
6
  setup: async (global, options)=>{
@@ -2,8 +2,8 @@ import "node:module";
2
2
  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
- import { getTestEntries, resolveShardedEntries, prettyTestPath, ROOT_SUITE_NAME } from "./4411.js";
6
- import { logger as logger_logger, getTaskNameWithPrefix, color as logger_color, bgColor } from "./6830.js";
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";
7
7
  const collectNodeTests = async ({ context, nodeProjects, globTestSourceEntries })=>{
8
8
  const { getSetupFiles } = await import("./255.js");
9
9
  if (0 === nodeProjects.length) return {
@@ -25,7 +25,7 @@ const collectNodeTests = async ({ context, nodeProjects, globTestSourceEntries }
25
25
  getSetupFiles(globalSetup, rootPath)
26
26
  ];
27
27
  }));
28
- const rsbuildInstance = await prepareRsbuild(context, globTestSourceEntries, setupFiles, globalSetupFiles);
28
+ const rsbuildInstance = await prepareRsbuild(context, globTestSourceEntries, setupFiles, globalSetupFiles, nodeProjects);
29
29
  const { getRsbuildStats, closeServer } = await createRsbuildServer({
30
30
  globTestSourceEntries,
31
31
  globalSetupFiles,
@@ -11,7 +11,7 @@ const loadModule_createRequire = (filename, distPath, rstestContext, assetFiles,
11
11
  const _require = (()=>{
12
12
  try {
13
13
  return createRequire(filename);
14
- } catch (_err) {
14
+ } catch {
15
15
  return createRequire(distPath);
16
16
  }
17
17
  })();
@@ -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";
@@ -212,9 +212,16 @@ async function runTests(context) {
212
212
  };
213
213
  let browserProjectsToRun = browserProjects;
214
214
  let nodeProjectsToRun = nodeProjects;
215
- if (shard) {
216
- browserProjectsToRun = browserProjects.filter((p)=>Object.keys(entriesCache.get(p.environmentName)?.entries || {}).length > 0);
217
- nodeProjectsToRun = nodeProjects.filter((p)=>Object.keys(entriesCache.get(p.environmentName)?.entries || {}).length > 0);
215
+ if (isWatchMode) {
216
+ if (shard) {
217
+ browserProjectsToRun = browserProjects.filter((p)=>Object.keys(entriesCache.get(p.environmentName)?.entries || {}).length > 0);
218
+ nodeProjectsToRun = nodeProjects.filter((p)=>Object.keys(entriesCache.get(p.environmentName)?.entries || {}).length > 0);
219
+ }
220
+ } else {
221
+ await Promise.all(allProjects.map((p)=>globTestSourceEntries(p.environmentName)));
222
+ const hasEntries = (env)=>Object.keys(entriesCache.get(env)?.entries || {}).length > 0;
223
+ browserProjectsToRun = browserProjects.filter((p)=>hasEntries(p.environmentName));
224
+ nodeProjectsToRun = nodeProjects.filter((p)=>hasEntries(p.environmentName));
218
225
  }
219
226
  const hasBrowserTestsToRun = browserProjectsToRun.length > 0;
220
227
  const hasNodeTestsToRun = nodeProjectsToRun.length > 0;
@@ -248,7 +255,7 @@ async function runTests(context) {
248
255
  getSetupFiles(globalSetup, rootPath)
249
256
  ];
250
257
  }));
251
- const rsbuildInstance = await prepareRsbuild(context, globTestSourceEntries, setupFiles, globalSetupFiles);
258
+ const rsbuildInstance = await prepareRsbuild(context, globTestSourceEntries, setupFiles, globalSetupFiles, projects);
252
259
  const { getRsbuildStats, closeServer } = await createRsbuildServer({
253
260
  inspectedConfig: {
254
261
  ...context.normalizedConfig,