@rstest/core 0.6.6 → 0.6.8
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~122.js +29 -2
- package/dist/0~173.js +4 -0
- package/dist/0~255.js +1 -1
- package/dist/0~583.js +1 -1
- package/dist/0~634.js +1 -1
- package/dist/155.js +136 -126
- package/dist/362.js +8 -2
- package/dist/946.js +2 -2
- package/{dist-types → dist}/index.d.ts +49 -22
- package/{dist-types → dist}/worker.d.ts +41 -18
- package/package.json +3 -4
package/dist/0~122.js
CHANGED
|
@@ -89,6 +89,8 @@ const createForksPool = (poolOptions)=>{
|
|
|
89
89
|
};
|
|
90
90
|
};
|
|
91
91
|
const external_node_os_ = __webpack_require__("node:os");
|
|
92
|
+
const picocolors = __webpack_require__("../../node_modules/.pnpm/picocolors@1.1.1/node_modules/picocolors/picocolors.js");
|
|
93
|
+
var picocolors_default = /*#__PURE__*/ __webpack_require__.n(picocolors);
|
|
92
94
|
const getNumCpus = ()=>external_node_os_["default"].availableParallelism?.() ?? external_node_os_["default"].cpus().length;
|
|
93
95
|
const parseWorkers = (maxWorkers)=>{
|
|
94
96
|
const parsed = Number.parseInt(maxWorkers.toString(), 10);
|
|
@@ -168,6 +170,7 @@ const createPool = async ({ context, recommendWorkerCount = 1 / 0 })=>{
|
|
|
168
170
|
});
|
|
169
171
|
const rpcMethods = {
|
|
170
172
|
onTestCaseStart: async (test)=>{
|
|
173
|
+
context.stateManager.onTestCaseStart(test);
|
|
171
174
|
Promise.all(reporters.map((reporter)=>reporter.onTestCaseStart?.(test)));
|
|
172
175
|
},
|
|
173
176
|
onTestCaseResult: async (result)=>{
|
|
@@ -216,6 +219,26 @@ const createPool = async ({ context, recommendWorkerCount = 1 / 0 })=>{
|
|
|
216
219
|
}
|
|
217
220
|
}).catch((err)=>{
|
|
218
221
|
err.fullStack = true;
|
|
222
|
+
if (err instanceof Error) {
|
|
223
|
+
if (err.message.includes('Worker exited unexpectedly')) delete err.stack;
|
|
224
|
+
const runningModule = context.stateManager.runningModules.get(entryInfo.testPath);
|
|
225
|
+
if (runningModule?.runningTests.length) {
|
|
226
|
+
const getCaseName = (test)=>`"${test.name}"${test.parentNames?.length ? ` (Under suite: ${test.parentNames?.join(' > ')})` : ''}`;
|
|
227
|
+
if (runningModule?.runningTests.length === 1) err.message += `\n\n${picocolors_default().white(`Maybe relevant test case: ${getCaseName(runningModule.runningTests[0])} which is running when the error occurs.`)}`;
|
|
228
|
+
else err.message += `\n\n${picocolors_default().white(`The below test cases may be relevant, as they were running when the error occurred:\n - ${runningModule.runningTests.map((t)=>getCaseName(t)).join('\n - ')}`)}`;
|
|
229
|
+
}
|
|
230
|
+
return {
|
|
231
|
+
testId: '0',
|
|
232
|
+
project: projectName,
|
|
233
|
+
testPath: entryInfo.testPath,
|
|
234
|
+
status: 'fail',
|
|
235
|
+
name: '',
|
|
236
|
+
results: runningModule?.results || [],
|
|
237
|
+
errors: [
|
|
238
|
+
err
|
|
239
|
+
]
|
|
240
|
+
};
|
|
241
|
+
}
|
|
219
242
|
return {
|
|
220
243
|
testId: '0',
|
|
221
244
|
project: projectName,
|
|
@@ -446,7 +469,7 @@ const pluginEntryWatch = ({ isWatch, globTestSourceEntries, setupFiles, context
|
|
|
446
469
|
});
|
|
447
470
|
const autoExternalNodeModules = ({ context, request, dependencyType, getResolve }, callback)=>{
|
|
448
471
|
if (!request) return callback();
|
|
449
|
-
if (request.startsWith('@swc/helpers/')) return callback();
|
|
472
|
+
if (request.startsWith('@swc/helpers/') || request.endsWith('.wasm')) return callback();
|
|
450
473
|
const doExternal = (externalPath = request)=>{
|
|
451
474
|
callback(void 0, externalPath, 'commonjs' === dependencyType ? 'commonjs' : 'import');
|
|
452
475
|
};
|
|
@@ -527,7 +550,7 @@ const pluginInspect = ()=>enable ? {
|
|
|
527
550
|
});
|
|
528
551
|
}
|
|
529
552
|
} : null;
|
|
530
|
-
const external_node_fs_ = __webpack_require__("fs");
|
|
553
|
+
const external_node_fs_ = __webpack_require__("node:fs");
|
|
531
554
|
const mockRuntime_dirname = external_node_path_["default"].dirname(fileURLToPath(import.meta.url));
|
|
532
555
|
class MockRuntimeRspackPlugin {
|
|
533
556
|
apply(compiler) {
|
|
@@ -551,6 +574,10 @@ class MockRuntimeRspackPlugin {
|
|
|
551
574
|
const finalSource = module.source.source.toString('utf-8').replace('enumerable: true, get:', 'enumerable: true, configurable: true, get:');
|
|
552
575
|
module.source.source = Buffer.from(finalSource);
|
|
553
576
|
}
|
|
577
|
+
if ('async_wasm_loading' === module.name) {
|
|
578
|
+
const finalSource = module.source.source.toString('utf-8').replace('readFile(', 'readWasmFile(');
|
|
579
|
+
module.source.source = Buffer.from(finalSource);
|
|
580
|
+
}
|
|
554
581
|
});
|
|
555
582
|
});
|
|
556
583
|
compiler.hooks.thisCompilation.tap('RstestMockPlugin', (compilation)=>{
|
package/dist/0~173.js
CHANGED
|
@@ -280,6 +280,10 @@ async function runTests(context) {
|
|
|
280
280
|
}));
|
|
281
281
|
await generateCoverage(context, results, coverageProvider);
|
|
282
282
|
}
|
|
283
|
+
if (isFailure) {
|
|
284
|
+
const bail = context.normalizedConfig.bail;
|
|
285
|
+
if (bail && context.stateManager.getCountOfFailedTests() >= bail) src_logger.log(picocolors_default().yellow(`Test run aborted due to reaching the bail limit of ${bail} failed test(s).`));
|
|
286
|
+
}
|
|
283
287
|
};
|
|
284
288
|
if ('watch' === command) {
|
|
285
289
|
const enableCliShortcuts = isCliShortcutsEnabled();
|
package/dist/0~255.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 "./946.js";
|
|
5
|
-
const external_node_fs_ = __webpack_require__("fs");
|
|
5
|
+
const external_node_fs_ = __webpack_require__("node:fs");
|
|
6
6
|
const pluginCoverageCore = (coverageOptions)=>({
|
|
7
7
|
name: 'rstest:coverage-core',
|
|
8
8
|
setup: (api)=>{
|
package/dist/0~583.js
CHANGED
|
@@ -220,7 +220,7 @@ function readdirp(root, options = {}) {
|
|
|
220
220
|
options.root = root;
|
|
221
221
|
return new ReaddirpStream(options);
|
|
222
222
|
}
|
|
223
|
-
const external_node_fs_ = __webpack_require__("fs");
|
|
223
|
+
const external_node_fs_ = __webpack_require__("node:fs");
|
|
224
224
|
const external_node_os_ = __webpack_require__("node:os");
|
|
225
225
|
const STR_DATA = 'data';
|
|
226
226
|
const STR_END = 'end';
|
package/dist/0~634.js
CHANGED
|
@@ -3,7 +3,7 @@ import 'module';
|
|
|
3
3
|
import { __webpack_require__ } from "./rslib-runtime.js";
|
|
4
4
|
import { getTestEntries, getSetupFiles, getTaskNameWithPrefix, prettyTestPath, src_logger } from "./946.js";
|
|
5
5
|
import { prepareRsbuild, createPool, createRsbuildServer } from "./0~122.js";
|
|
6
|
-
const external_node_fs_ = __webpack_require__("fs");
|
|
6
|
+
const external_node_fs_ = __webpack_require__("node:fs");
|
|
7
7
|
const external_node_path_ = __webpack_require__("node:path");
|
|
8
8
|
const picocolors = __webpack_require__("../../node_modules/.pnpm/picocolors@1.1.1/node_modules/picocolors/picocolors.js");
|
|
9
9
|
var picocolors_default = /*#__PURE__*/ __webpack_require__.n(picocolors);
|
package/dist/155.js
CHANGED
|
@@ -500,13 +500,13 @@ function prepareCli() {
|
|
|
500
500
|
if (!npm_execpath || npm_execpath.includes('npx-cli.js') || npm_execpath.includes('.bun')) console.log();
|
|
501
501
|
}
|
|
502
502
|
function showRstest() {
|
|
503
|
-
src_logger.greet(" Rstest v0.6.
|
|
503
|
+
src_logger.greet(" Rstest v0.6.8");
|
|
504
504
|
src_logger.log('');
|
|
505
505
|
}
|
|
506
506
|
const applyCommonOptions = (cli)=>{
|
|
507
507
|
cli.option('-c, --config <config>', 'Specify the configuration file, can be a relative or absolute path').option('--config-loader <loader>', 'Specify the loader to load the config file, can be `jiti` or `native`', {
|
|
508
508
|
default: 'jiti'
|
|
509
|
-
}).option('-r, --root <root>', 'Specify the project root directory, can be an absolute path or a path relative to cwd').option('--globals', 'Provide global APIs').option('--isolate', 'Run tests in an isolated environment').option('--include <include>', 'Match test files').option('--exclude <exclude>', 'Exclude files from test').option('-u, --update', 'Update snapshot files').option('--coverage', 'Enable code coverage collection').option('--project <name>', 'Run only projects that match the name, can be a full name or wildcards pattern').option('--passWithNoTests', 'Allows the test suite to pass when no files are found').option('--printConsoleTrace', 'Print console traces when calling any console method').option('--disableConsoleIntercept', 'Disable console intercept').option('--logHeapUsage', 'Log heap usage after each test').option('--slowTestThreshold <value>', 'The number of milliseconds after which a test or suite is considered slow').option('--reporter <reporter>', 'Specify the reporter to use').option('-t, --testNamePattern <value>', 'Run only tests with a name that matches the regex').option('--testEnvironment <name>', 'The environment that will be used for testing').option('--testTimeout <value>', 'Timeout of a test in milliseconds').option('--hookTimeout <value>', 'Timeout of hook in milliseconds').option('--hideSkippedTests', 'Hide skipped tests from the output').option('--retry <retry>', 'Number of times to retry a test if it fails').option('--bail
|
|
509
|
+
}).option('-r, --root <root>', 'Specify the project root directory, can be an absolute path or a path relative to cwd').option('--globals', 'Provide global APIs').option('--isolate', 'Run tests in an isolated environment').option('--include <include>', 'Match test files').option('--exclude <exclude>', 'Exclude files from test').option('-u, --update', 'Update snapshot files').option('--coverage', 'Enable code coverage collection').option('--project <name>', 'Run only projects that match the name, can be a full name or wildcards pattern').option('--passWithNoTests', 'Allows the test suite to pass when no files are found').option('--printConsoleTrace', 'Print console traces when calling any console method').option('--disableConsoleIntercept', 'Disable console intercept').option('--logHeapUsage', 'Log heap usage after each test').option('--slowTestThreshold <value>', 'The number of milliseconds after which a test or suite is considered slow').option('--reporter <reporter>', 'Specify the reporter to use').option('-t, --testNamePattern <value>', 'Run only tests with a name that matches the regex').option('--testEnvironment <name>', 'The environment that will be used for testing').option('--testTimeout <value>', 'Timeout of a test in milliseconds').option('--hookTimeout <value>', 'Timeout of hook in milliseconds').option('--hideSkippedTests', 'Hide skipped tests from the output').option('--retry <retry>', 'Number of times to retry a test if it fails').option('--bail [number]', 'Stop running tests after n failures. Set to 0 to run all tests regardless of failures').option('--maxConcurrency <value>', 'Maximum number of concurrent tests').option('--clearMocks', 'Automatically clear mock calls, instances, contexts and results before every test').option('--resetMocks', 'Automatically reset mock state before every test').option('--restoreMocks', 'Automatically restore mock state and implementation before every test').option('--unstubGlobals', 'Restores all global variables that were changed with `rstest.stubGlobal` before every test').option('--unstubEnvs', 'Restores all `process.env` values that were changed with `rstest.stubEnv` before every test');
|
|
510
510
|
};
|
|
511
511
|
const runRest = async ({ options, filters, command })=>{
|
|
512
512
|
let rstest;
|
|
@@ -544,7 +544,7 @@ const runRest = async ({ options, filters, command })=>{
|
|
|
544
544
|
function setupCommands() {
|
|
545
545
|
const cli = dist('rstest');
|
|
546
546
|
cli.help();
|
|
547
|
-
cli.version("0.6.
|
|
547
|
+
cli.version("0.6.8");
|
|
548
548
|
applyCommonOptions(cli);
|
|
549
549
|
cli.command('[...filters]', 'run tests').option('-w, --watch', 'Run tests in watch mode').action(async (filters, options)=>{
|
|
550
550
|
showRstest();
|
|
@@ -601,7 +601,7 @@ function setupCommands() {
|
|
|
601
601
|
});
|
|
602
602
|
cli.parse();
|
|
603
603
|
}
|
|
604
|
-
const external_node_fs_ = __webpack_require__("fs");
|
|
604
|
+
const external_node_fs_ = __webpack_require__("node:fs");
|
|
605
605
|
const picocolors = __webpack_require__("../../node_modules/.pnpm/picocolors@1.1.1/node_modules/picocolors/picocolors.js");
|
|
606
606
|
var picocolors_default = /*#__PURE__*/ __webpack_require__.n(picocolors);
|
|
607
607
|
const findConfig = (basePath)=>DEFAULT_CONFIG_EXTENSIONS.map((ext)=>basePath + ext).find(external_node_fs_["default"].existsSync);
|
|
@@ -745,12 +745,7 @@ const withDefaultConfig = (config)=>{
|
|
|
745
745
|
includeSource: merged.includeSource.map((p)=>formatRootStr(p, merged.root))
|
|
746
746
|
};
|
|
747
747
|
};
|
|
748
|
-
|
|
749
|
-
const { content: config, filePath: configFilePath } = await config_loadConfig({
|
|
750
|
-
cwd: options.root,
|
|
751
|
-
path: options.config,
|
|
752
|
-
configLoader: options.configLoader
|
|
753
|
-
});
|
|
748
|
+
function mergeWithCLIOptions(config, options) {
|
|
754
749
|
const keys = [
|
|
755
750
|
'root',
|
|
756
751
|
'globals',
|
|
@@ -772,19 +767,27 @@ async function resolveConfig(options) {
|
|
|
772
767
|
'disableConsoleIntercept',
|
|
773
768
|
'testEnvironment',
|
|
774
769
|
'hideSkippedTests',
|
|
775
|
-
'logHeapUsage'
|
|
776
|
-
'bail'
|
|
770
|
+
'logHeapUsage'
|
|
777
771
|
];
|
|
778
772
|
for (const key of keys)if (void 0 !== options[key]) config[key] = options[key];
|
|
779
773
|
if (options.reporter) config.reporters = castArray(options.reporter);
|
|
774
|
+
if (void 0 !== options.bail && ('number' == typeof options.bail || 'boolean' == typeof options.bail)) config.bail = Number(options.bail);
|
|
780
775
|
if (void 0 !== options.coverage) {
|
|
781
776
|
config.coverage ??= {};
|
|
782
777
|
config.coverage.enabled = options.coverage;
|
|
783
778
|
}
|
|
784
779
|
if (options.exclude) config.exclude = castArray(options.exclude);
|
|
785
780
|
if (options.include) config.include = castArray(options.include);
|
|
781
|
+
return config;
|
|
782
|
+
}
|
|
783
|
+
async function resolveConfig(options) {
|
|
784
|
+
const { content: config, filePath: configFilePath } = await config_loadConfig({
|
|
785
|
+
cwd: options.root,
|
|
786
|
+
path: options.config,
|
|
787
|
+
configLoader: options.configLoader
|
|
788
|
+
});
|
|
786
789
|
return {
|
|
787
|
-
config,
|
|
790
|
+
config: mergeWithCLIOptions(config, options),
|
|
788
791
|
configFilePath: configFilePath ?? void 0
|
|
789
792
|
};
|
|
790
793
|
}
|
|
@@ -796,7 +799,7 @@ async function resolveProjects({ config, root, options }) {
|
|
|
796
799
|
if ('string' != typeof name || !name) return basename(dir);
|
|
797
800
|
return name;
|
|
798
801
|
};
|
|
799
|
-
const globProjects = async (patterns)=>{
|
|
802
|
+
const globProjects = async (patterns, root)=>{
|
|
800
803
|
const globOptions = {
|
|
801
804
|
absolute: true,
|
|
802
805
|
dot: true,
|
|
@@ -810,48 +813,60 @@ async function resolveProjects({ config, root, options }) {
|
|
|
810
813
|
};
|
|
811
814
|
return glob(patterns, globOptions);
|
|
812
815
|
};
|
|
813
|
-
const
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
816
|
+
const resolvedProjectPaths = new Set();
|
|
817
|
+
const getProjects = async (rstestConfig, root)=>{
|
|
818
|
+
const { projectPaths, projectPatterns, projectConfigs } = (rstestConfig.projects || []).reduce((total, p)=>{
|
|
819
|
+
if ('object' == typeof p) {
|
|
820
|
+
const projectRoot = p.root ? formatRootStr(p.root, root) : root;
|
|
821
|
+
total.projectConfigs.push({
|
|
822
|
+
config: mergeWithCLIOptions({
|
|
823
|
+
root: projectRoot,
|
|
824
|
+
...p,
|
|
825
|
+
name: p.name ? p.name : getDefaultProjectName(projectRoot)
|
|
826
|
+
}, options),
|
|
827
|
+
configFilePath: void 0
|
|
828
|
+
});
|
|
829
|
+
return total;
|
|
830
|
+
}
|
|
831
|
+
const projectStr = formatRootStr(p, root);
|
|
832
|
+
if (isDynamicPattern(projectStr)) total.projectPatterns.push(projectStr);
|
|
833
|
+
else {
|
|
834
|
+
const absolutePath = getAbsolutePath(root, projectStr);
|
|
835
|
+
if (!(0, external_node_fs_.existsSync)(absolutePath)) throw `Can't resolve project "${p}", please make sure "${p}" is a existing file or a directory.`;
|
|
836
|
+
total.projectPaths.push(absolutePath);
|
|
837
|
+
}
|
|
824
838
|
return total;
|
|
825
|
-
}
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
const absolutePath = getAbsolutePath(root, projectStr);
|
|
830
|
-
if (!(0, external_node_fs_.existsSync)(absolutePath)) throw `Can't resolve project "${p}", please make sure "${p}" is a existing file or a directory.`;
|
|
831
|
-
total.projectPaths.push(absolutePath);
|
|
832
|
-
}
|
|
833
|
-
return total;
|
|
834
|
-
}, {
|
|
835
|
-
projectPaths: [],
|
|
836
|
-
projectPatterns: [],
|
|
837
|
-
projectConfigs: []
|
|
838
|
-
});
|
|
839
|
-
projectPaths.push(...await globProjects(projectPatterns));
|
|
840
|
-
const projects = await Promise.all(projectPaths.map(async (project)=>{
|
|
841
|
-
const isDirectory = (0, external_node_fs_.statSync)(project).isDirectory();
|
|
842
|
-
const root = isDirectory ? project : dirname(project);
|
|
843
|
-
const { config, configFilePath } = await resolveConfig({
|
|
844
|
-
...options,
|
|
845
|
-
config: isDirectory ? void 0 : project,
|
|
846
|
-
root
|
|
839
|
+
}, {
|
|
840
|
+
projectPaths: [],
|
|
841
|
+
projectPatterns: [],
|
|
842
|
+
projectConfigs: []
|
|
847
843
|
});
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
844
|
+
projectPaths.push(...await globProjects(projectPatterns, root));
|
|
845
|
+
const projects = [];
|
|
846
|
+
await Promise.all(projectPaths.map(async (project)=>{
|
|
847
|
+
const isDirectory = (0, external_node_fs_.statSync)(project).isDirectory();
|
|
848
|
+
const projectRoot = isDirectory ? project : dirname(project);
|
|
849
|
+
const { config, configFilePath } = await resolveConfig({
|
|
850
|
+
...options,
|
|
851
|
+
config: isDirectory ? void 0 : project,
|
|
852
|
+
root: projectRoot
|
|
853
|
+
});
|
|
854
|
+
if (configFilePath) {
|
|
855
|
+
if (resolvedProjectPaths.has(configFilePath)) return;
|
|
856
|
+
resolvedProjectPaths.add(configFilePath);
|
|
857
|
+
}
|
|
858
|
+
config.name ??= getDefaultProjectName(projectRoot);
|
|
859
|
+
if (config.projects?.length) {
|
|
860
|
+
const childProjects = await getProjects(config, projectRoot);
|
|
861
|
+
projects.push(...childProjects);
|
|
862
|
+
} else projects.push({
|
|
863
|
+
config,
|
|
864
|
+
configFilePath
|
|
865
|
+
});
|
|
866
|
+
}));
|
|
867
|
+
return projects.concat(projectConfigs);
|
|
868
|
+
};
|
|
869
|
+
const projects = await getProjects(config, root).then((p)=>filterProjects(p, options));
|
|
855
870
|
if (!projects.length) {
|
|
856
871
|
let errorMsg = `No projects found, please make sure you have at least one valid project.
|
|
857
872
|
${picocolors_default().gray('projects:')} ${JSON.stringify(config.projects, null, 2)}`;
|
|
@@ -1558,10 +1573,9 @@ function getRenderedRowCount(rows, columns) {
|
|
|
1558
1573
|
class StatusRenderer {
|
|
1559
1574
|
rootPath;
|
|
1560
1575
|
renderer;
|
|
1561
|
-
runningModules = new Map();
|
|
1562
|
-
testModules = [];
|
|
1563
1576
|
startTime = void 0;
|
|
1564
|
-
|
|
1577
|
+
testState;
|
|
1578
|
+
constructor(rootPath, state){
|
|
1565
1579
|
this.rootPath = rootPath;
|
|
1566
1580
|
this.renderer = new WindowRenderer({
|
|
1567
1581
|
getWindow: ()=>this.getContent(),
|
|
@@ -1571,13 +1585,16 @@ class StatusRenderer {
|
|
|
1571
1585
|
getColumns: ()=>'columns' in process.stdout ? process.stdout.columns : 80
|
|
1572
1586
|
}
|
|
1573
1587
|
});
|
|
1588
|
+
this.testState = state;
|
|
1574
1589
|
}
|
|
1575
1590
|
getContent() {
|
|
1576
1591
|
this.startTime ??= Date.now();
|
|
1577
1592
|
const now = Date.now();
|
|
1578
1593
|
const summary = [];
|
|
1594
|
+
const runningModules = this.testState.getRunningModules();
|
|
1595
|
+
const testModules = this.testState.getTestModules();
|
|
1579
1596
|
const shouldDisplayRunningTests = (runningTests)=>runningTests[0]?.startTime && now - runningTests[0].startTime > 2000;
|
|
1580
|
-
for (const [module, { runningTests }] of
|
|
1597
|
+
for (const [module, { runningTests }] of runningModules.entries()){
|
|
1581
1598
|
const relativePath = pathe_M_eThtNZ_relative(this.rootPath, module);
|
|
1582
1599
|
summary.push(`${picocolors_default().bgYellow(picocolors_default().bold(' RUNS '))} ${prettyTestPath(relativePath)}`);
|
|
1583
1600
|
if (runningTests.length && shouldDisplayRunningTests(runningTests)) {
|
|
@@ -1587,66 +1604,24 @@ class StatusRenderer {
|
|
|
1587
1604
|
}
|
|
1588
1605
|
}
|
|
1589
1606
|
summary.push('');
|
|
1590
|
-
if (0 ===
|
|
1591
|
-
else summary.push(`${TestFileSummaryLabel} ${getSummaryStatusString(
|
|
1592
|
-
const testResults = Array.from(
|
|
1607
|
+
if (0 === testModules.length) summary.push(`${TestFileSummaryLabel} ${runningModules.size} total`);
|
|
1608
|
+
else summary.push(`${TestFileSummaryLabel} ${getSummaryStatusString(testModules, '', false)} ${picocolors_default().dim('|')} ${runningModules.size + testModules.length} total`);
|
|
1609
|
+
const testResults = Array.from(runningModules.values()).flatMap(({ results })=>results).concat(testModules.flatMap((mod)=>mod.results));
|
|
1593
1610
|
if (testResults.length) summary.push(`${TestSummaryLabel} ${getSummaryStatusString(testResults, '', false)}`);
|
|
1594
1611
|
summary.push(`${DurationLabel} ${prettyTime(Date.now() - this.startTime)}`);
|
|
1595
1612
|
summary.push('');
|
|
1596
1613
|
return summary;
|
|
1597
1614
|
}
|
|
1598
|
-
onTestFileStart(
|
|
1599
|
-
this.runningModules.set(testPath, {
|
|
1600
|
-
runningTests: [],
|
|
1601
|
-
results: []
|
|
1602
|
-
});
|
|
1615
|
+
onTestFileStart() {
|
|
1603
1616
|
this.renderer?.schedule();
|
|
1604
1617
|
}
|
|
1605
|
-
onTestCaseResult(
|
|
1606
|
-
const currentModule = this.runningModules.get(result.testPath);
|
|
1607
|
-
if (currentModule) {
|
|
1608
|
-
const filteredRunningTests = currentModule.runningTests.filter((t)=>t.testId !== result.testId);
|
|
1609
|
-
this.runningModules.set(result.testPath, {
|
|
1610
|
-
runningTests: filteredRunningTests,
|
|
1611
|
-
results: [
|
|
1612
|
-
...currentModule.results,
|
|
1613
|
-
result
|
|
1614
|
-
]
|
|
1615
|
-
});
|
|
1616
|
-
} else this.runningModules.set(result.testPath, {
|
|
1617
|
-
runningTests: [],
|
|
1618
|
-
results: [
|
|
1619
|
-
result
|
|
1620
|
-
]
|
|
1621
|
-
});
|
|
1618
|
+
onTestCaseResult() {
|
|
1622
1619
|
this.renderer?.schedule();
|
|
1623
1620
|
}
|
|
1624
|
-
|
|
1625
|
-
const currentModule = this.runningModules.get(test.testPath);
|
|
1626
|
-
if (currentModule) {
|
|
1627
|
-
const filteredRunningTests = currentModule.runningTests.filter((t)=>t.testId !== test.testId);
|
|
1628
|
-
this.runningModules.set(test.testPath, {
|
|
1629
|
-
runningTests: [
|
|
1630
|
-
...filteredRunningTests,
|
|
1631
|
-
test
|
|
1632
|
-
],
|
|
1633
|
-
results: currentModule.results
|
|
1634
|
-
});
|
|
1635
|
-
} else this.runningModules.set(test.testPath, {
|
|
1636
|
-
runningTests: [
|
|
1637
|
-
test
|
|
1638
|
-
],
|
|
1639
|
-
results: []
|
|
1640
|
-
});
|
|
1641
|
-
}
|
|
1642
|
-
onTestFileResult(test) {
|
|
1643
|
-
this.runningModules.delete(test.testPath);
|
|
1644
|
-
this.testModules.push(test);
|
|
1621
|
+
onTestFileResult() {
|
|
1645
1622
|
this.renderer?.schedule();
|
|
1646
1623
|
}
|
|
1647
1624
|
clear() {
|
|
1648
|
-
this.testModules.length = 0;
|
|
1649
|
-
this.runningModules.clear();
|
|
1650
1625
|
this.startTime = void 0;
|
|
1651
1626
|
this.renderer?.finish();
|
|
1652
1627
|
}
|
|
@@ -1688,17 +1663,17 @@ class DefaultReporter {
|
|
|
1688
1663
|
config;
|
|
1689
1664
|
options = {};
|
|
1690
1665
|
statusRenderer;
|
|
1691
|
-
constructor({ rootPath, options, config }){
|
|
1666
|
+
constructor({ rootPath, options, config, testState }){
|
|
1692
1667
|
this.rootPath = rootPath;
|
|
1693
1668
|
this.config = config;
|
|
1694
1669
|
this.options = options;
|
|
1695
|
-
if (isTTY()) this.statusRenderer = new StatusRenderer(rootPath);
|
|
1670
|
+
if (isTTY()) this.statusRenderer = new StatusRenderer(rootPath, testState);
|
|
1696
1671
|
}
|
|
1697
|
-
onTestFileStart(
|
|
1698
|
-
this.statusRenderer?.onTestFileStart(
|
|
1672
|
+
onTestFileStart() {
|
|
1673
|
+
this.statusRenderer?.onTestFileStart();
|
|
1699
1674
|
}
|
|
1700
1675
|
onTestFileResult(test) {
|
|
1701
|
-
this.statusRenderer?.onTestFileResult(
|
|
1676
|
+
this.statusRenderer?.onTestFileResult();
|
|
1702
1677
|
const relativePath = pathe_M_eThtNZ_relative(this.rootPath, test.testPath);
|
|
1703
1678
|
const { slowTestThreshold } = this.config;
|
|
1704
1679
|
logFileTitle(test, relativePath);
|
|
@@ -1710,11 +1685,8 @@ class DefaultReporter {
|
|
|
1710
1685
|
});
|
|
1711
1686
|
}
|
|
1712
1687
|
}
|
|
1713
|
-
onTestCaseResult(
|
|
1714
|
-
this.statusRenderer?.onTestCaseResult(
|
|
1715
|
-
}
|
|
1716
|
-
onTestCaseStart(test) {
|
|
1717
|
-
this.statusRenderer?.onTestCaseStart(test);
|
|
1688
|
+
onTestCaseResult() {
|
|
1689
|
+
this.statusRenderer?.onTestCaseResult();
|
|
1718
1690
|
}
|
|
1719
1691
|
onUserConsoleLog(log) {
|
|
1720
1692
|
const shouldLog = this.config.onConsoleLog?.(log.content) ?? true;
|
|
@@ -2158,7 +2130,7 @@ async function error_printError(error, getSourcemap, rootPath) {
|
|
|
2158
2130
|
fullStack: error.fullStack,
|
|
2159
2131
|
getSourcemap
|
|
2160
2132
|
});
|
|
2161
|
-
if (!stackFrames.length && error.stack.
|
|
2133
|
+
if (!stackFrames.length && !(error.fullStack || isDebug()) && !error.stack.endsWith(error.message)) src_logger.log(picocolors_default().gray("No error stack found, set 'DEBUG=rstest' to show fullStack."));
|
|
2162
2134
|
if (stackFrames[0]) await printCodeFrame(stackFrames[0]);
|
|
2163
2135
|
printStack(stackFrames, rootPath);
|
|
2164
2136
|
}
|
|
@@ -2343,7 +2315,7 @@ class JUnitReporter {
|
|
|
2343
2315
|
}
|
|
2344
2316
|
class VerboseReporter extends DefaultReporter {
|
|
2345
2317
|
onTestFileResult(test) {
|
|
2346
|
-
this.statusRenderer?.onTestFileResult(
|
|
2318
|
+
this.statusRenderer?.onTestFileResult();
|
|
2347
2319
|
const relativePath = pathe_M_eThtNZ_relative(this.rootPath, test.testPath);
|
|
2348
2320
|
const { slowTestThreshold } = this.config;
|
|
2349
2321
|
logFileTitle(test, relativePath, true);
|
|
@@ -2357,16 +2329,49 @@ class TestStateManager {
|
|
|
2357
2329
|
runningModules = new Map();
|
|
2358
2330
|
testModules = [];
|
|
2359
2331
|
onTestFileStart(testPath) {
|
|
2360
|
-
this.runningModules.set(testPath,
|
|
2332
|
+
this.runningModules.set(testPath, {
|
|
2333
|
+
runningTests: [],
|
|
2334
|
+
results: []
|
|
2335
|
+
});
|
|
2361
2336
|
}
|
|
2362
2337
|
onTestCaseResult(result) {
|
|
2363
|
-
this.runningModules.
|
|
2364
|
-
|
|
2365
|
-
result
|
|
2366
|
-
|
|
2338
|
+
const currentModule = this.runningModules.get(result.testPath);
|
|
2339
|
+
if (currentModule) {
|
|
2340
|
+
const filteredRunningTests = currentModule.runningTests.filter((t)=>t.testId !== result.testId);
|
|
2341
|
+
this.runningModules.set(result.testPath, {
|
|
2342
|
+
runningTests: filteredRunningTests,
|
|
2343
|
+
results: [
|
|
2344
|
+
...currentModule.results,
|
|
2345
|
+
result
|
|
2346
|
+
]
|
|
2347
|
+
});
|
|
2348
|
+
} else this.runningModules.set(result.testPath, {
|
|
2349
|
+
runningTests: [],
|
|
2350
|
+
results: [
|
|
2351
|
+
result
|
|
2352
|
+
]
|
|
2353
|
+
});
|
|
2354
|
+
}
|
|
2355
|
+
onTestCaseStart(test) {
|
|
2356
|
+
const currentModule = this.runningModules.get(test.testPath);
|
|
2357
|
+
if (currentModule) {
|
|
2358
|
+
const filteredRunningTests = currentModule.runningTests.filter((t)=>t.testId !== test.testId);
|
|
2359
|
+
this.runningModules.set(test.testPath, {
|
|
2360
|
+
runningTests: [
|
|
2361
|
+
...filteredRunningTests,
|
|
2362
|
+
test
|
|
2363
|
+
],
|
|
2364
|
+
results: currentModule.results
|
|
2365
|
+
});
|
|
2366
|
+
} else this.runningModules.set(test.testPath, {
|
|
2367
|
+
runningTests: [
|
|
2368
|
+
test
|
|
2369
|
+
],
|
|
2370
|
+
results: []
|
|
2371
|
+
});
|
|
2367
2372
|
}
|
|
2368
2373
|
getCountOfFailedTests() {
|
|
2369
|
-
const testResults = Array.from(this.runningModules.values()).
|
|
2374
|
+
const testResults = Array.from(this.runningModules.values()).flatMap(({ results })=>results).concat(this.testModules.flatMap((mod)=>mod.results));
|
|
2370
2375
|
return testResults.filter((t)=>'fail' === t.status).length;
|
|
2371
2376
|
}
|
|
2372
2377
|
onTestFileResult(test) {
|
|
@@ -2397,6 +2402,10 @@ class Rstest {
|
|
|
2397
2402
|
testResults: []
|
|
2398
2403
|
};
|
|
2399
2404
|
stateManager = new TestStateManager();
|
|
2405
|
+
testState = {
|
|
2406
|
+
getRunningModules: ()=>this.stateManager.runningModules,
|
|
2407
|
+
getTestModules: ()=>this.stateManager.testModules
|
|
2408
|
+
};
|
|
2400
2409
|
projects = [];
|
|
2401
2410
|
constructor({ cwd = process.cwd(), command, fileFilters, configFilePath, projects }, userConfig){
|
|
2402
2411
|
this.cwd = cwd;
|
|
@@ -2410,14 +2419,15 @@ class Rstest {
|
|
|
2410
2419
|
});
|
|
2411
2420
|
const reporters = 'list' !== command ? createReporters(rstestConfig.reporters, {
|
|
2412
2421
|
rootPath,
|
|
2413
|
-
config: rstestConfig
|
|
2422
|
+
config: rstestConfig,
|
|
2423
|
+
testState: this.testState
|
|
2414
2424
|
}) : [];
|
|
2415
2425
|
const snapshotManager = new SnapshotManager({
|
|
2416
2426
|
updateSnapshot: rstestConfig.update ? 'all' : T ? 'none' : 'new'
|
|
2417
2427
|
});
|
|
2418
2428
|
this.reporters = reporters;
|
|
2419
2429
|
this.snapshotManager = snapshotManager;
|
|
2420
|
-
this.version = "0.6.
|
|
2430
|
+
this.version = "0.6.8";
|
|
2421
2431
|
this.rootPath = rootPath;
|
|
2422
2432
|
this.originalConfig = userConfig;
|
|
2423
2433
|
this.normalizedConfig = rstestConfig;
|
package/dist/362.js
CHANGED
|
@@ -4859,7 +4859,7 @@ __webpack_require__.add({
|
|
|
4859
4859
|
var path = __webpack_require__("node:path");
|
|
4860
4860
|
var fs;
|
|
4861
4861
|
try {
|
|
4862
|
-
fs = __webpack_require__("fs");
|
|
4862
|
+
fs = __webpack_require__("node:fs");
|
|
4863
4863
|
if (!fs.existsSync || !fs.readFileSync) fs = null;
|
|
4864
4864
|
} catch (err) {}
|
|
4865
4865
|
var bufferFrom = __webpack_require__("../../node_modules/.pnpm/buffer-from@1.1.2/node_modules/buffer-from/index.js");
|
|
@@ -6849,6 +6849,12 @@ const loadModule = ({ codeContent, distPath, testPath, rstestContext, assetFiles
|
|
|
6849
6849
|
module: localModule,
|
|
6850
6850
|
exports: localModule.exports,
|
|
6851
6851
|
require: createRequire(testPath, distPath, rstestContext, assetFiles, interopDefault),
|
|
6852
|
+
readWasmFile: (wasmPath, callback)=>{
|
|
6853
|
+
const joinedPath = isRelativePath(wasmPath) ? posix.join(posix.dirname(distPath), wasmPath) : wasmPath;
|
|
6854
|
+
const content = assetFiles[posix.normalize(joinedPath)];
|
|
6855
|
+
if (content) callback(null, Buffer.from(content, 'utf-8'));
|
|
6856
|
+
else callback(new Error(`WASM file ${joinedPath} not found in asset files.`));
|
|
6857
|
+
},
|
|
6852
6858
|
__rstest_dynamic_import__: defineRstestDynamicImport({
|
|
6853
6859
|
testPath,
|
|
6854
6860
|
interopDefault
|
|
@@ -6936,7 +6942,7 @@ function createRuntimeRpc(options, { originalConsole }) {
|
|
|
6936
6942
|
rpc
|
|
6937
6943
|
};
|
|
6938
6944
|
}
|
|
6939
|
-
const external_node_fs_ = __webpack_require__("fs");
|
|
6945
|
+
const external_node_fs_ = __webpack_require__("node:fs");
|
|
6940
6946
|
class NodeSnapshotEnvironment {
|
|
6941
6947
|
constructor(options = {}){
|
|
6942
6948
|
this.options = options;
|
package/dist/946.js
CHANGED
|
@@ -1484,7 +1484,7 @@ __webpack_require__.add({
|
|
|
1484
1484
|
return last;
|
|
1485
1485
|
};
|
|
1486
1486
|
},
|
|
1487
|
-
fs: function(module) {
|
|
1487
|
+
"node:fs": function(module) {
|
|
1488
1488
|
module.exports = __WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__;
|
|
1489
1489
|
},
|
|
1490
1490
|
"node:os": function(module) {
|
|
@@ -2338,7 +2338,7 @@ const ADDITIONAL_NODE_BUILTINS = [
|
|
|
2338
2338
|
];
|
|
2339
2339
|
const isTTY = (type = 'stdout')=>('stdin' === type ? process.stdin.isTTY : process.stdout.isTTY) && !process.env.CI;
|
|
2340
2340
|
const external_node_path_ = __webpack_require__("node:path");
|
|
2341
|
-
const external_node_fs_ = __webpack_require__("fs");
|
|
2341
|
+
const external_node_fs_ = __webpack_require__("node:fs");
|
|
2342
2342
|
var __require = /* @__PURE__ */ createRequire(import.meta.url);
|
|
2343
2343
|
function cleanPath(path) {
|
|
2344
2344
|
let normalized = (0, external_node_path_.normalize)(path);
|
|
@@ -337,7 +337,7 @@ declare type CommonOptions = {
|
|
|
337
337
|
maxConcurrency?: number;
|
|
338
338
|
slowTestThreshold?: number;
|
|
339
339
|
hideSkippedTests?: boolean;
|
|
340
|
-
bail?: number;
|
|
340
|
+
bail?: number | boolean;
|
|
341
341
|
};
|
|
342
342
|
|
|
343
343
|
declare type CompareKeys = ((a: string, b: string) => number) | null | undefined;
|
|
@@ -588,15 +588,15 @@ declare class DefaultReporter implements Reporter {
|
|
|
588
588
|
protected config: NormalizedConfig;
|
|
589
589
|
private options;
|
|
590
590
|
protected statusRenderer: StatusRenderer | undefined;
|
|
591
|
-
constructor({ rootPath, options, config, }: {
|
|
591
|
+
constructor({ rootPath, options, config, testState, }: {
|
|
592
592
|
rootPath: string;
|
|
593
593
|
config: NormalizedConfig;
|
|
594
594
|
options: DefaultReporterOptions;
|
|
595
|
+
testState: RstestTestState;
|
|
595
596
|
});
|
|
596
|
-
onTestFileStart(
|
|
597
|
+
onTestFileStart(): void;
|
|
597
598
|
onTestFileResult(test: TestFileResult): void;
|
|
598
|
-
onTestCaseResult(
|
|
599
|
-
onTestCaseStart(test: TestCaseInfo): void;
|
|
599
|
+
onTestCaseResult(): void;
|
|
600
600
|
onUserConsoleLog(log: UserConsoleLog): void;
|
|
601
601
|
onExit(): Promise<void>;
|
|
602
602
|
onTestRunEnd({ results, testResults, duration, getSourcemap, snapshotSummary, filterRerunTestPaths, }: {
|
|
@@ -633,7 +633,7 @@ export declare function defineConfig(config: RstestConfigExport): RstestConfigEx
|
|
|
633
633
|
* This function helps you to autocomplete configuration types.
|
|
634
634
|
* It accepts a Rstest project config object, or a function that returns a config.
|
|
635
635
|
*/
|
|
636
|
-
export declare function defineProject(config: ProjectConfig): ProjectConfig;
|
|
636
|
+
export declare function defineProject(config: ProjectConfig | NestedProjectConfig): ProjectConfig | NestedProjectConfig;
|
|
637
637
|
|
|
638
638
|
export declare function defineProject(config: ProjectConfigSyncFn): ProjectConfigSyncFn;
|
|
639
639
|
|
|
@@ -946,6 +946,18 @@ export declare function initCli(options: CommonOptions): Promise<{
|
|
|
946
946
|
projects: Project[];
|
|
947
947
|
}>;
|
|
948
948
|
|
|
949
|
+
/**
|
|
950
|
+
* A list of glob patterns or files that match your test projects.
|
|
951
|
+
*
|
|
952
|
+
* eg. ['packages/*', 'examples/node/rstest.config.ts']
|
|
953
|
+
*/
|
|
954
|
+
/**
|
|
955
|
+
* Inline project config must include a name.
|
|
956
|
+
*/
|
|
957
|
+
declare type InlineProjectConfig = ProjectConfig & {
|
|
958
|
+
name: string;
|
|
959
|
+
};
|
|
960
|
+
|
|
949
961
|
declare interface InlineSnapshotMatcher<T> {
|
|
950
962
|
<U extends {
|
|
951
963
|
[P in keyof T]: any;
|
|
@@ -1900,6 +1912,10 @@ declare interface MockSettledResultRejected_2 {
|
|
|
1900
1912
|
|
|
1901
1913
|
declare type NamesIndex = number;
|
|
1902
1914
|
|
|
1915
|
+
declare type NestedProjectConfig = {
|
|
1916
|
+
projects: (ProjectConfig | string)[];
|
|
1917
|
+
};
|
|
1918
|
+
|
|
1903
1919
|
declare interface NewPlugin {
|
|
1904
1920
|
serialize: (val: any, config: Config, indentation: string, depth: number, refs: Refs, printer: Printer) => string;
|
|
1905
1921
|
test: Test;
|
|
@@ -2017,9 +2033,9 @@ declare type Project = {
|
|
|
2017
2033
|
|
|
2018
2034
|
export declare type ProjectConfig = Omit<RstestConfig, 'projects' | 'reporters' | 'pool' | 'isolate' | 'coverage' | 'resolveSnapshotPath' | 'onConsoleLog' | 'hideSkippedTests' | 'bail'>;
|
|
2019
2035
|
|
|
2020
|
-
declare type ProjectConfigAsyncFn = () => Promise<ProjectConfig>;
|
|
2036
|
+
declare type ProjectConfigAsyncFn = () => Promise<ProjectConfig | NestedProjectConfig>;
|
|
2021
2037
|
|
|
2022
|
-
declare type ProjectConfigSyncFn = () => ProjectConfig;
|
|
2038
|
+
declare type ProjectConfigSyncFn = () => ProjectConfig | NestedProjectConfig;
|
|
2023
2039
|
|
|
2024
2040
|
declare type ProjectContext = {
|
|
2025
2041
|
name: string;
|
|
@@ -2375,6 +2391,10 @@ declare type RstestContext = {
|
|
|
2375
2391
|
* Run tests from one or more projects.
|
|
2376
2392
|
*/
|
|
2377
2393
|
projects: ProjectContext[];
|
|
2394
|
+
/**
|
|
2395
|
+
* The test state
|
|
2396
|
+
*/
|
|
2397
|
+
testState: RstestTestState;
|
|
2378
2398
|
/**
|
|
2379
2399
|
* The command type.
|
|
2380
2400
|
*
|
|
@@ -2407,6 +2427,11 @@ declare type RstestPoolOptions = {
|
|
|
2407
2427
|
|
|
2408
2428
|
declare type RstestPoolType = 'forks';
|
|
2409
2429
|
|
|
2430
|
+
declare type RstestTestState = {
|
|
2431
|
+
getRunningModules: () => RunningModules;
|
|
2432
|
+
getTestModules: () => TestFileResult[];
|
|
2433
|
+
};
|
|
2434
|
+
|
|
2410
2435
|
export declare interface RstestUtilities {
|
|
2411
2436
|
/**
|
|
2412
2437
|
* Creates a spy on a function.
|
|
@@ -2549,6 +2574,11 @@ declare type RunnerAPI = {
|
|
|
2549
2574
|
onTestFailed: (fn: OnTestFailedHandler, timeout?: number) => void;
|
|
2550
2575
|
};
|
|
2551
2576
|
|
|
2577
|
+
declare type RunningModules = Map<string, {
|
|
2578
|
+
runningTests: TestCaseInfo[];
|
|
2579
|
+
results: TestResult[];
|
|
2580
|
+
}>;
|
|
2581
|
+
|
|
2552
2582
|
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'>;
|
|
2553
2583
|
|
|
2554
2584
|
declare type RuntimeOptions = Partial<Pick<RuntimeConfig, 'testTimeout' | 'hookTimeout' | 'clearMocks' | 'resetMocks' | 'restoreMocks' | 'maxConcurrency' | 'retry'>>;
|
|
@@ -2726,15 +2756,13 @@ declare type SourcesIndex = number;
|
|
|
2726
2756
|
declare class StatusRenderer {
|
|
2727
2757
|
private rootPath;
|
|
2728
2758
|
private renderer;
|
|
2729
|
-
private runningModules;
|
|
2730
|
-
private testModules;
|
|
2731
2759
|
private startTime;
|
|
2732
|
-
|
|
2760
|
+
private testState;
|
|
2761
|
+
constructor(rootPath: string, state: RstestTestState);
|
|
2733
2762
|
getContent(): string[];
|
|
2734
|
-
onTestFileStart(
|
|
2735
|
-
onTestCaseResult(
|
|
2736
|
-
|
|
2737
|
-
onTestFileResult(test: TestFileResult): void;
|
|
2763
|
+
onTestFileStart(): void;
|
|
2764
|
+
onTestCaseResult(): void;
|
|
2765
|
+
onTestFileResult(): void;
|
|
2738
2766
|
clear(): void;
|
|
2739
2767
|
}
|
|
2740
2768
|
|
|
@@ -2829,12 +2857,7 @@ declare type TestForFn<ExtraContext = object> = <T>(cases: readonly T[]) => (des
|
|
|
2829
2857
|
/** The test file original path */
|
|
2830
2858
|
declare type TestPath = string;
|
|
2831
2859
|
|
|
2832
|
-
|
|
2833
|
-
* A list of glob patterns or files that match your test projects.
|
|
2834
|
-
*
|
|
2835
|
-
* eg. ['packages/*', 'examples/node/rstest.config.ts']
|
|
2836
|
-
*/
|
|
2837
|
-
declare type TestProject = string | ProjectConfig;
|
|
2860
|
+
declare type TestProject = string | InlineProjectConfig;
|
|
2838
2861
|
|
|
2839
2862
|
export declare type TestResult = {
|
|
2840
2863
|
testId: string;
|
|
@@ -2852,10 +2875,14 @@ export declare type TestResult = {
|
|
|
2852
2875
|
declare type TestResultStatus = 'skip' | 'pass' | 'fail' | 'todo';
|
|
2853
2876
|
|
|
2854
2877
|
declare class TestStateManager {
|
|
2855
|
-
runningModules: Map<string,
|
|
2878
|
+
runningModules: Map<string, {
|
|
2879
|
+
runningTests: TestCaseInfo[];
|
|
2880
|
+
results: TestResult[];
|
|
2881
|
+
}>;
|
|
2856
2882
|
testModules: TestFileResult[];
|
|
2857
2883
|
onTestFileStart(testPath: string): void;
|
|
2858
2884
|
onTestCaseResult(result: TestResult): void;
|
|
2885
|
+
onTestCaseStart(test: TestCaseInfo): void;
|
|
2859
2886
|
getCountOfFailedTests(): number;
|
|
2860
2887
|
onTestFileResult(test: TestFileResult): void;
|
|
2861
2888
|
reset(): void;
|
|
@@ -494,15 +494,15 @@ declare class DefaultReporter implements Reporter {
|
|
|
494
494
|
protected config: NormalizedConfig;
|
|
495
495
|
private options;
|
|
496
496
|
protected statusRenderer: StatusRenderer | undefined;
|
|
497
|
-
constructor({ rootPath, options, config, }: {
|
|
497
|
+
constructor({ rootPath, options, config, testState, }: {
|
|
498
498
|
rootPath: string;
|
|
499
499
|
config: NormalizedConfig;
|
|
500
500
|
options: DefaultReporterOptions;
|
|
501
|
+
testState: RstestTestState;
|
|
501
502
|
});
|
|
502
|
-
onTestFileStart(
|
|
503
|
+
onTestFileStart(): void;
|
|
503
504
|
onTestFileResult(test: TestFileResult): void;
|
|
504
|
-
onTestCaseResult(
|
|
505
|
-
onTestCaseStart(test: TestCaseInfo): void;
|
|
505
|
+
onTestCaseResult(): void;
|
|
506
506
|
onUserConsoleLog(log: UserConsoleLog): void;
|
|
507
507
|
onExit(): Promise<void>;
|
|
508
508
|
onTestRunEnd({ results, testResults, duration, getSourcemap, snapshotSummary, filterRerunTestPaths, }: {
|
|
@@ -770,6 +770,18 @@ declare interface HtmlSpaOptions extends HtmlOptions {
|
|
|
770
770
|
|
|
771
771
|
declare type Indent = (arg0: string) => string;
|
|
772
772
|
|
|
773
|
+
/**
|
|
774
|
+
* A list of glob patterns or files that match your test projects.
|
|
775
|
+
*
|
|
776
|
+
* eg. ['packages/*', 'examples/node/rstest.config.ts']
|
|
777
|
+
*/
|
|
778
|
+
/**
|
|
779
|
+
* Inline project config must include a name.
|
|
780
|
+
*/
|
|
781
|
+
declare type InlineProjectConfig = ProjectConfig & {
|
|
782
|
+
name: string;
|
|
783
|
+
};
|
|
784
|
+
|
|
773
785
|
declare interface InlineSnapshotMatcher<T> {
|
|
774
786
|
<U extends {
|
|
775
787
|
[P in keyof T]: any;
|
|
@@ -2006,6 +2018,10 @@ declare type RstestContext = {
|
|
|
2006
2018
|
* Run tests from one or more projects.
|
|
2007
2019
|
*/
|
|
2008
2020
|
projects: ProjectContext[];
|
|
2021
|
+
/**
|
|
2022
|
+
* The test state
|
|
2023
|
+
*/
|
|
2024
|
+
testState: RstestTestState;
|
|
2009
2025
|
/**
|
|
2010
2026
|
* The command type.
|
|
2011
2027
|
*
|
|
@@ -2034,6 +2050,11 @@ declare type RstestPoolOptions = {
|
|
|
2034
2050
|
|
|
2035
2051
|
declare type RstestPoolType = 'forks';
|
|
2036
2052
|
|
|
2053
|
+
declare type RstestTestState = {
|
|
2054
|
+
getRunningModules: () => RunningModules;
|
|
2055
|
+
getTestModules: () => TestFileResult[];
|
|
2056
|
+
};
|
|
2057
|
+
|
|
2037
2058
|
declare const runInPool: (options: RunWorkerOptions["options"]) => Promise<{
|
|
2038
2059
|
tests: Test_2[];
|
|
2039
2060
|
testPath: string;
|
|
@@ -2052,6 +2073,11 @@ declare type RunnerAPI = {
|
|
|
2052
2073
|
onTestFailed: (fn: OnTestFailedHandler, timeout?: number) => void;
|
|
2053
2074
|
};
|
|
2054
2075
|
|
|
2076
|
+
declare type RunningModules = Map<string, {
|
|
2077
|
+
runningTests: TestCaseInfo[];
|
|
2078
|
+
results: TestResult[];
|
|
2079
|
+
}>;
|
|
2080
|
+
|
|
2055
2081
|
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'>;
|
|
2056
2082
|
|
|
2057
2083
|
/** Runtime to Server */
|
|
@@ -2257,15 +2283,13 @@ declare type SourcesIndex = number;
|
|
|
2257
2283
|
declare class StatusRenderer {
|
|
2258
2284
|
private rootPath;
|
|
2259
2285
|
private renderer;
|
|
2260
|
-
private runningModules;
|
|
2261
|
-
private testModules;
|
|
2262
2286
|
private startTime;
|
|
2263
|
-
|
|
2287
|
+
private testState;
|
|
2288
|
+
constructor(rootPath: string, state: RstestTestState);
|
|
2264
2289
|
getContent(): string[];
|
|
2265
|
-
onTestFileStart(
|
|
2266
|
-
onTestCaseResult(
|
|
2267
|
-
|
|
2268
|
-
onTestFileResult(test: TestFileResult): void;
|
|
2290
|
+
onTestFileStart(): void;
|
|
2291
|
+
onTestCaseResult(): void;
|
|
2292
|
+
onTestFileResult(): void;
|
|
2269
2293
|
clear(): void;
|
|
2270
2294
|
}
|
|
2271
2295
|
|
|
@@ -2402,12 +2426,7 @@ declare type TestForFn<ExtraContext = object> = <T>(cases: readonly T[]) => (des
|
|
|
2402
2426
|
/** The test file original path */
|
|
2403
2427
|
declare type TestPath = string;
|
|
2404
2428
|
|
|
2405
|
-
|
|
2406
|
-
* A list of glob patterns or files that match your test projects.
|
|
2407
|
-
*
|
|
2408
|
-
* eg. ['packages/*', 'examples/node/rstest.config.ts']
|
|
2409
|
-
*/
|
|
2410
|
-
declare type TestProject = string | ProjectConfig;
|
|
2429
|
+
declare type TestProject = string | InlineProjectConfig;
|
|
2411
2430
|
|
|
2412
2431
|
declare type TestResult = {
|
|
2413
2432
|
testId: string;
|
|
@@ -2427,10 +2446,14 @@ declare type TestResultStatus = 'skip' | 'pass' | 'fail' | 'todo';
|
|
|
2427
2446
|
declare type TestRunMode = 'run' | 'skip' | 'todo' | 'only';
|
|
2428
2447
|
|
|
2429
2448
|
declare class TestStateManager {
|
|
2430
|
-
runningModules: Map<string,
|
|
2449
|
+
runningModules: Map<string, {
|
|
2450
|
+
runningTests: TestCaseInfo[];
|
|
2451
|
+
results: TestResult[];
|
|
2452
|
+
}>;
|
|
2431
2453
|
testModules: TestFileResult[];
|
|
2432
2454
|
onTestFileStart(testPath: string): void;
|
|
2433
2455
|
onTestCaseResult(result: TestResult): void;
|
|
2456
|
+
onTestCaseStart(test: TestCaseInfo): void;
|
|
2434
2457
|
getCountOfFailedTests(): number;
|
|
2435
2458
|
onTestFileResult(test: TestFileResult): void;
|
|
2436
2459
|
reset(): void;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rstest/core",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.8",
|
|
4
4
|
"description": "The Rsbuild-based test tool.",
|
|
5
5
|
"bugs": {
|
|
6
6
|
"url": "https://github.com/web-infra-dev/rstest/issues"
|
|
@@ -19,13 +19,13 @@
|
|
|
19
19
|
"license": "MIT",
|
|
20
20
|
"type": "module",
|
|
21
21
|
"main": "./dist/index.js",
|
|
22
|
-
"types": "./dist
|
|
22
|
+
"types": "./dist/index.d.ts",
|
|
23
23
|
"bin": {
|
|
24
24
|
"rstest": "./bin/rstest.js"
|
|
25
25
|
},
|
|
26
26
|
"exports": {
|
|
27
27
|
".": {
|
|
28
|
-
"types": "./dist
|
|
28
|
+
"types": "./dist/index.d.ts",
|
|
29
29
|
"default": "./dist/index.js"
|
|
30
30
|
},
|
|
31
31
|
"./package.json": {
|
|
@@ -41,7 +41,6 @@
|
|
|
41
41
|
"files": [
|
|
42
42
|
"bin",
|
|
43
43
|
"dist",
|
|
44
|
-
"dist-types",
|
|
45
44
|
"compiled",
|
|
46
45
|
"globals.d.ts",
|
|
47
46
|
"importMeta.d.ts"
|