Expand description
Cucumber step-definition surface for the shared QuickJS engine.
The same VM that runs ferridriver run scripts and MCP run_script
also loads cucumber-js-shaped .js step files. Given/When/
Then/Before/After/defineParameterType/… are native Rust
functions (no JS glue); registrations land in a Rust ExtensionRegistry
held as context userdata (the QuickJS context is single-threaded, so
a RefCell is the right interior mutability — no Arc/Mutex).
Step bodies are kept as Persistent functions and called back by
the Rust ferridriver-bdd core. Every body receives the
per-scenario World as its FIRST positional argument — arrow,
classic function, async, all the same shape — followed by the
cucumber-extracted parameters, an optional DataTableJs, and an
optional doc-string. The World is also bound as this so
function (world) { this === world } holds for callers who prefer
that style.
No business logic here: matching, outline expansion, tag filtering
and hook ordering all stay in the ferridriver-bdd core.
Structs§
- Collected
Allow - Capability allow-list snapshot. Serialises to the exact JSON the MCP
PluginAllowdeserialises (commands+net, camelCase) so the loader needs no JS round-trip to recover manifests. - Collected
Hook - Collected
Param Type - Collected
Registry - Collected
Step - Step metadata read back by the
ferridriver-bddcore to build its Cucumber-Expression registry. Straight off the Rust registry — no JS round-trip. - Collected
Tool - One registered tool’s manifest, read straight off the Rust registry.
Field layout +
camelCasematch MCPPluginManifestso aserde_jsonround-trip reconstructs it without re-running the plugin. - Data
Table Js - A cucumber data table, passed to steps as the trailing argument.
- HookArg
- The argument cucumber-js passes to
Before/Afterhooks. Built by the BDD layer and lowered to a JS object{ pickle: { name, tags }, result: { status, message? } }ininvoke_hook— enough for the screenshot-on-failure idiom (After(s => { if (s.result.status === 'FAILED') this.attach(...) })). - Scenario
World - Per-scenario fixtures the BDD core threads onto the JS World — the
same handles
RunContextcarries for scripting, installed onto a per-scenario World object rather thanglobalThis. - Script
Attachment - One Cucumber attachment produced by
this.attach(...)/this.log(...)during a scenario. Drained by the BDD layer into the test result so the messages / HTML / Allure reporters surface it (screenshot- and text-on-failure).
Enums§
- JsArg
- A cucumber-extracted step argument, lowered directly to a JS value
(never through
serde_json— a transitive dep may enableserde_json/arbitrary_precision, which would turn numbers into objects). - Step
Kind - Cucumber step keyword.
Stepis keyword-agnostic (defineStep,And,But); matching in the core is keyword-agnostic anyway. - Step
Outcome - Outcome of a JS step/hook beyond plain pass (cucumber return
protocol: returning the string
'pending'/'skipped').
Functions§
- collect_
registry - Snapshot the registry after the step
.jsfiles evaluated. - drain_
attachments - Drain the scenario’s queued attachments (and clear the queue). The BDD layer calls this after each scenario and forwards them into the test result so the reporters surface them.
- install_
bdd - Install the native cucumber + MCP-tool surface and the shared
extension registry as context userdata. Idempotent; called once at
Session::create. - invoke_
hook - Invoke hook
idx. Same bridge asinvoke_step. - invoke_
step - Invoke step
idxwith cucumber-extracted args, the optional data table and doc string, against the current World. A thrown JS error becomes aScriptErrorcarrying the.jslocation. - reset_
world - Drop the per-scenario World (cucumber builds a fresh one per
scenario). The next
set_scenario_worldinstalls a new one. - set_
scenario_ world - Build the per-scenario World and make it the
thissteps run against. IfsetWorldConstructorwas used, that class is constructed and the fixtures are augmented onto the instance. - tool_
names - The ordered tool names — drives building the native
plugins.<name>surface. - tools_
len - Number of tools registered so far — lets the loader slice each bundled file’s contributions out of the shared registry.
- tools_
snapshot - Snapshot every registered tool manifest, in registration order.
Synchronous (
&Ctx) so the bundle/extraction path can call it inside its ownasync_with!without a second context hop.