@rstest/core 0.9.3 → 0.9.5
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/LICENSE.md +0 -228
- package/dist/0~8843.js +33 -17
- package/dist/0~browserLoader.js +1 -1
- package/dist/0~browser~1.js +4 -4
- package/dist/0~checkThresholds.js +1 -1
- package/dist/0~console.js +1 -1
- package/dist/0~fake-timers.js +1483 -0
- package/dist/0~generate.js +4 -3
- package/dist/0~happyDom.js +1 -1
- package/dist/0~jsdom.js +1 -1
- package/dist/0~listTests.js +14 -10
- package/dist/0~loadEsModule.js +3 -1
- package/dist/0~loadModule.js +1 -1
- package/dist/0~runTests.js +17 -6
- package/dist/0~snapshot.js +2140 -0
- package/dist/0~snapshot.js.LICENSE.txt +7 -0
- package/dist/0~utils.js +1 -1
- package/dist/1949.js +2919 -9808
- package/dist/1949.js.LICENSE.txt +1 -49
- package/dist/3145.js +363 -63
- package/dist/4411.js +232 -47
- package/dist/6830.js +61 -9
- package/dist/7552.js +22 -4918
- package/dist/7704.js +1 -2
- package/dist/9743.js +1982 -0
- package/dist/9784.js +1343 -0
- package/dist/{7552.js.LICENSE.txt → 9784.js.LICENSE.txt} +19 -8
- package/dist/browser-runtime/2~fake-timers.js +1653 -0
- package/dist/browser-runtime/2~snapshot.js +2138 -0
- package/dist/browser-runtime/2~snapshot.js.LICENSE.txt +7 -0
- package/dist/browser-runtime/723.js +2055 -10605
- package/dist/browser-runtime/723.js.LICENSE.txt +0 -17
- package/dist/browser-runtime/index.d.ts +189 -11
- package/dist/browser-runtime/rslib-runtime.js +0 -7
- package/dist/browser.d.ts +39 -5
- package/dist/browser.js +2 -2
- package/dist/globalSetupWorker.js +1 -1
- package/dist/index.d.ts +39 -5
- package/dist/mockRuntimeCode.js +2 -0
- package/dist/worker.d.ts +31 -5
- package/dist/worker.js +32 -11
- package/package.json +21 -22
package/dist/0~generate.js
CHANGED
|
@@ -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
|
|
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)=>!
|
|
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
|
-
|
|
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) {
|
package/dist/0~happyDom.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: '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)=>{
|
package/dist/0~listTests.js
CHANGED
|
@@ -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 {
|
|
6
|
-
import { logger as logger_logger,
|
|
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,
|
|
@@ -49,8 +49,12 @@ const collectNodeTests = async ({ context, nodeProjects, globTestSourceEntries }
|
|
|
49
49
|
if (entries.length && globalSetupEntries.length && !project._globalSetups) {
|
|
50
50
|
project._globalSetups = true;
|
|
51
51
|
const files = globalSetupEntries.flatMap((e)=>e.files);
|
|
52
|
-
const
|
|
53
|
-
const
|
|
52
|
+
const assetFilesPromise = getAssetFiles(files);
|
|
53
|
+
const sourceMapsPromise = getSourceMaps(files);
|
|
54
|
+
const [assetFiles, sourceMaps] = await Promise.all([
|
|
55
|
+
assetFilesPromise,
|
|
56
|
+
sourceMapsPromise
|
|
57
|
+
]);
|
|
54
58
|
const { success, errors } = await runGlobalSetup({
|
|
55
59
|
globalSetupEntries,
|
|
56
60
|
assetFiles,
|
|
@@ -111,15 +115,15 @@ const collectBrowserTests = async ({ context, browserProjects, shardedEntries })
|
|
|
111
115
|
});
|
|
112
116
|
};
|
|
113
117
|
const collectTestFiles = async ({ context, globTestSourceEntries })=>{
|
|
114
|
-
const
|
|
115
|
-
for (const project of context.projects){
|
|
118
|
+
const projectLists = await Promise.all(context.projects.map(async (project)=>{
|
|
116
119
|
const files = await globTestSourceEntries(project.environmentName);
|
|
117
|
-
|
|
120
|
+
return Object.values(files).map((testPath)=>({
|
|
118
121
|
testPath,
|
|
119
122
|
project: project.name,
|
|
120
123
|
tests: []
|
|
121
|
-
}))
|
|
122
|
-
}
|
|
124
|
+
}));
|
|
125
|
+
}));
|
|
126
|
+
const list = projectLists.flat();
|
|
123
127
|
return {
|
|
124
128
|
close: async ()=>void 0,
|
|
125
129
|
errors: [],
|
package/dist/0~loadEsModule.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import "node:module";
|
|
2
|
+
import { builtinModules } from "node:module";
|
|
2
3
|
import { isAbsolute } from "node:path";
|
|
3
4
|
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
4
5
|
import node_vm from "node:vm";
|
|
@@ -12,6 +13,7 @@ var loadEsModule_EsmMode = /*#__PURE__*/ function(EsmMode) {
|
|
|
12
13
|
return EsmMode;
|
|
13
14
|
}({});
|
|
14
15
|
const isRelativePath = (p)=>/^\.\.?\//.test(p);
|
|
16
|
+
const isBuiltinSpecifier = (specifier)=>specifier.startsWith('node:') || builtinModules.includes(specifier);
|
|
15
17
|
const defineRstestDynamicImport = ({ distPath, testPath, assetFiles, interopDefault, returnModule, esmMode })=>async (specifier, importAttributes)=>{
|
|
16
18
|
const currentDirectory = posix.dirname(distPath);
|
|
17
19
|
const joinedPath = isRelativePath(specifier) ? posix.join(currentDirectory, specifier) : specifier;
|
|
@@ -37,7 +39,7 @@ const defineRstestDynamicImport = ({ distPath, testPath, assetFiles, interopDefa
|
|
|
37
39
|
} catch (err) {
|
|
38
40
|
logger_logger.error(`load file ${joinedPath} failed:\n`, err instanceof Error ? err.message : err);
|
|
39
41
|
}
|
|
40
|
-
const resolvedPath = isAbsolute(specifier) ? pathToFileURL(specifier) : import.meta.resolve(specifier, pathToFileURL(testPath));
|
|
42
|
+
const resolvedPath = isAbsolute(specifier) ? pathToFileURL(specifier) : isBuiltinSpecifier(specifier) ? specifier : import.meta.resolve(specifier, pathToFileURL(testPath));
|
|
41
43
|
const modulePath = 'string' == typeof resolvedPath ? resolvedPath : resolvedPath.pathname;
|
|
42
44
|
if (importAttributes?.with?.rstest) delete importAttributes.with.rstest;
|
|
43
45
|
if (modulePath.endsWith('.json')) {
|
package/dist/0~loadModule.js
CHANGED
package/dist/0~runTests.js
CHANGED
|
@@ -212,9 +212,16 @@ async function runTests(context) {
|
|
|
212
212
|
};
|
|
213
213
|
let browserProjectsToRun = browserProjects;
|
|
214
214
|
let nodeProjectsToRun = nodeProjects;
|
|
215
|
-
if (
|
|
216
|
-
|
|
217
|
-
|
|
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,
|
|
@@ -292,8 +299,12 @@ async function runTests(context) {
|
|
|
292
299
|
if (entries.length && globalSetupEntries.length && !p._globalSetups) {
|
|
293
300
|
p._globalSetups = true;
|
|
294
301
|
const files = globalSetupEntries.flatMap((e)=>e.files);
|
|
295
|
-
const
|
|
296
|
-
const
|
|
302
|
+
const assetFilesPromise = getAssetFiles(files);
|
|
303
|
+
const sourceMapsPromise = getSourceMaps(files);
|
|
304
|
+
const [assetFiles, sourceMaps] = await Promise.all([
|
|
305
|
+
assetFilesPromise,
|
|
306
|
+
sourceMapsPromise
|
|
307
|
+
]);
|
|
297
308
|
const { success, errors } = await runGlobalSetup({
|
|
298
309
|
globalSetupEntries,
|
|
299
310
|
assetFiles,
|