@rstest/core 0.9.5 → 0.9.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.md +80 -0
- package/dist/0~8843.js +15 -1
- package/dist/{0~lib.js → 0~@babel/code-frame.js} +2 -2
- package/dist/0~@clack/prompts.js +1044 -0
- package/dist/0~browserLoader.js +1 -1
- package/dist/0~browser~1.js +17 -17
- package/dist/0~checkThresholds.js +1 -1
- package/dist/0~chokidar.js +43 -42
- package/dist/0~fake-timers.js +381 -228
- package/dist/0~generate.js +1 -2
- package/dist/0~listTests.js +67 -7
- package/dist/0~magic-string.es.js +1 -181
- package/dist/0~restart.js +1 -1
- package/dist/0~snapshot.js +1 -1
- package/dist/1255.js +11 -11
- package/dist/3145.js +275 -25
- package/dist/4411.js +127 -139
- package/dist/6830.js +1 -1
- package/dist/7290.js +15 -0
- package/dist/9743.js +1 -1
- package/dist/9784.js +1 -1
- package/dist/browser-runtime/2~fake-timers.js +389 -403
- package/dist/browser-runtime/2~magic-string.es.js +5 -191
- package/dist/browser-runtime/2~snapshot.js +2 -2
- package/dist/browser-runtime/723.js +77 -15
- package/dist/browser-runtime/index.d.ts +32 -62
- package/dist/browser.d.ts +32 -62
- package/dist/globalSetupWorker.js +1 -1
- package/dist/index.d.ts +56 -68
- package/dist/index.js +1 -1
- package/dist/worker.d.ts +18 -6
- package/dist/worker.js +1 -1
- package/globals.d.ts +1 -0
- package/package.json +13 -14
- package/dist/0~dist.js +0 -1014
- package/dist/4899.js +0 -11
- package/dist/browser-runtime/rslib-runtime.js +0 -49
- /package/dist/{rslib-runtime.js → 0~rslib-runtime.js} +0 -0
package/dist/3145.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import "node:module";
|
|
2
|
-
import { __webpack_require__ } from "./rslib-runtime.js";
|
|
3
2
|
import node_fs, { existsSync, mkdirSync, readFileSync, statSync, writeFileSync } from "node:fs";
|
|
4
3
|
import { loadConfig, mergeRsbuildConfig } from "@rsbuild/core";
|
|
5
4
|
import { stripVTControlCharacters } from "node:util";
|
|
@@ -7,6 +6,7 @@ import promises from "node:fs/promises";
|
|
|
7
6
|
import node_path, { dirname as external_node_path_dirname, resolve as external_node_path_resolve } from "node:path";
|
|
8
7
|
import { createRequire } from "node:module";
|
|
9
8
|
import node_process from "node:process";
|
|
9
|
+
import { __webpack_require__ } from "./0~rslib-runtime.js";
|
|
10
10
|
import { POINTER, DEFAULT_CONFIG_NAME, globalApis, resolve as pathe_M_eThtNZ_resolve, relative, join, logger as logger_logger, prettyTime, getTempRstestOutputDirGlob, color as logger_color, isAbsolute, getOutputDistPathRoot, TEMP_RSTEST_OUTPUT_DIR, TS_CONFIG_FILE, basename, isTTY, dirname as pathe_M_eThtNZ_dirname, TEST_DELIMITER, getAbsolutePath, bgColor, formatRootStr, determineAgent, castArray, dist_m, getTaskNameWithPrefix, isDebug, formatError, normalize, DEFAULT_CONFIG_EXTENSIONS } from "./6830.js";
|
|
11
11
|
import { isDynamicPattern, glob, filterProjects, prettyTestPath, formatTestPath } from "./4411.js";
|
|
12
12
|
import { posix } from "./7011.js";
|
|
@@ -588,7 +588,7 @@ function prepareCli() {
|
|
|
588
588
|
if (!npm_execpath || npm_execpath.includes('npx-cli.js') || npm_execpath.includes('.bun')) logger_logger.log();
|
|
589
589
|
}
|
|
590
590
|
function showRstest() {
|
|
591
|
-
logger_logger.greet(" Rstest v0.9.
|
|
591
|
+
logger_logger.greet(" Rstest v0.9.7");
|
|
592
592
|
logger_logger.log('');
|
|
593
593
|
}
|
|
594
594
|
const runtimeOptionDefinitions = [
|
|
@@ -821,6 +821,10 @@ const listCommandOptionDefinitions = [
|
|
|
821
821
|
[
|
|
822
822
|
'--printLocation',
|
|
823
823
|
'print test case location'
|
|
824
|
+
],
|
|
825
|
+
[
|
|
826
|
+
'--summary',
|
|
827
|
+
'print a summary after the list'
|
|
824
828
|
]
|
|
825
829
|
];
|
|
826
830
|
const applyOptions = (command, definitions)=>{
|
|
@@ -856,6 +860,7 @@ const resolveCliRuntime = async (options)=>{
|
|
|
856
860
|
createRstest
|
|
857
861
|
};
|
|
858
862
|
};
|
|
863
|
+
const normalizeCliFilters = (filters)=>filters.map((filter)=>normalize(String(filter)));
|
|
859
864
|
const runRest = async ({ options, filters, command })=>{
|
|
860
865
|
let rstest;
|
|
861
866
|
const unexpectedlyExitHandler = (err)=>{
|
|
@@ -867,7 +872,7 @@ const runRest = async ({ options, filters, command })=>{
|
|
|
867
872
|
config,
|
|
868
873
|
configFilePath,
|
|
869
874
|
projects
|
|
870
|
-
}, command, filters
|
|
875
|
+
}, command, normalizeCliFilters(filters));
|
|
871
876
|
process.on('uncaughtException', unexpectedlyExitHandler);
|
|
872
877
|
process.on('unhandledRejection', unexpectedlyExitHandler);
|
|
873
878
|
if ('watch' === command) {
|
|
@@ -900,7 +905,7 @@ function createCli() {
|
|
|
900
905
|
return sections;
|
|
901
906
|
}
|
|
902
907
|
});
|
|
903
|
-
cli.version("0.9.
|
|
908
|
+
cli.version("0.9.7");
|
|
904
909
|
const defaultCommand = cli.command('[...filters]', 'run tests').option('-w, --watch', 'Run tests in watch mode');
|
|
905
910
|
applyRuntimeCommandOptions(defaultCommand);
|
|
906
911
|
defaultCommand.action(async (filters, options)=>{
|
|
@@ -947,12 +952,13 @@ function createCli() {
|
|
|
947
952
|
config,
|
|
948
953
|
configFilePath,
|
|
949
954
|
projects
|
|
950
|
-
}, 'list', filters
|
|
955
|
+
}, 'list', normalizeCliFilters(filters));
|
|
951
956
|
await rstest.listTests({
|
|
952
957
|
filesOnly: options.filesOnly,
|
|
953
958
|
json: options.json,
|
|
954
959
|
includeSuites: options.includeSuites,
|
|
955
|
-
printLocation: options.printLocation
|
|
960
|
+
printLocation: options.printLocation,
|
|
961
|
+
summary: options.summary
|
|
956
962
|
});
|
|
957
963
|
} catch (err) {
|
|
958
964
|
logger_logger.error('Failed to run Rstest list.');
|
|
@@ -986,7 +992,7 @@ function createCli() {
|
|
|
986
992
|
try {
|
|
987
993
|
let selectedProject = project;
|
|
988
994
|
if (!selectedProject) {
|
|
989
|
-
const { select, isCancel } = await import("./0
|
|
995
|
+
const { select, isCancel } = await import("./0~@clack/prompts.js");
|
|
990
996
|
console.log();
|
|
991
997
|
const selected = await select({
|
|
992
998
|
message: 'What would you like to initialize?',
|
|
@@ -1516,6 +1522,77 @@ function addSnapshotResult(summary, result) {
|
|
|
1516
1522
|
summary.updated += result.updated;
|
|
1517
1523
|
summary.total += result.added + result.matched + result.unmatched + result.updated;
|
|
1518
1524
|
}
|
|
1525
|
+
const REPORT_INTERVAL_MS = 30000;
|
|
1526
|
+
const SLOW_CASE_THRESHOLD_MS = 10000;
|
|
1527
|
+
const MAX_REPORT_COUNT = 20;
|
|
1528
|
+
class NonTTYProgressNotifier {
|
|
1529
|
+
rootPath;
|
|
1530
|
+
testState;
|
|
1531
|
+
reportTimeout;
|
|
1532
|
+
startTime;
|
|
1533
|
+
started = false;
|
|
1534
|
+
reportCount = 0;
|
|
1535
|
+
constructor(rootPath, testState){
|
|
1536
|
+
this.rootPath = rootPath;
|
|
1537
|
+
this.testState = testState;
|
|
1538
|
+
}
|
|
1539
|
+
start() {
|
|
1540
|
+
if (this.started) return;
|
|
1541
|
+
this.started = true;
|
|
1542
|
+
this.startTime ??= Date.now();
|
|
1543
|
+
this.scheduleReport();
|
|
1544
|
+
}
|
|
1545
|
+
notifyOutput() {
|
|
1546
|
+
if (this.started) this.scheduleReport();
|
|
1547
|
+
}
|
|
1548
|
+
stop() {
|
|
1549
|
+
this.started = false;
|
|
1550
|
+
if (this.reportTimeout) {
|
|
1551
|
+
clearTimeout(this.reportTimeout);
|
|
1552
|
+
this.reportTimeout = void 0;
|
|
1553
|
+
}
|
|
1554
|
+
}
|
|
1555
|
+
scheduleReport() {
|
|
1556
|
+
if (this.reportTimeout) clearTimeout(this.reportTimeout);
|
|
1557
|
+
this.reportTimeout = setTimeout(()=>{
|
|
1558
|
+
this.report();
|
|
1559
|
+
this.reportCount++;
|
|
1560
|
+
if (this.reportCount < MAX_REPORT_COUNT) this.scheduleReport();
|
|
1561
|
+
}, REPORT_INTERVAL_MS);
|
|
1562
|
+
this.reportTimeout.unref();
|
|
1563
|
+
}
|
|
1564
|
+
report() {
|
|
1565
|
+
const runningModules = this.testState.getRunningModules();
|
|
1566
|
+
const testModules = this.testState.getTestModules();
|
|
1567
|
+
const doneFiles = testModules.length;
|
|
1568
|
+
const allResults = testModules.flatMap((mod)=>mod.results).concat(Array.from(runningModules.values()).flatMap(({ results })=>results));
|
|
1569
|
+
const passed = allResults.filter((r)=>'pass' === r.status).length;
|
|
1570
|
+
const failed = allResults.filter((r)=>'fail' === r.status).length;
|
|
1571
|
+
const elapsed = prettyTime(Date.now() - this.startTime);
|
|
1572
|
+
const filePart = `test files: ${doneFiles} done${runningModules.size ? `, ${runningModules.size} running` : ''}`;
|
|
1573
|
+
const testParts = [
|
|
1574
|
+
passed ? `${passed} passed` : null,
|
|
1575
|
+
failed ? `${failed} failed` : null
|
|
1576
|
+
].filter(Boolean);
|
|
1577
|
+
const parts = [
|
|
1578
|
+
filePart,
|
|
1579
|
+
testParts.length ? `tests: ${testParts.join(', ')}` : null,
|
|
1580
|
+
elapsed
|
|
1581
|
+
].filter(Boolean);
|
|
1582
|
+
console.log(`[PROGRESS] ${parts.join(' | ')}`);
|
|
1583
|
+
if (runningModules.size > 0) {
|
|
1584
|
+
const now = Date.now();
|
|
1585
|
+
for (const [module, { runningTests }] of runningModules.entries()){
|
|
1586
|
+
const relativePath = relative(this.rootPath, module);
|
|
1587
|
+
const slowCases = runningTests.filter((t)=>t.startTime && now - t.startTime > SLOW_CASE_THRESHOLD_MS);
|
|
1588
|
+
if (slowCases.length > 0) {
|
|
1589
|
+
const caseNames = slowCases.map((t)=>`${getTaskNameWithPrefix(t)} ${prettyTime(now - t.startTime)}`).join(', ');
|
|
1590
|
+
console.log(` Running: ${relativePath} > ${caseNames}`);
|
|
1591
|
+
} else console.log(` Running: ${relativePath}`);
|
|
1592
|
+
}
|
|
1593
|
+
}
|
|
1594
|
+
}
|
|
1595
|
+
}
|
|
1519
1596
|
const getSummaryStatusString = (tasks, name = 'tests', showTotal = true)=>{
|
|
1520
1597
|
if (0 === tasks.length) return logger_color.dim(`no ${name}`);
|
|
1521
1598
|
const passed = tasks.filter((result)=>'pass' === result.status);
|
|
@@ -1808,12 +1885,28 @@ const logFileTitle = (test, relativePath, alwaysShowTime = false, showProjectNam
|
|
|
1808
1885
|
if (test.heap) title += ` ${logger_color.magenta(formatHeapUsed(test.heap))}`;
|
|
1809
1886
|
logger_logger.log(title);
|
|
1810
1887
|
};
|
|
1888
|
+
const logUserConsoleLog = (rootPath, log)=>{
|
|
1889
|
+
const titles = [];
|
|
1890
|
+
const testPath = relative(rootPath, log.testPath);
|
|
1891
|
+
if (log.trace) {
|
|
1892
|
+
const [frame] = stack_trace_parser_esm_parse(log.trace);
|
|
1893
|
+
const filePath = relative(rootPath, frame.file || '');
|
|
1894
|
+
if (filePath !== testPath) titles.push(testPath);
|
|
1895
|
+
titles.push(`${filePath}:${frame.lineNumber}:${frame.column}`);
|
|
1896
|
+
} else titles.push(testPath);
|
|
1897
|
+
const logOutput = 'stdout' === log.type ? logger_logger.log : logger_logger.stderr;
|
|
1898
|
+
logOutput('');
|
|
1899
|
+
logOutput(`${log.name}${logger_color.gray(logger_color.dim(` | ${titles.join(logger_color.gray(logger_color.dim(' | ')))}`))}`);
|
|
1900
|
+
logOutput(log.content);
|
|
1901
|
+
logOutput('');
|
|
1902
|
+
};
|
|
1811
1903
|
class DefaultReporter {
|
|
1812
1904
|
rootPath;
|
|
1813
1905
|
config;
|
|
1814
1906
|
projectConfigs;
|
|
1815
1907
|
options = {};
|
|
1816
1908
|
statusRenderer;
|
|
1909
|
+
nonTTYProgressNotifier;
|
|
1817
1910
|
testState;
|
|
1818
1911
|
constructor({ rootPath, options, config, testState, projectConfigs }){
|
|
1819
1912
|
this.rootPath = rootPath;
|
|
@@ -1822,12 +1915,15 @@ class DefaultReporter {
|
|
|
1822
1915
|
this.options = options;
|
|
1823
1916
|
this.testState = testState;
|
|
1824
1917
|
if (isTTY() || options.logger) this.statusRenderer = new StatusRenderer(rootPath, testState, options.logger);
|
|
1918
|
+
else this.nonTTYProgressNotifier = new NonTTYProgressNotifier(rootPath, testState);
|
|
1825
1919
|
}
|
|
1826
1920
|
onTestFileStart() {
|
|
1827
1921
|
this.statusRenderer?.onTestFileStart();
|
|
1922
|
+
this.nonTTYProgressNotifier?.start();
|
|
1828
1923
|
}
|
|
1829
1924
|
onTestFileResult(test) {
|
|
1830
1925
|
this.statusRenderer?.onTestFileResult();
|
|
1926
|
+
this.nonTTYProgressNotifier?.notifyOutput();
|
|
1831
1927
|
const projectConfig = this.projectConfigs.get(test.project);
|
|
1832
1928
|
const hideSkippedTestFiles = projectConfig?.hideSkippedTestFiles ?? this.config.hideSkippedTestFiles;
|
|
1833
1929
|
if (hideSkippedTestFiles && 'skip' === test.status) return;
|
|
@@ -1850,25 +1946,16 @@ class DefaultReporter {
|
|
|
1850
1946
|
onUserConsoleLog(log) {
|
|
1851
1947
|
const shouldLog = this.config.onConsoleLog?.(log.content) ?? true;
|
|
1852
1948
|
if (!shouldLog) return;
|
|
1853
|
-
|
|
1854
|
-
|
|
1855
|
-
if (log.trace) {
|
|
1856
|
-
const [frame] = stack_trace_parser_esm_parse(log.trace);
|
|
1857
|
-
const filePath = relative(this.rootPath, frame.file || '');
|
|
1858
|
-
if (filePath !== testPath) titles.push(testPath);
|
|
1859
|
-
titles.push(`${filePath}:${frame.lineNumber}:${frame.column}`);
|
|
1860
|
-
} else titles.push(testPath);
|
|
1861
|
-
const logOutput = 'stdout' === log.type ? logger_logger.log : logger_logger.stderr;
|
|
1862
|
-
logOutput('');
|
|
1863
|
-
logOutput(`${log.name}${logger_color.gray(logger_color.dim(` | ${titles.join(logger_color.gray(logger_color.dim(' | ')))}`))}`);
|
|
1864
|
-
logOutput(log.content);
|
|
1865
|
-
logOutput('');
|
|
1949
|
+
this.nonTTYProgressNotifier?.notifyOutput();
|
|
1950
|
+
logUserConsoleLog(this.rootPath, log);
|
|
1866
1951
|
}
|
|
1867
1952
|
onExit() {
|
|
1868
1953
|
this.statusRenderer?.clear();
|
|
1954
|
+
this.nonTTYProgressNotifier?.stop();
|
|
1869
1955
|
}
|
|
1870
1956
|
async onTestRunEnd({ results, testResults, duration, getSourcemap, snapshotSummary, filterRerunTestPaths, unhandledErrors }) {
|
|
1871
1957
|
this.statusRenderer?.clear();
|
|
1958
|
+
this.nonTTYProgressNotifier?.stop();
|
|
1872
1959
|
if (false === this.options.summary) return;
|
|
1873
1960
|
await printSummaryErrorLogs({
|
|
1874
1961
|
testResults,
|
|
@@ -1903,7 +1990,7 @@ class BlobReporter {
|
|
|
1903
1990
|
const shard = this.config.shard;
|
|
1904
1991
|
const fileName = shard ? `blob-${shard.index}-${shard.count}.json` : 'blob.json';
|
|
1905
1992
|
const blobData = {
|
|
1906
|
-
version: "0.9.
|
|
1993
|
+
version: "0.9.7",
|
|
1907
1994
|
shard: shard ? {
|
|
1908
1995
|
index: shard.index,
|
|
1909
1996
|
count: shard.count
|
|
@@ -1925,6 +2012,74 @@ class BlobReporter {
|
|
|
1925
2012
|
writeFileSync(join(this.outputDir, fileName), JSON.stringify(blobData), 'utf-8');
|
|
1926
2013
|
}
|
|
1927
2014
|
}
|
|
2015
|
+
const DOT_BY_STATUS = {
|
|
2016
|
+
fail: 'x',
|
|
2017
|
+
pass: '·',
|
|
2018
|
+
skip: '-',
|
|
2019
|
+
todo: '*'
|
|
2020
|
+
};
|
|
2021
|
+
const COLOR_BY_STATUS = {
|
|
2022
|
+
fail: logger_color.red,
|
|
2023
|
+
pass: logger_color.green,
|
|
2024
|
+
skip: logger_color.yellow,
|
|
2025
|
+
todo: logger_color.gray
|
|
2026
|
+
};
|
|
2027
|
+
class DotReporter {
|
|
2028
|
+
rootPath;
|
|
2029
|
+
options;
|
|
2030
|
+
outputStream;
|
|
2031
|
+
getColumns;
|
|
2032
|
+
currentColumn = 0;
|
|
2033
|
+
constructor({ rootPath, options = {} }){
|
|
2034
|
+
this.rootPath = rootPath;
|
|
2035
|
+
this.options = options;
|
|
2036
|
+
this.outputStream = options.logger?.outputStream ?? process.stdout;
|
|
2037
|
+
this.getColumns = options.logger?.getColumns ?? (()=>'columns' in process.stdout ? process.stdout.columns || 80 : 80);
|
|
2038
|
+
}
|
|
2039
|
+
onTestCaseResult(result) {
|
|
2040
|
+
const marker = COLOR_BY_STATUS[result.status](DOT_BY_STATUS[result.status]);
|
|
2041
|
+
this.outputStream.write(marker);
|
|
2042
|
+
this.currentColumn += 1;
|
|
2043
|
+
if (this.currentColumn >= this.getColumnWidth()) {
|
|
2044
|
+
this.outputStream.write('\n');
|
|
2045
|
+
this.currentColumn = 0;
|
|
2046
|
+
}
|
|
2047
|
+
}
|
|
2048
|
+
onUserConsoleLog(log) {
|
|
2049
|
+
this.flushLine();
|
|
2050
|
+
logUserConsoleLog(this.rootPath, log);
|
|
2051
|
+
}
|
|
2052
|
+
onExit() {
|
|
2053
|
+
this.flushLine();
|
|
2054
|
+
}
|
|
2055
|
+
async onTestRunEnd({ results, testResults, duration, getSourcemap, snapshotSummary, filterRerunTestPaths, unhandledErrors }) {
|
|
2056
|
+
this.flushLine();
|
|
2057
|
+
if (false === this.options.summary) return;
|
|
2058
|
+
await printSummaryErrorLogs({
|
|
2059
|
+
testResults,
|
|
2060
|
+
results,
|
|
2061
|
+
unhandledErrors,
|
|
2062
|
+
rootPath: this.rootPath,
|
|
2063
|
+
getSourcemap,
|
|
2064
|
+
filterRerunTestPaths
|
|
2065
|
+
});
|
|
2066
|
+
printSummaryLog({
|
|
2067
|
+
results,
|
|
2068
|
+
testResults,
|
|
2069
|
+
duration,
|
|
2070
|
+
rootPath: this.rootPath,
|
|
2071
|
+
snapshotSummary
|
|
2072
|
+
});
|
|
2073
|
+
}
|
|
2074
|
+
flushLine() {
|
|
2075
|
+
if (0 === this.currentColumn) return;
|
|
2076
|
+
this.outputStream.write('\n');
|
|
2077
|
+
this.currentColumn = 0;
|
|
2078
|
+
}
|
|
2079
|
+
getColumnWidth() {
|
|
2080
|
+
return Math.max(1, this.getColumns() || 80);
|
|
2081
|
+
}
|
|
2082
|
+
}
|
|
1928
2083
|
class GithubActionsReporter {
|
|
1929
2084
|
onWritePath;
|
|
1930
2085
|
rootPath;
|
|
@@ -1977,6 +2132,95 @@ class GithubActionsReporter {
|
|
|
1977
2132
|
function escapeData(s) {
|
|
1978
2133
|
return s.replace(/%/g, '%25').replace(/\r/g, '%0D').replace(/\n/g, '%0A').replace(/:/g, '%3A').replace(/,/g, '%2C');
|
|
1979
2134
|
}
|
|
2135
|
+
class JsonReporter {
|
|
2136
|
+
config;
|
|
2137
|
+
rootPath;
|
|
2138
|
+
outputPath;
|
|
2139
|
+
consoleLogs = [];
|
|
2140
|
+
constructor({ config, rootPath, options }){
|
|
2141
|
+
this.config = config;
|
|
2142
|
+
this.rootPath = rootPath;
|
|
2143
|
+
this.outputPath = options?.outputPath;
|
|
2144
|
+
}
|
|
2145
|
+
onUserConsoleLog(log) {
|
|
2146
|
+
this.consoleLogs.push(log);
|
|
2147
|
+
}
|
|
2148
|
+
normalizeTest(test) {
|
|
2149
|
+
return {
|
|
2150
|
+
...test,
|
|
2151
|
+
testPath: relative(this.rootPath, test.testPath),
|
|
2152
|
+
fullName: getTaskNameWithPrefix(test)
|
|
2153
|
+
};
|
|
2154
|
+
}
|
|
2155
|
+
createReport({ results, testResults, duration, snapshotSummary, unhandledErrors }) {
|
|
2156
|
+
const failedTests = testResults.filter((result)=>'fail' === result.status);
|
|
2157
|
+
const passedTests = testResults.filter((result)=>'pass' === result.status);
|
|
2158
|
+
const skippedTests = testResults.filter((result)=>'skip' === result.status);
|
|
2159
|
+
const todoTests = testResults.filter((result)=>'todo' === result.status);
|
|
2160
|
+
const failedFiles = results.filter((result)=>'fail' === result.status);
|
|
2161
|
+
const noTestsDiscovered = 0 === results.length && 0 === testResults.length;
|
|
2162
|
+
const hasFailedStatus = failedTests.length > 0 || failedFiles.length > 0 || (unhandledErrors?.length ?? 0) > 0 || noTestsDiscovered && !this.config.passWithNoTests;
|
|
2163
|
+
return {
|
|
2164
|
+
tool: 'rstest',
|
|
2165
|
+
version: "0.9.7",
|
|
2166
|
+
status: hasFailedStatus ? 'fail' : 'pass',
|
|
2167
|
+
summary: {
|
|
2168
|
+
testFiles: results.length,
|
|
2169
|
+
failedFiles: failedFiles.length,
|
|
2170
|
+
tests: testResults.length,
|
|
2171
|
+
failedTests: failedTests.length,
|
|
2172
|
+
passedTests: passedTests.length,
|
|
2173
|
+
skippedTests: skippedTests.length,
|
|
2174
|
+
todoTests: todoTests.length
|
|
2175
|
+
},
|
|
2176
|
+
durationMs: {
|
|
2177
|
+
total: duration.totalTime,
|
|
2178
|
+
build: duration.buildTime,
|
|
2179
|
+
tests: duration.testTime
|
|
2180
|
+
},
|
|
2181
|
+
snapshot: snapshotSummary,
|
|
2182
|
+
files: results.map((fileResult)=>({
|
|
2183
|
+
...fileResult,
|
|
2184
|
+
testPath: relative(this.rootPath, fileResult.testPath),
|
|
2185
|
+
fullName: getTaskNameWithPrefix(fileResult),
|
|
2186
|
+
results: fileResult.results.map((test)=>this.normalizeTest(test))
|
|
2187
|
+
})),
|
|
2188
|
+
tests: testResults.map((test)=>this.normalizeTest(test)),
|
|
2189
|
+
consoleLogs: this.consoleLogs.length > 0 ? this.consoleLogs.map((log)=>({
|
|
2190
|
+
...log,
|
|
2191
|
+
testPath: relative(this.rootPath, log.testPath)
|
|
2192
|
+
})) : void 0,
|
|
2193
|
+
unhandledErrors: unhandledErrors?.map((error)=>({
|
|
2194
|
+
message: error.message,
|
|
2195
|
+
stack: error.stack,
|
|
2196
|
+
name: error.name
|
|
2197
|
+
}))
|
|
2198
|
+
};
|
|
2199
|
+
}
|
|
2200
|
+
async writeReport(content) {
|
|
2201
|
+
if (!this.outputPath) return void logger_logger.log(content);
|
|
2202
|
+
try {
|
|
2203
|
+
await promises.mkdir(node_path.dirname(this.outputPath), {
|
|
2204
|
+
recursive: true
|
|
2205
|
+
});
|
|
2206
|
+
await promises.writeFile(this.outputPath, content, 'utf-8');
|
|
2207
|
+
logger_logger.log(`JSON report written to: ${this.outputPath}`);
|
|
2208
|
+
} catch (error) {
|
|
2209
|
+
logger_logger.stderr(`Failed to write JSON report to ${this.outputPath}:`, error);
|
|
2210
|
+
logger_logger.log(content);
|
|
2211
|
+
}
|
|
2212
|
+
}
|
|
2213
|
+
async onTestRunEnd({ results, testResults, duration, snapshotSummary, unhandledErrors }) {
|
|
2214
|
+
const report = this.createReport({
|
|
2215
|
+
results,
|
|
2216
|
+
testResults,
|
|
2217
|
+
duration,
|
|
2218
|
+
snapshotSummary,
|
|
2219
|
+
unhandledErrors
|
|
2220
|
+
});
|
|
2221
|
+
await this.writeReport(`${JSON.stringify(report, null, 2)}\n`);
|
|
2222
|
+
}
|
|
2223
|
+
}
|
|
1980
2224
|
function ansiRegex({ onlyFirst = false } = {}) {
|
|
1981
2225
|
const ST = '(?:\\u0007|\\u001B\\u005C|\\u009C)';
|
|
1982
2226
|
const osc = `(?:\\u001B\\][\\s\\S]*?${ST})`;
|
|
@@ -2339,7 +2583,7 @@ async function printCodeFrame(frame) {
|
|
|
2339
2583
|
if (!filePath) return;
|
|
2340
2584
|
const source = node_fs.existsSync(filePath) ? node_fs.readFileSync(filePath, 'utf-8') : void 0;
|
|
2341
2585
|
if (!source) return;
|
|
2342
|
-
const { codeFrameColumns } = await import("./0
|
|
2586
|
+
const { codeFrameColumns } = await import("./0~@babel/code-frame.js").then(__webpack_require__.bind(__webpack_require__, "../../node_modules/.pnpm/@babel+code-frame@7.29.0/node_modules/@babel/code-frame/lib/index.js"));
|
|
2343
2587
|
const result = codeFrameColumns(source, {
|
|
2344
2588
|
start: {
|
|
2345
2589
|
line: frame.lineNumber,
|
|
@@ -3571,7 +3815,7 @@ class MdReporter {
|
|
|
3571
3815
|
}
|
|
3572
3816
|
renderFrontMatter(lines) {
|
|
3573
3817
|
const frontMatter = {
|
|
3574
|
-
tool: "@rstest/core@0.9.
|
|
3818
|
+
tool: "@rstest/core@0.9.7",
|
|
3575
3819
|
timestamp: new Date().toISOString()
|
|
3576
3820
|
};
|
|
3577
3821
|
if (this.options.header.env) frontMatter.runtime = {
|
|
@@ -3822,6 +4066,7 @@ class VerboseReporter extends DefaultReporter {
|
|
|
3822
4066
|
}
|
|
3823
4067
|
onTestFileResult(test) {
|
|
3824
4068
|
this.statusRenderer?.onTestFileResult();
|
|
4069
|
+
this.nonTTYProgressNotifier?.notifyOutput();
|
|
3825
4070
|
const projectConfig = this.projectConfigs.get(test.project);
|
|
3826
4071
|
const hideSkippedTestFiles = projectConfig?.hideSkippedTestFiles ?? this.config.hideSkippedTestFiles;
|
|
3827
4072
|
if (hideSkippedTestFiles && 'skip' === test.status) return;
|
|
@@ -3945,7 +4190,7 @@ class Rstest {
|
|
|
3945
4190
|
updateSnapshot: rstestConfig.update ? 'all' : dist_m ? 'none' : 'new'
|
|
3946
4191
|
});
|
|
3947
4192
|
this.snapshotManager = snapshotManager;
|
|
3948
|
-
this.version = "0.9.
|
|
4193
|
+
this.version = "0.9.7";
|
|
3949
4194
|
this.rootPath = rootPath;
|
|
3950
4195
|
this.originalConfig = userConfig;
|
|
3951
4196
|
this.normalizedConfig = rstestConfig;
|
|
@@ -4022,9 +4267,11 @@ class Rstest {
|
|
|
4022
4267
|
}
|
|
4023
4268
|
const reportersMap = {
|
|
4024
4269
|
default: DefaultReporter,
|
|
4270
|
+
dot: DotReporter,
|
|
4025
4271
|
verbose: VerboseReporter,
|
|
4026
4272
|
'github-actions': GithubActionsReporter,
|
|
4027
4273
|
junit: JUnitReporter,
|
|
4274
|
+
json: JsonReporter,
|
|
4028
4275
|
md: MdReporter,
|
|
4029
4276
|
blob: BlobReporter
|
|
4030
4277
|
};
|
|
@@ -4081,7 +4328,10 @@ function core_createRstest({ config, projects, configFilePath }, command, fileFi
|
|
|
4081
4328
|
function defineConfig(config) {
|
|
4082
4329
|
return config;
|
|
4083
4330
|
}
|
|
4331
|
+
function defineInlineProject(config) {
|
|
4332
|
+
return config;
|
|
4333
|
+
}
|
|
4084
4334
|
function defineProject(config) {
|
|
4085
4335
|
return config;
|
|
4086
4336
|
}
|
|
4087
|
-
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 };
|
|
4337
|
+
export { config_loadConfig as loadConfig, core_createRstest as createRstest, core_namespaceObject, defineConfig, defineInlineProject, defineProject, detect, error_parseErrorStacktrace as parseErrorStacktrace, error_printError as printError, formatStack, init_initCli as initCli, init_namespaceObject, mergeProjectConfig, mergeRstestConfig, resolveCommand, runCLI, runRest };
|