@unotest/dsl
v0.9.1
Published
JavaScript DSL parser + AST types for @unotest scenarios, plus a vocab-agnostic validator engine (subpath @unotest/dsl/validator). Extensions: MemberCallExpression (method chains), PropertyAccessExpression, raw backtick strings, MetaBlockStatement. See EX
Downloads
566
Readme
@unotest/dsl
JavaScript DSL parser + AST types for @unotest scenarios, plus a
vocab-agnostic validator engine under the @unotest/dsl/validator subpath.
Extensions documented in EXTENSIONS.md:
- MemberCallExpression — postfix
.IDENT(args)for method chains (loc.getByRole(...).filter(...).click()). - PropertyAccessExpression —
obj.propreads. - MetaBlockStatement —
//@collapse(...) … //@endcollapseblocks. - Raw backtick strings — multi-line
`...`without${}interpolation.
API
import { Lexer, Parser } from "@unotest/dsl";
const tokens = new Lexer("function test_x() { click(getByRole('button')); }").tokenize();
const ast = new Parser(tokens).parse();See the package source for the full surface (AST node types, builders, parser, lexer, token types).
Validator
import { validateDsl } from "@unotest/dsl/validator";
// `registry` is a FunctionContractRegistry supplied by the platform
// (e.g. @unotest/web's web-vocab contracts) — this package ships none.
const diagnostics = validateDsl(ast, code, /* isWrapped */ false, registry);The validator is vocab-agnostic: it walks the AST and checks function
contracts, argument kinds, and statement shape against the injected
registry. AST classes are shared with the parser root export, so
instanceof checks hold across both subpaths.
Consumers
@unotest/web— CLI / MCP / runner uses the parser for scenarios and@unotest/dsl/validatorwith its web-vocab contract registry forlint.
Pre-launch
Pre-1.0.0 — public API may change without deprecation cycles. Pin to
an exact version if breakage matters: "@unotest/dsl": "0.5.0".
