@rstest/core 0.9.3 → 0.9.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.
- package/dist/0~8843.js +10 -4
- package/dist/0~browserLoader.js +1 -1
- package/dist/0~browser~1.js +2 -2
- package/dist/0~listTests.js +11 -7
- package/dist/0~loadEsModule.js +3 -1
- package/dist/0~runTests.js +6 -2
- package/dist/3145.js +53 -35
- package/dist/7704.js +1 -2
- package/dist/worker.js +21 -2
- package/package.json +1 -1
package/dist/0~8843.js
CHANGED
|
@@ -344,8 +344,12 @@ const filterAssetsByEntry = async (entryInfo, getAssetFiles, getSourceMaps, setu
|
|
|
344
344
|
...entryInfo.files,
|
|
345
345
|
...setupAssets
|
|
346
346
|
]));
|
|
347
|
-
const
|
|
348
|
-
const
|
|
347
|
+
const neededFilesPromise = getAssetFiles(assetNames);
|
|
348
|
+
const neededSourceMapsPromise = getSourceMaps(assetNames);
|
|
349
|
+
const [neededFiles, neededSourceMaps] = await Promise.all([
|
|
350
|
+
neededFilesPromise,
|
|
351
|
+
neededSourceMapsPromise
|
|
352
|
+
]);
|
|
349
353
|
return {
|
|
350
354
|
assetFiles: neededFiles,
|
|
351
355
|
sourceMaps: neededSourceMaps
|
|
@@ -1073,8 +1077,10 @@ const prepareRsbuild = async (context, globTestSourceEntries, setupFiles, global
|
|
|
1073
1077
|
}
|
|
1074
1078
|
});
|
|
1075
1079
|
if (coverage?.enabled && 'list' !== command) {
|
|
1076
|
-
const { loadCoverageProvider } = await
|
|
1077
|
-
|
|
1080
|
+
const [{ loadCoverageProvider }, { pluginCoverageCore }] = await Promise.all([
|
|
1081
|
+
import("./7704.js"),
|
|
1082
|
+
import("./0~plugin.js")
|
|
1083
|
+
]);
|
|
1078
1084
|
const { pluginCoverage } = await loadCoverageProvider(coverage, context.rootPath);
|
|
1079
1085
|
coverage.exclude.push(...Object.values(setupFiles).flatMap((files)=>Object.values(files)), ...Object.values(globalSetupFiles || {}).flatMap((files)=>Object.values(files)));
|
|
1080
1086
|
rsbuildInstance.addPlugins([
|
package/dist/0~browserLoader.js
CHANGED
|
@@ -4,7 +4,7 @@ import { pathToFileURL } from "node:url";
|
|
|
4
4
|
import "./4411.js";
|
|
5
5
|
import { logger as logger_logger, color as logger_color } from "./6830.js";
|
|
6
6
|
async function loadBrowserModule(options = {}) {
|
|
7
|
-
const coreVersion = "0.9.
|
|
7
|
+
const coreVersion = "0.9.4";
|
|
8
8
|
const { projectRoots = [] } = options;
|
|
9
9
|
let browserModule;
|
|
10
10
|
let browserVersion;
|
package/dist/0~browser~1.js
CHANGED
|
@@ -372,7 +372,7 @@ async function createInteractive(cwd, projectInfo, isAgent) {
|
|
|
372
372
|
}
|
|
373
373
|
const provider = providerSelection;
|
|
374
374
|
const preview = computeFilePreview(cwd, projectInfo);
|
|
375
|
-
const deps = getDependenciesWithVersions(effectiveFramework, provider, "0.9.
|
|
375
|
+
const deps = getDependenciesWithVersions(effectiveFramework, provider, "0.9.4");
|
|
376
376
|
const depsList = Object.entries(deps).map(([name, version])=>`${name}@${version}`).join(', ');
|
|
377
377
|
const previewLines = [
|
|
378
378
|
`${logger_color.cyan('+')} Create ${preview.configFile}`,
|
|
@@ -450,7 +450,7 @@ async function generateFiles(cwd, projectInfo, provider) {
|
|
|
450
450
|
updatePackageJsonScripts(cwd, {
|
|
451
451
|
'test:browser': 'rstest --config=rstest.browser.config.ts'
|
|
452
452
|
});
|
|
453
|
-
const deps = getDependenciesWithVersions(effectiveFramework, provider, "0.9.
|
|
453
|
+
const deps = getDependenciesWithVersions(effectiveFramework, provider, "0.9.4");
|
|
454
454
|
updatePackageJsonDevDeps(cwd, deps);
|
|
455
455
|
return createdFiles;
|
|
456
456
|
}
|
package/dist/0~listTests.js
CHANGED
|
@@ -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~runTests.js
CHANGED
|
@@ -292,8 +292,12 @@ async function runTests(context) {
|
|
|
292
292
|
if (entries.length && globalSetupEntries.length && !p._globalSetups) {
|
|
293
293
|
p._globalSetups = true;
|
|
294
294
|
const files = globalSetupEntries.flatMap((e)=>e.files);
|
|
295
|
-
const
|
|
296
|
-
const
|
|
295
|
+
const assetFilesPromise = getAssetFiles(files);
|
|
296
|
+
const sourceMapsPromise = getSourceMaps(files);
|
|
297
|
+
const [assetFiles, sourceMaps] = await Promise.all([
|
|
298
|
+
assetFilesPromise,
|
|
299
|
+
sourceMapsPromise
|
|
300
|
+
]);
|
|
297
301
|
const { success, errors } = await runGlobalSetup({
|
|
298
302
|
globalSetupEntries,
|
|
299
303
|
assetFiles,
|
package/dist/3145.js
CHANGED
|
@@ -16,12 +16,14 @@ import "./5040.js";
|
|
|
16
16
|
var init_namespaceObject = {};
|
|
17
17
|
__webpack_require__.r(init_namespaceObject);
|
|
18
18
|
__webpack_require__.d(init_namespaceObject, {
|
|
19
|
-
initCli: ()=>init_initCli
|
|
19
|
+
initCli: ()=>init_initCli,
|
|
20
|
+
resolveProjects: ()=>resolveProjects
|
|
20
21
|
});
|
|
21
|
-
var
|
|
22
|
-
__webpack_require__.r(
|
|
23
|
-
__webpack_require__.d(
|
|
24
|
-
createRstest: ()=>core_createRstest
|
|
22
|
+
var core_namespaceObject = {};
|
|
23
|
+
__webpack_require__.r(core_namespaceObject);
|
|
24
|
+
__webpack_require__.d(core_namespaceObject, {
|
|
25
|
+
createRstest: ()=>core_createRstest,
|
|
26
|
+
initCli: ()=>init_initCli
|
|
25
27
|
});
|
|
26
28
|
var error_namespaceObject = {};
|
|
27
29
|
__webpack_require__.r(error_namespaceObject);
|
|
@@ -587,7 +589,7 @@ function prepareCli() {
|
|
|
587
589
|
if (!npm_execpath || npm_execpath.includes('npx-cli.js') || npm_execpath.includes('.bun')) logger_logger.log();
|
|
588
590
|
}
|
|
589
591
|
function showRstest() {
|
|
590
|
-
logger_logger.greet(" Rstest v0.9.
|
|
592
|
+
logger_logger.greet(" Rstest v0.9.4");
|
|
591
593
|
logger_logger.log('');
|
|
592
594
|
}
|
|
593
595
|
const applyCommonOptions = (cli)=>{
|
|
@@ -602,15 +604,26 @@ const handleUnexpectedExit = (rstest, err)=>{
|
|
|
602
604
|
logger_logger.error(formatError(err));
|
|
603
605
|
process.exit(1);
|
|
604
606
|
};
|
|
607
|
+
const resolveCliRuntime = async (options)=>{
|
|
608
|
+
const [{ initCli }, { createRstest }] = await Promise.all([
|
|
609
|
+
Promise.resolve(init_namespaceObject),
|
|
610
|
+
Promise.resolve(core_namespaceObject)
|
|
611
|
+
]);
|
|
612
|
+
const { config, configFilePath, projects } = await initCli(options);
|
|
613
|
+
return {
|
|
614
|
+
config,
|
|
615
|
+
configFilePath,
|
|
616
|
+
projects,
|
|
617
|
+
createRstest
|
|
618
|
+
};
|
|
619
|
+
};
|
|
605
620
|
const runRest = async ({ options, filters, command })=>{
|
|
606
621
|
let rstest;
|
|
607
622
|
const unexpectedlyExitHandler = (err)=>{
|
|
608
623
|
handleUnexpectedExit(rstest, err);
|
|
609
624
|
};
|
|
610
625
|
try {
|
|
611
|
-
const {
|
|
612
|
-
const { config, configFilePath, projects } = await initCli(options);
|
|
613
|
-
const { createRstest } = await Promise.resolve(src_core_namespaceObject);
|
|
626
|
+
const { config, configFilePath, projects, createRstest } = await resolveCliRuntime(options);
|
|
614
627
|
rstest = createRstest({
|
|
615
628
|
config,
|
|
616
629
|
configFilePath,
|
|
@@ -638,7 +651,7 @@ const runRest = async ({ options, filters, command })=>{
|
|
|
638
651
|
function setupCommands() {
|
|
639
652
|
const cli = cac('rstest');
|
|
640
653
|
cli.help();
|
|
641
|
-
cli.version("0.9.
|
|
654
|
+
cli.version("0.9.4");
|
|
642
655
|
applyCommonOptions(cli);
|
|
643
656
|
cli.command('[...filters]', 'run tests').option('-w, --watch', 'Run tests in watch mode').action(async (filters, options)=>{
|
|
644
657
|
if (!determineAgent().isAgent) showRstest();
|
|
@@ -671,10 +684,8 @@ function setupCommands() {
|
|
|
671
684
|
});
|
|
672
685
|
cli.command('list [...filters]', 'lists all test files that Rstest will run').option('--filesOnly', 'only list the test files').option('--json [boolean/path]', 'print tests as JSON or write to a file').option('--includeSuites', 'include suites in output').option('--printLocation', 'print test case location').action(async (filters, options)=>{
|
|
673
686
|
try {
|
|
674
|
-
const {
|
|
675
|
-
const { config, configFilePath, projects } = await initCli(options);
|
|
687
|
+
const { config, configFilePath, projects, createRstest } = await resolveCliRuntime(options);
|
|
676
688
|
if (options.printLocation) config.includeTaskLocation = true;
|
|
677
|
-
const { createRstest } = await Promise.resolve(src_core_namespaceObject);
|
|
678
689
|
const rstest = createRstest({
|
|
679
690
|
config,
|
|
680
691
|
configFilePath,
|
|
@@ -695,9 +706,7 @@ function setupCommands() {
|
|
|
695
706
|
cli.command('merge-reports [path]', 'Merge blob reports from multiple shards into a unified report').option('--cleanup', 'Remove blob reports directory after merging').action(async (path, options)=>{
|
|
696
707
|
if (!determineAgent().isAgent) showRstest();
|
|
697
708
|
try {
|
|
698
|
-
const {
|
|
699
|
-
const { config, configFilePath, projects } = await initCli(options);
|
|
700
|
-
const { createRstest } = await Promise.resolve(src_core_namespaceObject);
|
|
709
|
+
const { config, configFilePath, projects, createRstest } = await resolveCliRuntime(options);
|
|
701
710
|
const rstest = createRstest({
|
|
702
711
|
config,
|
|
703
712
|
configFilePath,
|
|
@@ -1067,22 +1076,23 @@ async function resolveProjects({ config, root, options }) {
|
|
|
1067
1076
|
const getProjects = async (rstestConfig, root)=>{
|
|
1068
1077
|
const projectPaths = [];
|
|
1069
1078
|
const projectPatterns = [];
|
|
1070
|
-
const
|
|
1071
|
-
|
|
1079
|
+
const inlineProjectConfigPromises = [];
|
|
1080
|
+
for (const p of rstestConfig.projects || []){
|
|
1072
1081
|
if ('object' == typeof p) {
|
|
1073
1082
|
const projectRoot = p.root ? formatRootStr(p.root, root) : root;
|
|
1074
|
-
|
|
1083
|
+
inlineProjectConfigPromises.push(resolveExtends({
|
|
1075
1084
|
...p
|
|
1076
|
-
})
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1085
|
+
}).then((projectConfig)=>({
|
|
1086
|
+
config: mergeWithCLIOptions({
|
|
1087
|
+
root: projectRoot,
|
|
1088
|
+
...projectConfig,
|
|
1089
|
+
name: p.name ? p.name : getDefaultProjectName(projectRoot)
|
|
1090
|
+
}, options),
|
|
1091
|
+
configFilePath: void 0
|
|
1092
|
+
}), (error)=>({
|
|
1093
|
+
error
|
|
1094
|
+
})));
|
|
1095
|
+
continue;
|
|
1086
1096
|
}
|
|
1087
1097
|
const projectStr = formatRootStr(p, root);
|
|
1088
1098
|
if (isDynamicPattern(projectStr)) projectPatterns.push(projectStr);
|
|
@@ -1091,8 +1101,16 @@ async function resolveProjects({ config, root, options }) {
|
|
|
1091
1101
|
if (!existsSync(absolutePath)) throw `Can't resolve project "${p}", please make sure "${p}" is a existing file or a directory.`;
|
|
1092
1102
|
projectPaths.push(absolutePath);
|
|
1093
1103
|
}
|
|
1094
|
-
}
|
|
1095
|
-
|
|
1104
|
+
}
|
|
1105
|
+
const [inlineProjectConfigResults, globbedProjectPaths] = await Promise.all([
|
|
1106
|
+
Promise.all(inlineProjectConfigPromises),
|
|
1107
|
+
globProjects(projectPatterns, root)
|
|
1108
|
+
]);
|
|
1109
|
+
const projectConfigs = inlineProjectConfigResults.map((result)=>{
|
|
1110
|
+
if ('error' in result) throw result.error;
|
|
1111
|
+
return result;
|
|
1112
|
+
});
|
|
1113
|
+
projectPaths.push(...globbedProjectPaths);
|
|
1096
1114
|
const projects = [];
|
|
1097
1115
|
await Promise.all(projectPaths.map(async (project)=>{
|
|
1098
1116
|
const isDirectory = statSync(project).isDirectory();
|
|
@@ -1613,7 +1631,7 @@ class BlobReporter {
|
|
|
1613
1631
|
const shard = this.config.shard;
|
|
1614
1632
|
const fileName = shard ? `blob-${shard.index}-${shard.count}.json` : 'blob.json';
|
|
1615
1633
|
const blobData = {
|
|
1616
|
-
version: "0.9.
|
|
1634
|
+
version: "0.9.4",
|
|
1617
1635
|
shard: shard ? {
|
|
1618
1636
|
index: shard.index,
|
|
1619
1637
|
count: shard.count
|
|
@@ -3271,7 +3289,7 @@ class MdReporter {
|
|
|
3271
3289
|
}
|
|
3272
3290
|
renderFrontMatter(lines) {
|
|
3273
3291
|
const frontMatter = {
|
|
3274
|
-
tool: "@rstest/core@0.9.
|
|
3292
|
+
tool: "@rstest/core@0.9.4",
|
|
3275
3293
|
timestamp: new Date().toISOString()
|
|
3276
3294
|
};
|
|
3277
3295
|
if (this.options.header.env) frontMatter.runtime = {
|
|
@@ -3645,7 +3663,7 @@ class Rstest {
|
|
|
3645
3663
|
updateSnapshot: rstestConfig.update ? 'all' : dist_m ? 'none' : 'new'
|
|
3646
3664
|
});
|
|
3647
3665
|
this.snapshotManager = snapshotManager;
|
|
3648
|
-
this.version = "0.9.
|
|
3666
|
+
this.version = "0.9.4";
|
|
3649
3667
|
this.rootPath = rootPath;
|
|
3650
3668
|
this.originalConfig = userConfig;
|
|
3651
3669
|
this.normalizedConfig = rstestConfig;
|
|
@@ -3784,4 +3802,4 @@ function defineConfig(config) {
|
|
|
3784
3802
|
function defineProject(config) {
|
|
3785
3803
|
return config;
|
|
3786
3804
|
}
|
|
3787
|
-
export { config_loadConfig as loadConfig, core_createRstest as createRstest, defineConfig, defineProject, detect, error_parseErrorStacktrace as parseErrorStacktrace, error_printError as printError, formatStack, init_initCli as initCli, mergeProjectConfig, mergeRstestConfig, resolveCommand, runCLI, runRest };
|
|
3805
|
+
export { config_loadConfig as loadConfig, core_createRstest as createRstest, core_namespaceObject, defineConfig, defineProject, detect, error_parseErrorStacktrace as parseErrorStacktrace, error_printError as printError, formatStack, init_initCli as initCli, init_namespaceObject, mergeProjectConfig, mergeRstestConfig, resolveCommand, runCLI, runRest };
|
package/dist/7704.js
CHANGED
|
@@ -36,5 +36,4 @@ async function createCoverageProvider(options, root) {
|
|
|
36
36
|
}
|
|
37
37
|
throw new Error(`Unknown coverage provider: ${options.provider}`);
|
|
38
38
|
}
|
|
39
|
-
|
|
40
|
-
export { coverage_CoverageProviderMap as CoverageProviderMap, createCoverageProvider, loadCoverageProvider };
|
|
39
|
+
export { CoverageProviderMap, createCoverageProvider, loadCoverageProvider };
|
package/dist/worker.js
CHANGED
|
@@ -101,6 +101,25 @@ const registerGlobalApi = (api)=>globalApis.reduce((apis, key)=>{
|
|
|
101
101
|
}, {});
|
|
102
102
|
const globalCleanups = [];
|
|
103
103
|
let isTeardown = false;
|
|
104
|
+
const setErrorName = (error, type)=>{
|
|
105
|
+
try {
|
|
106
|
+
error.name = type;
|
|
107
|
+
return error;
|
|
108
|
+
} catch {
|
|
109
|
+
try {
|
|
110
|
+
Object.defineProperty(error, 'name', {
|
|
111
|
+
value: type,
|
|
112
|
+
configurable: true
|
|
113
|
+
});
|
|
114
|
+
return error;
|
|
115
|
+
} catch {
|
|
116
|
+
const fallbackError = new Error(error.message);
|
|
117
|
+
fallbackError.name = type;
|
|
118
|
+
fallbackError.stack = error.stack;
|
|
119
|
+
return fallbackError;
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
};
|
|
104
123
|
const setupEnv = (env)=>{
|
|
105
124
|
if (env) Object.entries(env).forEach(([key, value])=>{
|
|
106
125
|
if (void 0 === value) delete process.env[key];
|
|
@@ -152,8 +171,8 @@ const preparePool = async ({ entryInfo: { distPath, testPath }, updateSnapshot,
|
|
|
152
171
|
const { createRstestRuntime } = await import("./1949.js");
|
|
153
172
|
const unhandledErrors = [];
|
|
154
173
|
const handleError = (e, type)=>{
|
|
155
|
-
const
|
|
156
|
-
error.name
|
|
174
|
+
const rawError = 'string' == typeof e ? new Error(e) : e;
|
|
175
|
+
const error = rawError.name && 'Error' !== rawError.name ? rawError : setErrorName(rawError, type);
|
|
157
176
|
if (isTeardown) {
|
|
158
177
|
error.stack = `${logger_color.yellow('Caught error after test environment was torn down:')}\n\n${error.stack}`;
|
|
159
178
|
console.error(error);
|