@unotest/web 0.5.0 → 0.6.1
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/.claude/skills/write-e2e-test.md +9 -5
- package/CHANGELOG.md +49 -0
- package/README.md +59 -84
- package/bin/unotest-web.js +10 -32
- package/dist/config/schema.d.ts +9 -9
- package/dist/config/schema.js +1 -1
- package/dist/driver/index.js +1 -1
- package/dist/dsl/index.d.ts +25 -20
- package/dist/dsl/index.js +1 -1
- package/dist/linter-DzAzJpab.d.ts +21 -0
- package/dist/mcp/server.js +1 -1
- package/dist/runner/cli.d.ts +10 -1
- package/dist/runner/cli.js +1 -1
- package/dist/runner/init.js +1 -1
- package/dist/runner/install-chromium.js +1 -1
- package/dist/runner/prepare-fix.js +1 -1
- package/dist/runner/serve-fixture.js +1 -1
- package/dist/runner/web-runner-adapter.js +1 -1
- package/guides/agent-integration.md +297 -0
- package/guides/dsl-reference.md +670 -0
- package/package.json +29 -39
- package/src/mcp/prompts/agent-test-author.md +71 -1
package/dist/dsl/index.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ export { i as LocatorStep, j as appendStep, k as describeLocator, l as isLocator
|
|
|
3
3
|
import { Matcher, RegexLiteral } from '@unotest/protocol';
|
|
4
4
|
import { Statement, BlockStatement } from '@unotest/dsl';
|
|
5
5
|
import { SandboxConfig } from '../config/schema.js';
|
|
6
|
+
export { L as LintDiagnostic, a as LintOptions, b as LintSeverity, l as lintAst } from '../linter-DzAzJpab.js';
|
|
6
7
|
import 'zod';
|
|
7
8
|
|
|
8
9
|
/** Test/codegen convenience: build a RegexLiteral inline. The DSL
|
|
@@ -80,12 +81,14 @@ interface ExecutionError {
|
|
|
80
81
|
type ExecutionEvent = {
|
|
81
82
|
kind: 'step-start';
|
|
82
83
|
node: Statement;
|
|
84
|
+
file: string;
|
|
83
85
|
line: number;
|
|
84
86
|
col: number;
|
|
85
87
|
callStack?: readonly string[];
|
|
86
88
|
} | {
|
|
87
89
|
kind: 'step-end';
|
|
88
90
|
node: Statement;
|
|
91
|
+
file: string;
|
|
89
92
|
line: number;
|
|
90
93
|
col: number;
|
|
91
94
|
ok: true;
|
|
@@ -93,6 +96,7 @@ type ExecutionEvent = {
|
|
|
93
96
|
} | {
|
|
94
97
|
kind: 'step-end';
|
|
95
98
|
node: Statement;
|
|
99
|
+
file: string;
|
|
96
100
|
line: number;
|
|
97
101
|
col: number;
|
|
98
102
|
ok: false;
|
|
@@ -101,6 +105,7 @@ type ExecutionEvent = {
|
|
|
101
105
|
} | {
|
|
102
106
|
kind: 'paused';
|
|
103
107
|
reason: 'step' | 'failure' | 'breakpoint';
|
|
108
|
+
file: string;
|
|
104
109
|
line: number;
|
|
105
110
|
col: number;
|
|
106
111
|
};
|
|
@@ -137,6 +142,12 @@ interface RunResult {
|
|
|
137
142
|
error?: ExecutionError;
|
|
138
143
|
}
|
|
139
144
|
|
|
145
|
+
/** Read-only lookup over external scenario variables. */
|
|
146
|
+
interface VariableStore {
|
|
147
|
+
has(name: string): boolean;
|
|
148
|
+
get(name: string): string | undefined;
|
|
149
|
+
}
|
|
150
|
+
|
|
140
151
|
interface Logger {
|
|
141
152
|
info(msg: string, ...rest: unknown[]): void;
|
|
142
153
|
warn(msg: string, ...rest: unknown[]): void;
|
|
@@ -161,6 +172,9 @@ interface TestRuntimeDeps {
|
|
|
161
172
|
* `dbQuery`/`dbExec`, `apiCall` read these — scenarios can NOT pass a
|
|
162
173
|
* database connection or absolute URL through arguments. */
|
|
163
174
|
readonly sandbox?: SandboxConfig;
|
|
175
|
+
/** External variable store (`unotest/.env` + `.secrets`). Resolves bare
|
|
176
|
+
* UPPER_SNAKE identifiers. Defaults to an empty store when omitted. */
|
|
177
|
+
readonly variables?: VariableStore;
|
|
164
178
|
/** Injectable clock — defaults to Date.now. Tests pass a fake. */
|
|
165
179
|
readonly nowFn?: () => number;
|
|
166
180
|
}
|
|
@@ -170,6 +184,7 @@ declare class TestRuntime {
|
|
|
170
184
|
readonly context: DriverContext;
|
|
171
185
|
readonly logger: Logger;
|
|
172
186
|
readonly sandbox: SandboxConfig;
|
|
187
|
+
private readonly variables;
|
|
173
188
|
private readonly nowFn;
|
|
174
189
|
private readonly scope;
|
|
175
190
|
private _callDepth;
|
|
@@ -220,7 +235,15 @@ declare class FunctionRegistry {
|
|
|
220
235
|
declare class AstExecutor {
|
|
221
236
|
private readonly registry;
|
|
222
237
|
constructor(registry: FunctionRegistry);
|
|
223
|
-
|
|
238
|
+
private entryFile;
|
|
239
|
+
private fnFile;
|
|
240
|
+
/** Project-root-relative posix file the current step lives in: origin of
|
|
241
|
+
* the innermost user-function frame, else the entry file. `callStack`
|
|
242
|
+
* only ever holds user-function names (pushed in callUserFunction), so
|
|
243
|
+
* every frame has a `fnFile` entry; the `?? entryFile` is a defensive
|
|
244
|
+
* fallback, not a normal path. */
|
|
245
|
+
private fileForStack;
|
|
246
|
+
run(program: BlockStatement, testName: string, runtime: TestRuntime, opts: RunOptions, helpers?: BlockStatement[], entryFile?: string, fnFile?: ReadonlyMap<string, string>): AsyncGenerator<ExecutionEvent, RunResult>;
|
|
224
247
|
private runBlock;
|
|
225
248
|
private runStatement;
|
|
226
249
|
private execStatement;
|
|
@@ -317,22 +340,4 @@ declare class TestRuntimeManager {
|
|
|
317
340
|
/** Build a fully-populated FunctionRegistry. */
|
|
318
341
|
declare function buildDefaultRegistry(): FunctionRegistry;
|
|
319
342
|
|
|
320
|
-
type
|
|
321
|
-
interface LintDiagnostic {
|
|
322
|
-
rule: string;
|
|
323
|
-
severity: LintSeverity;
|
|
324
|
-
message: string;
|
|
325
|
-
line: number;
|
|
326
|
-
col: number;
|
|
327
|
-
}
|
|
328
|
-
interface LintOptions {
|
|
329
|
-
/** Per-rule severity override. Default severities live with each rule. */
|
|
330
|
-
ruleSeverity?: Partial<Record<string, LintSeverity>>;
|
|
331
|
-
/** Pass through if the agent provided documented justification — e.g. a
|
|
332
|
-
* `// reason:` comment immediately above the line. The lexer doesn't
|
|
333
|
-
* preserve comments today; for v1 we accept a flag from the caller. */
|
|
334
|
-
allowDisambigByIndex?: boolean;
|
|
335
|
-
}
|
|
336
|
-
declare function lintAst(ast: BlockStatement, opts?: LintOptions): LintDiagnostic[];
|
|
337
|
-
|
|
338
|
-
export { AstExecutor, type DslArg, type DslArray, type DslFunction, type DslObject, type DslValue, type ExecutionError, type ExecutionEvent, FunctionRegistry, type LintDiagnostic, type LintOptions, type LintSeverity, LocatorValue, type RunOptions, type RunResult, TestRuntime, TestRuntimeManager, buildDefaultRegistry, chainGetByAltText, chainGetByLabel, chainGetByPlaceholder, chainGetByRole, chainGetByTestId, chainGetByText, chainGetByTitle, contentFrame, filter, first, getByAltText, getByLabel, getByPlaceholder, getByRole, getByTestId, getByText, getByTitle, last, lintAst, locator, nth, re };
|
|
343
|
+
export { AstExecutor, type DslArg, type DslArray, type DslFunction, type DslObject, type DslValue, type ExecutionError, type ExecutionEvent, FunctionRegistry, LocatorValue, type RunOptions, type RunResult, TestRuntime, TestRuntimeManager, buildDefaultRegistry, chainGetByAltText, chainGetByLabel, chainGetByPlaceholder, chainGetByRole, chainGetByTestId, chainGetByText, chainGetByTitle, contentFrame, filter, first, getByAltText, getByLabel, getByPlaceholder, getByRole, getByTestId, getByText, getByTitle, last, locator, nth, re };
|