Turns a recorded trace into an executable regression test.
This is the part of the feature that earns its keep. A causal view explains a bug once; an exported test keeps it fixed. The step from "I reproduced it" to "there is a test for it" is the expensive one on every team, and a trace already contains everything that step needs: the inputs, the expected observations, and the responses to replay instead of the network.
The generated file is deliberately readable and deliberately editable. It is a starting point a developer prunes — delete the assertions you do not care about, keep the ones that describe the bug — not an opaque artifact.
- Source:
Methods
(static) generateTest(trace, options) → {string}
Generates the source of a regression test from a trace.
Parameters:
- Source:
Returns:
The generated test source.
- Type
- string
(static) suggestName(trace) → {string}
Suggests a file name stem for an exported trace.
Parameters:
| Name | Type | Description |
|---|---|---|
trace |
object | The trace. |
- Source:
Returns:
A kebab-case stem such as cart-item-click.
- Type
- string
(inner) assertionsFor(step, redacted) → {Array:.<string:>}
Builds the assertion lines for one step.
Assertions come from the recorded DOM and state changes rather than from the final state alone, so a generated test fails at the step that broke rather than at the end.
Parameters:
| Name | Type | Description |
|---|---|---|
step |
object | A step from inputSteps. |
redacted |
boolean | Whether the trace withheld values. |
- Source:
Returns:
Assertion source lines, already indented.
(inner) describe(input) → {string}
Describes an input in a comment.
Parameters:
| Name | Type | Description |
|---|---|---|
input |
object | The input node. |
- Source:
Returns:
A short label.
- Type
- string
(inner) inputSteps(trace) → {Array:.<object:>}
Collects the inputs replay will drive, with the observations each caused.
Parameters:
| Name | Type | Description |
|---|---|---|
trace |
object | The trace. |
- Source:
Returns:
One entry per input, in recorded order.
(inner) literal(value) → {string}
Escapes a value for embedding in generated source.
Parameters:
| Name | Type | Description |
|---|---|---|
value |
any | The value. |
- Source:
Returns:
A JavaScript literal.
- Type
- string