@midscene/test 1.17.8-beta-20261110095715.0 → 1.17.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/es/164.mjs +49 -34
- package/dist/es/164.mjs.map +1 -1
- package/dist/es/{663.mjs → 299.mjs} +226 -213
- package/dist/es/299.mjs.map +1 -0
- package/dist/es/431.mjs +16 -42
- package/dist/es/431.mjs.map +1 -1
- package/dist/es/793.mjs +1 -1
- package/dist/es/cli/index.mjs +8 -1
- package/dist/es/cli/index.mjs.map +1 -0
- package/dist/lib/cli/index.js +51 -61
- package/dist/lib/cli/index.js.map +1 -1
- package/dist/lib/index.js +14 -40
- package/dist/lib/index.js.map +1 -1
- package/dist/lib/test-cli.js +882 -880
- package/dist/lib/test-cli.js.map +1 -1
- package/dist/types/cli/index.d.ts +4 -0
- package/package.json +17 -18
- package/dist/es/663.mjs.map +0 -1
package/dist/es/164.mjs
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import string_width from "string-width";
|
|
2
|
-
import { DEFAULT_TEST_FILE_SELECTION, fileURLToPath,
|
|
3
|
-
import { sep,
|
|
4
|
-
import { WorkflowExecutionFailure,
|
|
2
|
+
import { DEFAULT_TEST_FILE_SELECTION, fileURLToPath, prepareTestRun, discoverTestConfig, inspect, formatModelUsage, stripVTControlCharacters, CliModelUsage, runPreparedTestProject, loadTestProject } from "./299.mjs";
|
|
3
|
+
import { sep, realpathSync, resolve, statSync, existsSync, isAbsolute, appendFileSync, relative, win32, writeFileSync } from "./154.mjs";
|
|
4
|
+
import { WorkflowExecutionFailure, sanitizeReportValue } from "./793.mjs";
|
|
5
5
|
import { chalk } from "./946.mjs";
|
|
6
|
-
import {
|
|
6
|
+
import { renderTestBadgeLines } from "./431.mjs";
|
|
7
7
|
import { z } from "./487.mjs";
|
|
8
8
|
import { runWithConsoleLogHandler } from "./470.mjs";
|
|
9
|
-
var package_namespaceObject =
|
|
9
|
+
var package_namespaceObject = {
|
|
10
|
+
rE: "1.17.8"
|
|
11
|
+
};
|
|
10
12
|
const formatCliError = (error)=>'string' == typeof error ? error : inspect(error, {
|
|
11
13
|
colors: false,
|
|
12
14
|
depth: null,
|
|
@@ -39,6 +41,15 @@ const shorten = (value, length)=>{
|
|
|
39
41
|
const text = oneLine(value);
|
|
40
42
|
return text.length <= length ? text : `${text.slice(0, length - 1)}…`;
|
|
41
43
|
};
|
|
44
|
+
function unwrapFrameLocation(location) {
|
|
45
|
+
if (!location.endsWith(')')) return location;
|
|
46
|
+
const absoluteStart = location.search(/ \((?:file:\/\/|[A-Za-z]:[\\/]|\/|\\\\)/);
|
|
47
|
+
if (-1 !== absoluteStart) return location.slice(absoluteStart + 2, -1);
|
|
48
|
+
let depth = 0;
|
|
49
|
+
for(let index = location.length - 1; index >= 0; index--)if (')' === location[index]) depth++;
|
|
50
|
+
else if ('(' === location[index] && 0 === --depth) return ' ' === location[index - 1] ? location.slice(index + 1, -1) : location;
|
|
51
|
+
return location;
|
|
52
|
+
}
|
|
42
53
|
function firstBusinessFrame(error, projectRoot) {
|
|
43
54
|
const seen = new Set();
|
|
44
55
|
const frames = [];
|
|
@@ -51,8 +62,7 @@ function firstBusinessFrame(error, projectRoot) {
|
|
|
51
62
|
if ('string' != typeof detail.stack) return;
|
|
52
63
|
for (const line of detail.stack.split('\n')){
|
|
53
64
|
if (!line.trim().startsWith('at ')) continue;
|
|
54
|
-
|
|
55
|
-
if (location.endsWith(')')) location = location.slice(location.lastIndexOf('(') + 1, -1);
|
|
65
|
+
const location = unwrapFrameLocation(line.trim().slice(3).replace(/^async /, ''));
|
|
56
66
|
const match = location.match(/^(.*):(\d+):(\d+)$/);
|
|
57
67
|
if (!match) continue;
|
|
58
68
|
let file = match[1];
|
|
@@ -80,17 +90,15 @@ function firstBusinessFrame(error, projectRoot) {
|
|
|
80
90
|
function formatFailureInput(input) {
|
|
81
91
|
if (void 0 === input) return [];
|
|
82
92
|
const value = sanitizeReportValue(input).value;
|
|
83
|
-
const render = (value)=>shorten(
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
})
|
|
93
|
-
}).message, 160);
|
|
93
|
+
const render = (value)=>shorten('string' == typeof value ? value : inspect(value, {
|
|
94
|
+
colors: false,
|
|
95
|
+
depth: 2,
|
|
96
|
+
maxArrayLength: 4,
|
|
97
|
+
maxStringLength: 180,
|
|
98
|
+
breakLength: 1 / 0,
|
|
99
|
+
customInspect: false,
|
|
100
|
+
getters: false
|
|
101
|
+
}), 160);
|
|
94
102
|
if (value && 'object' == typeof value && !Array.isArray(value)) {
|
|
95
103
|
const entries = Object.entries(value);
|
|
96
104
|
const rows = entries.slice(0, 4).map(([key, value])=>`${shorten(key, 48)}: ${render(value)}`);
|
|
@@ -127,10 +135,7 @@ function formatFailureDetails(source, error, context = {}) {
|
|
|
127
135
|
]
|
|
128
136
|
])if (attempt && (attempt.total > 1 || attempt.index > 0)) field(label, `${attempt.index + 1}/${attempt.total}`);
|
|
129
137
|
if (body.length) body.push('');
|
|
130
|
-
const
|
|
131
|
-
message: formatConciseError(error)
|
|
132
|
-
}).message;
|
|
133
|
-
const lines = stripVTControlCharacters(safeMessage).split(/\r?\n/);
|
|
138
|
+
const lines = stripVTControlCharacters(formatConciseError(error)).split(/\r?\n/);
|
|
134
139
|
body.push(` Error: ${shorten(lines[0], 320)}`, ...lines.slice(1, 6).map((line)=>` ${shorten(line, 320)}`));
|
|
135
140
|
if (lines.length > 6) body.push(' … (use --reporter verbose for details)');
|
|
136
141
|
const input = step ? formatFailureInput(step.input) : [];
|
|
@@ -903,8 +908,7 @@ function writeGitHubSummary(result) {
|
|
|
903
908
|
const summary = [
|
|
904
909
|
'## Midscene Test',
|
|
905
910
|
'',
|
|
906
|
-
|
|
907
|
-
'',
|
|
911
|
+
...renderTestBadgeLines(result),
|
|
908
912
|
'| Passed | Failed | Not run | Passed after retry | Duration |',
|
|
909
913
|
'| ---: | ---: | ---: | ---: | ---: |',
|
|
910
914
|
`| ${result.summary.passed} | ${result.summary.failed} | ${result.summary.notRun} | ${result.summary.passedAfterRetry} | ${formatDuration(result.durationMs)} |`,
|
|
@@ -1091,7 +1095,7 @@ function captureTerminalOutput(output, streams = [
|
|
|
1091
1095
|
const parseTestCliArgs = (args, cwd = process.cwd())=>{
|
|
1092
1096
|
const command = 'nodes' === args[0] ? args[0] : void 0;
|
|
1093
1097
|
const commandOffset = command ? 1 : 0;
|
|
1094
|
-
let
|
|
1098
|
+
let inputPath;
|
|
1095
1099
|
let configPath;
|
|
1096
1100
|
let resultDir;
|
|
1097
1101
|
const projectNames = [];
|
|
@@ -1102,8 +1106,8 @@ const parseTestCliArgs = (args, cwd = process.cwd())=>{
|
|
|
1102
1106
|
const arg = equal < 0 ? token : token.slice(0, equal);
|
|
1103
1107
|
const inlineValue = equal < 0 ? void 0 : token.slice(equal + 1);
|
|
1104
1108
|
if (!arg.startsWith('-')) {
|
|
1105
|
-
if (
|
|
1106
|
-
|
|
1109
|
+
if (inputPath) throw new Error('Only one test file or directory is allowed.');
|
|
1110
|
+
inputPath = resolve(cwd, arg);
|
|
1107
1111
|
continue;
|
|
1108
1112
|
}
|
|
1109
1113
|
if ('--config' === arg || '--result-dir' === arg || '--project' === arg || '--reporter' === arg) {
|
|
@@ -1127,7 +1131,11 @@ const parseTestCliArgs = (args, cwd = process.cwd())=>{
|
|
|
1127
1131
|
command
|
|
1128
1132
|
} : {},
|
|
1129
1133
|
cwd,
|
|
1130
|
-
|
|
1134
|
+
...command ? {
|
|
1135
|
+
projectRoot: inputPath
|
|
1136
|
+
} : {
|
|
1137
|
+
testPath: inputPath
|
|
1138
|
+
},
|
|
1131
1139
|
configPath,
|
|
1132
1140
|
resultDir,
|
|
1133
1141
|
...projectNames.length > 0 ? {
|
|
@@ -1171,6 +1179,12 @@ Options:
|
|
|
1171
1179
|
--help, -h Show this help
|
|
1172
1180
|
--version Show the package version
|
|
1173
1181
|
|
|
1182
|
+
With a config, run paths filter project files. Without one, they select standalone inputs.
|
|
1183
|
+
Run paths never change config discovery or the artifact root.
|
|
1184
|
+
For test runs, config discovery checks cwd only; --config is relative to cwd.
|
|
1185
|
+
The selected config directory becomes the test root.
|
|
1186
|
+
File include/exclude and tag rules still apply to explicit paths.
|
|
1187
|
+
|
|
1174
1188
|
Legacy tasks/flow YAML and its CLI options belong to the midscene command.
|
|
1175
1189
|
`;
|
|
1176
1190
|
const assertDirectory = (path, label)=>{
|
|
@@ -1414,16 +1428,17 @@ async function runTestCli(args, io = defaultCliIO, onResult) {
|
|
|
1414
1428
|
}
|
|
1415
1429
|
const reporter = new TerminalReporter(io, options.reporter);
|
|
1416
1430
|
const restoreOutput = io === defaultCliIO && io.isTTY && 'verbose' !== options.reporter ? captureTerminalOutput((message, write)=>reporter.output(message, write)) : void 0;
|
|
1417
|
-
const projectRoot = realpathSync(options.projectRoot && existsSync(options.projectRoot) && statSync(options.projectRoot).isFile() ? dirname(options.projectRoot) : options.projectRoot ?? options.cwd);
|
|
1418
1431
|
try {
|
|
1419
1432
|
return await runWithConsoleLogHandler((entry)=>reporter.console(entry), async ()=>{
|
|
1433
|
+
const plan = await prepareTestRun({
|
|
1434
|
+
...options,
|
|
1435
|
+
onProgress: (message)=>reporter.progress(message),
|
|
1436
|
+
onEvent: (event)=>reporter.event(event)
|
|
1437
|
+
});
|
|
1438
|
+
const projectRoot = realpathSync(plan.projectRoot);
|
|
1420
1439
|
let result;
|
|
1421
1440
|
try {
|
|
1422
|
-
result = await
|
|
1423
|
-
...options,
|
|
1424
|
-
onProgress: (message)=>reporter.progress(message),
|
|
1425
|
-
onEvent: (event)=>reporter.event(event)
|
|
1426
|
-
});
|
|
1441
|
+
result = await runPreparedTestProject(plan);
|
|
1427
1442
|
} catch (error) {
|
|
1428
1443
|
if (!(error instanceof WorkflowExecutionFailure)) throw error;
|
|
1429
1444
|
reportTestProjectResult(error.result, io, reporter, projectRoot, error.errors);
|