nukadoko 0.1.0 → 0.2.0
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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +291 -0
- data/README.ja.md +58 -5
- data/README.md +15 -3
- data/exe/nuka +8 -0
- data/lib/nukadoko/aria_snapshot.rb +1008 -0
- data/lib/nukadoko/aria_tree.rb +150 -0
- data/lib/nukadoko/base.rb +274 -0
- data/lib/nukadoko/check.rb +669 -22
- data/lib/nukadoko/claim_check.rb +177 -0
- data/lib/nukadoko/claim_check_run.rb +293 -0
- data/lib/nukadoko/claim_line.rb +381 -0
- data/lib/nukadoko/claim_rules.rb +519 -0
- data/lib/nukadoko/claims.rb +407 -30
- data/lib/nukadoko/cli.rb +802 -19
- data/lib/nukadoko/codes.json +942 -0
- data/lib/nukadoko/codes.rb +19 -0
- data/lib/nukadoko/command.rb +214 -12
- data/lib/nukadoko/criteria.rb +172 -0
- data/lib/nukadoko/definition.rb +33 -41
- data/lib/nukadoko/env_check.rb +90 -0
- data/lib/nukadoko/features.rb +80 -10
- data/lib/nukadoko/fixtures.rb +296 -10
- data/lib/nukadoko/http_recording.rb +68 -0
- data/lib/nukadoko/init.rb +130 -0
- data/lib/nukadoko/judge.rb +221 -0
- data/lib/nukadoko/judgment_file.rb +78 -0
- data/lib/nukadoko/judgments.rb +256 -0
- data/lib/nukadoko/literal.rb +129 -0
- data/lib/nukadoko/measured.rb +105 -0
- data/lib/nukadoko/order.rb +84 -0
- data/lib/nukadoko/parts.rb +42 -21
- data/lib/nukadoko/pattern.rb +11 -1
- data/lib/nukadoko/poll.rb +17 -6
- data/lib/nukadoko/program.rb +105 -17
- data/lib/nukadoko/project_fixtures.rb +17 -2
- data/lib/nukadoko/report_allure.rb +751 -0
- data/lib/nukadoko/report_messages.rb +167 -0
- data/lib/nukadoko/report_run.rb +169 -0
- data/lib/nukadoko/run.rb +865 -88
- data/lib/nukadoko/run_record.rb +532 -0
- data/lib/nukadoko/scaffold.rb +1015 -0
- data/lib/nukadoko/schema.rb +61 -4
- data/lib/nukadoko/secrets.rb +359 -0
- data/lib/nukadoko/selection.rb +163 -0
- data/lib/nukadoko/signature.rb +4 -1
- data/lib/nukadoko/skill.rb +36 -0
- data/lib/nukadoko/step.rb +62 -21
- data/lib/nukadoko/summary.rb +662 -0
- data/lib/nukadoko/table.rb +34 -2
- data/lib/nukadoko/text_fit.rb +179 -0
- data/lib/nukadoko/trace.rb +244 -0
- data/lib/nukadoko/trace_actions.rb +116 -0
- data/lib/nukadoko/tree_passes.rb +119 -0
- data/lib/nukadoko/verdict.rb +128 -0
- data/lib/nukadoko/version.rb +2 -1
- data/lib/nukadoko/vocabulary.rb +6 -0
- data/lib/nukadoko/walk.rb +305 -0
- data/lib/nukadoko/walk_files.rb +473 -0
- data/lib/nukadoko/walk_step.rb +149 -0
- data/lib/nukadoko.rb +36 -0
- data/llms.txt +296 -0
- data/sig/generated/nukadoko/aria_snapshot.rbs +331 -0
- data/sig/generated/nukadoko/aria_tree.rbs +142 -0
- data/sig/generated/nukadoko/base.rbs +136 -0
- data/sig/generated/nukadoko/check.rbs +255 -0
- data/sig/generated/nukadoko/claim_check.rbs +118 -0
- data/sig/generated/nukadoko/claim_check_run.rbs +88 -0
- data/sig/generated/nukadoko/claim_line.rbs +158 -0
- data/sig/generated/nukadoko/claim_rules.rbs +172 -0
- data/sig/generated/nukadoko/claims.rbs +165 -0
- data/sig/generated/nukadoko/cli.rbs +182 -0
- data/sig/generated/nukadoko/codes.rbs +16 -0
- data/sig/generated/nukadoko/command.rbs +109 -0
- data/sig/generated/nukadoko/criteria.rbs +83 -0
- data/sig/generated/nukadoko/definition.rbs +30 -0
- data/sig/generated/nukadoko/env_check.rbs +38 -0
- data/sig/generated/nukadoko/features.rbs +101 -0
- data/sig/generated/nukadoko/fixtures.rbs +152 -0
- data/sig/generated/nukadoko/http_recording.rbs +29 -0
- data/sig/generated/nukadoko/init.rbs +66 -0
- data/sig/generated/nukadoko/judge.rbs +64 -0
- data/sig/generated/nukadoko/judgment_file.rbs +39 -0
- data/sig/generated/nukadoko/judgments.rbs +120 -0
- data/sig/generated/nukadoko/literal.rbs +71 -0
- data/sig/generated/nukadoko/measured.rbs +42 -0
- data/sig/generated/nukadoko/order.rbs +54 -0
- data/sig/generated/nukadoko/parts.rbs +35 -0
- data/sig/generated/nukadoko/pattern.rbs +28 -0
- data/sig/generated/nukadoko/poll.rbs +40 -0
- data/sig/generated/nukadoko/program.rbs +101 -0
- data/sig/generated/nukadoko/project_fixtures.rbs +57 -0
- data/sig/generated/nukadoko/report_allure.rbs +268 -0
- data/sig/generated/nukadoko/report_messages.rbs +68 -0
- data/sig/generated/nukadoko/report_run.rbs +102 -0
- data/sig/generated/nukadoko/run.rbs +257 -0
- data/sig/generated/nukadoko/run_record.rbs +174 -0
- data/sig/generated/nukadoko/scaffold.rbs +328 -0
- data/sig/generated/nukadoko/schema.rbs +137 -0
- data/sig/generated/nukadoko/secrets.rbs +157 -0
- data/sig/generated/nukadoko/selection.rbs +73 -0
- data/sig/generated/nukadoko/signature.rbs +17 -0
- data/sig/generated/nukadoko/skill.rbs +20 -0
- data/sig/generated/nukadoko/step.rbs +115 -0
- data/sig/generated/nukadoko/summary.rbs +204 -0
- data/sig/generated/nukadoko/table.rbs +43 -0
- data/sig/generated/nukadoko/text_fit.rbs +70 -0
- data/sig/generated/nukadoko/trace.rbs +127 -0
- data/sig/generated/nukadoko/trace_actions.rbs +40 -0
- data/sig/generated/nukadoko/tree_passes.rbs +48 -0
- data/sig/generated/nukadoko/verdict.rbs +56 -0
- data/sig/generated/nukadoko/version.rbs +5 -0
- data/sig/generated/nukadoko/vocabulary.rbs +25 -0
- data/sig/generated/nukadoko/walk.rbs +139 -0
- data/sig/generated/nukadoko/walk_files.rbs +189 -0
- data/sig/generated/nukadoko/walk_step.rbs +50 -0
- data/sig/generated/nukadoko.rbs +15 -0
- data/sig/nukadoko.rbs +5 -48
- data/skills/nukadoko/SKILL.md +120 -0
- data/skills/nukadoko/references/checking-steps.md +200 -0
- data/skills/nukadoko/references/diagnosing.md +200 -0
- data/skills/nukadoko/references/done.md +99 -0
- data/skills/nukadoko/references/evidence.md +124 -0
- data/skills/nukadoko/references/examples/cli.md +230 -0
- data/skills/nukadoko/references/examples/http-api.md +339 -0
- data/skills/nukadoko/references/examples/workflow.md +173 -0
- data/skills/nukadoko/references/exploring.md +184 -0
- data/skills/nukadoko/references/fixtures.md +198 -0
- data/skills/nukadoko/references/from-prose.md +51 -0
- data/skills/nukadoko/references/judgments.md +95 -0
- data/skills/nukadoko/references/maintenance.md +97 -0
- data/skills/nukadoko/references/merge-risk.md +74 -0
- data/skills/nukadoko/references/parts.md +152 -0
- data/skills/nukadoko/references/perturbed-worlds.md +107 -0
- data/skills/nukadoko/references/program.md +200 -0
- data/skills/nukadoko/references/reviewing.md +200 -0
- data/skills/nukadoko/references/running.md +200 -0
- data/skills/nukadoko/references/scenario-rules.md +188 -0
- data/skills/nukadoko/references/states.md +66 -0
- data/skills/nukadoko/references/step-files.md +200 -0
- data/skills/nukadoko/references/verdicts.md +200 -0
- data/skills/nukadoko/references/writing-steps.md +200 -0
- data/skills/nukadoko/references/writing-the-feature.md +165 -0
- data/skills/nukadoko/scripts/claude-code-verdict-hook.mjs +99 -0
- data/skills/nukadoko/scripts/merge-risk.jq +56 -0
- data/skills/nukadoko-verification/SKILL.md +263 -0
- metadata +121 -1
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
# Walking a person through a scenario, one step at a time
|
|
2
|
+
|
|
3
|
+
Use this when the person wants to check that each step does what its
|
|
4
|
+
sentence says, with you beside them, instead of reading the run summary
|
|
5
|
+
alone. The raw output of a step (a JSON result, a list of files, an HTTP
|
|
6
|
+
log) is rarely enough for a person to judge. Your job in the walk is to
|
|
7
|
+
read that output for them, say what it means, and show where you read it.
|
|
8
|
+
|
|
9
|
+
## 1. Start the walk
|
|
10
|
+
|
|
11
|
+
```sh
|
|
12
|
+
npx nuka check features/checkout.feature
|
|
13
|
+
npx nuka run features/checkout.feature:12 --step # in the background
|
|
14
|
+
npx nuka step wait
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
`--step` runs one scenario in one environment, and after each step it
|
|
18
|
+
pauses with the world, the browser, and the fixtures still open until a
|
|
19
|
+
`nuka step` call answers. Start it in the host's background mode (in
|
|
20
|
+
Claude Code, `run_in_background`), since it does not return until the
|
|
21
|
+
walk ends. `nuka step wait` waits up to `--timeout` seconds (default 90)
|
|
22
|
+
and prints where the walk stands:
|
|
23
|
+
|
|
24
|
+
```
|
|
25
|
+
walk 1 paused after step 1/4 (passed): the shopper opens the cart
|
|
26
|
+
scenario: features/checkout.feature:12 Pay for a cart (default)
|
|
27
|
+
record: .nukadoko/runs/<run_id>/steps/<id>/record.json
|
|
28
|
+
view: page 1 http://127.0.0.1:41233/cart "Cart": <run_dir>/pauses/1/page.png <run_dir>/pauses/1/page.aria.yml
|
|
29
|
+
world: http://127.0.0.1:41233
|
|
30
|
+
do: nuka step next 1 --walk 1 (or: nuka step stop 1 --walk 1)
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
`--json` gives the same as fields: `walk`, `pause` (`pause`, `of`,
|
|
34
|
+
`line`, `text`, `step`, `status`, `record`, `failure` when the scenario
|
|
35
|
+
failed there, `remaining`, `paused_at`, `views`), `run_id`, `run_dir`,
|
|
36
|
+
`scenario`, `world`, and `do`. A wait that prints `starting` or
|
|
37
|
+
`running` ran out before the walk paused: run it again. A run that
|
|
38
|
+
refused (more than one scenario, say) never pauses, and a wait shows it
|
|
39
|
+
ended before its scenario ran. A wait reports each end once, then waits
|
|
40
|
+
for the next walk; `nuka step wait --walk <w>` shows that walk again.
|
|
41
|
+
|
|
42
|
+
## 2. Gather one step
|
|
43
|
+
|
|
44
|
+
For each pause, before you say anything about the step:
|
|
45
|
+
|
|
46
|
+
- The sentence: the pause's `text`, with its `line`.
|
|
47
|
+
- The contract: `npx nuka describe <step>` gives its `description`,
|
|
48
|
+
`mutates`, `from`, `args`, `returns`, and `file`, the step file to read.
|
|
49
|
+
- The record: `<run_dir>/<record>/record.json`. Read `args`,
|
|
50
|
+
`args_origin`, `result` (or `error` when it failed), `returns_dropped`,
|
|
51
|
+
`mutates`, `observed`, `used`, `calls`, and `evidence`.
|
|
52
|
+
- The views: each open page as the step left it, `page.png` for the
|
|
53
|
+
person and `page.aria.yml`, its accessibility tree, for you
|
|
54
|
+
(`page-2.*`, `page.<name>.*` for a second page or a `pageAs` context),
|
|
55
|
+
taken after the step's record. What a page sent while the walk waited
|
|
56
|
+
is in `pauses/<n>/http.jsonl`, not in the step's.
|
|
57
|
+
- The world, when there is one: its URL is live, so you can read it, but
|
|
58
|
+
anything you change there is what the next step finds.
|
|
59
|
+
|
|
60
|
+
What each part of `observed` says (a `null` channel means nothing was
|
|
61
|
+
measured there, not that nothing happened):
|
|
62
|
+
|
|
63
|
+
- `processes` lists each `runCommand`, with its command, `cwd`, `exit_code`,
|
|
64
|
+
`group` (`running` if a process it started still ran in its group), `files`
|
|
65
|
+
(what it added, changed, or removed under its working directory), `stdout` and
|
|
66
|
+
`stderr` (the files in the record's directory that hold what it printed),
|
|
67
|
+
`stdin` (the file that holds what it was given), and `env` (how its
|
|
68
|
+
environment differed from the runner's: each name, with a value only when it
|
|
69
|
+
is an existing absolute path, a decimal integer, or a boolean, else its
|
|
70
|
+
`hidden_bytes`).
|
|
71
|
+
- `http` counts the requests the step sent. Each is a line in `http.jsonl` with
|
|
72
|
+
its method, URL, status, request body, and response body. A line marked
|
|
73
|
+
`after_step_end` started after the record was written, so the record does not
|
|
74
|
+
count it; the run summary names it and its file. A body marked `incomplete`
|
|
75
|
+
was still arriving when nukadoko stopped waiting; one with an `error` failed
|
|
76
|
+
on its own. A line's `traceparent` is the value the request went out with,
|
|
77
|
+
nukadoko's or the step's own, and `traceparent_sent_to` the origins that
|
|
78
|
+
received it; nukadoko's value names the id the program's log lines carry.
|
|
79
|
+
- `program_log` counts the step's lines of the program's log, in
|
|
80
|
+
`program-log.txt` (late ones in `program-log-late.txt`): what the server
|
|
81
|
+
did for this step. `lines: 0` with `stamped` above 0 is explained by the
|
|
82
|
+
run summary's line for the world (`program.md`); `null`: a `url` world.
|
|
83
|
+
- `events` counts the step's execution events by kind, in `events.jsonl`
|
|
84
|
+
(late ones in `events-late.jsonl`); `open` names why `whole` is false.
|
|
85
|
+
- `mcp` and `websocket` count the lines of `mcp.jsonl` and `websocket.jsonl` (`evidence.md`).
|
|
86
|
+
- `files` lists the paths the step changed in a scratch directory or wrote
|
|
87
|
+
through `node:fs`, each with its content after the step. A file the step asked
|
|
88
|
+
Playwright to write (a screenshot saved to a path, a trace from
|
|
89
|
+
`tracing.stop({ path })`) is listed; what Playwright's server writes on its
|
|
90
|
+
own (trace chunks, a HAR, a video) is not, whoever launched the browser.
|
|
91
|
+
- `unmeasured` lists what the step did that nukadoko saw but cannot measure:
|
|
92
|
+
a process started without `runCommand` (its program and argument count
|
|
93
|
+
only), a `Worker`, a connection that carries no recorded request, a UDP
|
|
94
|
+
datagram, a page request that went without a `traceparent`, a written path
|
|
95
|
+
nukadoko could not inspect. The record has no evidence of what it did, so
|
|
96
|
+
a claim that rests on it is cannot tell. An empty list is not proof that
|
|
97
|
+
nothing else happened: a child process's own traffic is never seen.
|
|
98
|
+
|
|
99
|
+
The other fields:
|
|
100
|
+
|
|
101
|
+
- `args_origin` says where each argument came from (a capture, the
|
|
102
|
+
docstring, the table, an earlier step's result, the command line, or
|
|
103
|
+
the schema), which names the input to fix when an argument is wrong.
|
|
104
|
+
- `used` names the earlier step records read through `from`, and their values.
|
|
105
|
+
- `evidence` points at the trace, `http.jsonl`, and attachments: name the file to open.
|
|
106
|
+
- `judged_view` (a Then that read a page): each open page right after the judged reading,
|
|
107
|
+
in `judged/`, each file with `after_reading_ms`; the pause's view and `final.png` are later.
|
|
108
|
+
- `pages`, when `observe` reached a page: per open page, the latest response
|
|
109
|
+
it finished receiving before the reading (`last_response`) and the requests
|
|
110
|
+
in flight during it (`in_flight`), indexes into `page_requests` with
|
|
111
|
+
`sent_during`, per reading of a poll too. An order, not what the page drew:
|
|
112
|
+
a claim judged with one in flight (the summary line names it) may be stale.
|
|
113
|
+
|
|
114
|
+
## 3. Judge it with fresh eyes
|
|
115
|
+
|
|
116
|
+
The agent that wrote a step reads its own intent into the record. When the
|
|
117
|
+
host can start a subagent, give one only the sentence, the step file, and
|
|
118
|
+
the record, and ask whether what was measured does what the sentence
|
|
119
|
+
says; without a subagent, judge it yourself from the record alone and
|
|
120
|
+
say so. Expect one of four answers, each citing the field it rests on:
|
|
121
|
+
|
|
122
|
+
- **matches**: the record shows the sentence happening, and nothing else.
|
|
123
|
+
- **does less**: part of the sentence has no trace in the record (a Then
|
|
124
|
+
whose claims read something other than what the sentence names, a When
|
|
125
|
+
whose process exited before it did the work).
|
|
126
|
+
- **does more**: the record shows work the sentence does not name (a
|
|
127
|
+
write under a `mutates: false` declaration, which `undeclared-write`
|
|
128
|
+
names, a file the sentence never mentions, a request elsewhere).
|
|
129
|
+
- **cannot tell**: the evidence does not reach the claim (an
|
|
130
|
+
`observed` channel that is `null` or an entry in `observed.unmeasured`
|
|
131
|
+
where the claim needs evidence, a result that only echoes an argument).
|
|
132
|
+
|
|
133
|
+
A claim's `measured` names the channel in the record that holds the raw
|
|
134
|
+
value it compared, and the run summary prints it on the claim's line as
|
|
135
|
+
`measured: <channel>` or `measured: none`. `none` is what a constant in
|
|
136
|
+
step code looks like, and also a value read out of a larger body (one key
|
|
137
|
+
of a JSON response), so it is a place to look, not a verdict. An expected
|
|
138
|
+
value that came from `from` or `observe` gets the same after it, `expected
|
|
139
|
+
measured: <channel>` or `expected measured: none`, and `none` there is
|
|
140
|
+
what a When step that returns the value its Then compares with looks like.
|
|
141
|
+
"What this run does not show" lists what a green row does not cover, by
|
|
142
|
+
kind (`limits`): `no-claim`, `control-not-proving`, `unmeasured`, and more. A
|
|
143
|
+
Then whose `observe` reads a file and claims on it often comes back as cannot
|
|
144
|
+
tell, with `measured: null`: the record keeps what a process printed and the
|
|
145
|
+
files it changed, and nothing of a file the step read itself. That is a gap in
|
|
146
|
+
the evidence, not a wrong step. Have `observe` attach what it read with
|
|
147
|
+
`evidence.attach` (`evidence.md`), run again, and the next walk can show it.
|
|
148
|
+
|
|
149
|
+
## 4. Show one step, then wait
|
|
150
|
+
|
|
151
|
+
Tell the person, in their language and in plain words:
|
|
152
|
+
|
|
153
|
+
1. The sentence.
|
|
154
|
+
2. What happened, in a sentence or two, from the measured fields: "init
|
|
155
|
+
wrote 11 files under the project, among them `modules/orders/module.ts`,
|
|
156
|
+
and exited 0". Describe the measurement, not what the code meant to do.
|
|
157
|
+
When `used` is present, say what the step took from which earlier step:
|
|
158
|
+
"it ran in the `project` that installing solarsql returned".
|
|
159
|
+
3. The verdict from step 3 and the field it rests on.
|
|
160
|
+
4. What to open to confirm it: a Then's `judged/page.png`, else the pause's
|
|
161
|
+
`page.png`, a line of `http.jsonl`, a file the process wrote.
|
|
162
|
+
|
|
163
|
+
Then stop and wait for the person. Never answer a pause they have not
|
|
164
|
+
answered: the run waits exactly so that they judge each step while its
|
|
165
|
+
world is still there. Answer with the pause number they saw and the walk
|
|
166
|
+
number it printed (`walk 1 paused ...`), as the `do` line spells it:
|
|
167
|
+
|
|
168
|
+
- To go on: `npx nuka step next <n> --walk <w>`. It runs the next step
|
|
169
|
+
and prints the next pause, or the end after the last step.
|
|
170
|
+
- To stop: `npx nuka step stop <n> --walk <w>`. The steps after it do not
|
|
171
|
+
run, After hooks and teardown do, and the record says the scenario was
|
|
172
|
+
`stopped` at that step, not that it failed (`walk-stopped`).
|
|
173
|
+
|
|
174
|
+
A call whose output you lost, or that printed `starting` or `running`, is safe
|
|
175
|
+
to run again: an answer is written once, and the same answer again prints what
|
|
176
|
+
followed it. `pause-answered` means another answer reached that pause first,
|
|
177
|
+
`pause-not-current` that the walk is elsewhere, and `walk-not-current` that a
|
|
178
|
+
later walk replaced the one the answer names: show the person what the `nuka
|
|
179
|
+
step wait --walk <w>` of its `do` prints before you answer again. A pause where
|
|
180
|
+
the scenario failed (a step, or an AfterStep hook after it) prints `failure:`,
|
|
181
|
+
exits 1 with `walk-failed`, and offers only `next`: show the failure and the
|
|
182
|
+
views, answer `next` once the person has seen them, and go to `diagnosing.md`. A
|
|
183
|
+
walk a signal ended (the host's background limit, Ctrl-C) prints `interrupted`;
|
|
184
|
+
one whose run was killed prints `walk-gone`, and its `do:` starts it again.
|
|
185
|
+
|
|
186
|
+
A walked run is not the run a reviewer approves (the world and the browser
|
|
187
|
+
stayed open between steps, and its summary says so): after the walk, run the
|
|
188
|
+
scenario once more without `--step`.
|
|
189
|
+
|
|
190
|
+
## 5. When the person disagrees
|
|
191
|
+
|
|
192
|
+
Stop the walk at that pause (`nuka step stop <n> --walk <w>`) before you change
|
|
193
|
+
anything. The fix goes in the step file or the feature, never in the record: a
|
|
194
|
+
hand edit turns a measurement back into a claim. To show a variation of one step
|
|
195
|
+
without rerunning the whole scenario, `nuka do <step> --use <step_record_id>`
|
|
196
|
+
runs it alone on the same upstream values; that is a working record, not
|
|
197
|
+
evidence. After the fix, start a new walk; with the person's word, answer `next`
|
|
198
|
+
through the steps they already accepted, up to the first step whose file or
|
|
199
|
+
sentence changed. A Then the person rejects is fixed in the implementation or by
|
|
200
|
+
their word, not by weakening the Then.
|
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
# Running
|
|
2
|
+
|
|
3
|
+
## Setting up
|
|
4
|
+
|
|
5
|
+
Run every `nuka` command from the directory that holds the config; in a
|
|
6
|
+
workspace, that is the package, not the root. When there is no config,
|
|
7
|
+
`nuka init` writes it, `features/steps/`, `.gitignore` lines for
|
|
8
|
+
`.nukadoko/` and `.env` files, and a `test:scenarios` script in
|
|
9
|
+
`package.json`, so `npm run test:scenarios` runs `nuka run`, which checks
|
|
10
|
+
`featuresDir` and then executes it. A `test:scenarios` script the project
|
|
11
|
+
already has stays, and `init` says so on stderr; run `nuka run` directly
|
|
12
|
+
then. It also adds the steps and the config to `tsconfig.json`'s
|
|
13
|
+
`include`, and `"rewriteRelativeImportExtensions": true` to its `compilerOptions` so
|
|
14
|
+
`tsc` accepts the `.ts` import names `nuka scaffold` writes, keeping its
|
|
15
|
+
comments and trailing commas. When `compilerOptions` comes only through
|
|
16
|
+
`extends`, `init` says on stderr what to add instead of editing.
|
|
17
|
+
|
|
18
|
+
A CommonJS project (no `"type": "module"` in `package.json`) gets
|
|
19
|
+
`nukadoko.config.mts` and `.mts` step files from `nuka scaffold`. A `.ts`
|
|
20
|
+
step file loads there with a Node warning, unless `"type": "commonjs"`
|
|
21
|
+
is set, where it needs `.mts`. A hand-written
|
|
22
|
+
`nukadoko.config.ts` there loads with a Node warning on every run (`nuka
|
|
23
|
+
check` notes it as `package-type-missing`), and fails to import under
|
|
24
|
+
`"type": "commonjs"`, with an error that names the file.
|
|
25
|
+
|
|
26
|
+
A flag that takes one string or one number is refused when it is given
|
|
27
|
+
more than once, and the command writes nothing. `--use`, `--fail-on`,
|
|
28
|
+
`nuka run`'s `--env` and `--tag`, and `nuka scaffold`'s `--from` repeat, each value
|
|
29
|
+
kept in the order given.
|
|
30
|
+
|
|
31
|
+
## The program under test
|
|
32
|
+
|
|
33
|
+
`nukadoko.program.ts`, beside the config, builds, starts, and stops the
|
|
34
|
+
program the scenarios talk to, once per run (`references/program.md`).
|
|
35
|
+
|
|
36
|
+
## Environments
|
|
37
|
+
|
|
38
|
+
`--env <name>` on `nuka do` and `nuka run` targets an entry of the program
|
|
39
|
+
file's `environments`, or `default`, which needs none. An entry overrides
|
|
40
|
+
any program field, adds `envFiles` after the config's, and may set
|
|
41
|
+
`policy: "read-only"` and `conditions`. `nuka run` without `--env` runs
|
|
42
|
+
what the program file's `defaultEnvironments` names, or else every
|
|
43
|
+
environment that declares `conditions`, or `default` when none does;
|
|
44
|
+
`nuka do` without `--env` uses `default`. `nuka run --env a --env
|
|
45
|
+
b` runs every selected scenario in `a`, then in `b`, as one run: the
|
|
46
|
+
verdict table holds one cell per criterion and environment, and a
|
|
47
|
+
failure's `do:` names its environment. A cell that reads `·` never ran:
|
|
48
|
+
its `reason`, and the `hook-failed` or `program-start-failed` finding
|
|
49
|
+
beside it, say why. What each verdict of the table means, and what to do
|
|
50
|
+
about it, is `references/verdicts.md`.
|
|
51
|
+
|
|
52
|
+
Trial and error (`nuka do` while building a step, `nuka run` while
|
|
53
|
+
getting a feature green) belongs on a verification environment; never
|
|
54
|
+
point `--env` at a production-pointing name. `policy: "read-only"`
|
|
55
|
+
backstops that mistake and does not replace picking the right environment:
|
|
56
|
+
it refuses a `mutates: true` step before it runs, and a `mutates: true`
|
|
57
|
+
part a step calls, whatever the calling step declared about itself.
|
|
58
|
+
|
|
59
|
+
## Before running
|
|
60
|
+
|
|
61
|
+
`nuka check <feature>` catches every static inconsistency it can, before
|
|
62
|
+
anything executes. Among them: a step whose `from` key has no producing
|
|
63
|
+
step earlier in that scenario, or has two of them competing, which a run
|
|
64
|
+
finds only when the consuming step runs. A step whose fixtures build `page`, `context`, `pageAs`, or `request` in a
|
|
65
|
+
project that has not installed `playwright` is `playwright-missing`, with
|
|
66
|
+
the install line, so the run stops before it starts. A step file that
|
|
67
|
+
imports `playwright/test` (or `playwright-core`, `@playwright/test`)
|
|
68
|
+
without the package installed is `playwright-missing` too, named at the
|
|
69
|
+
step file instead of `step-file-import-failed`; the one install line fixes
|
|
70
|
+
every file in the group. A step file that reaches the package through
|
|
71
|
+
another project file is the same finding, and the message names that file. A line in a configured env file that is not a blank, a comment, or
|
|
72
|
+
a binding is `env-file-skipped-line`. Compat glue that
|
|
73
|
+
declares a done() callback is `done-callback-arity`. The finding covers a
|
|
74
|
+
hook whose parameter count is past what the executor passes, and a matched
|
|
75
|
+
compat step whose function takes more arguments than the line's captures
|
|
76
|
+
plus a table or docstring. A `"pending"` or `"skipped"` return is still
|
|
77
|
+
only visible to `nuka run`. `nuka check --codes` names every finding
|
|
78
|
+
code `check` can produce: read the catalog there, not a list elsewhere.
|
|
79
|
+
|
|
80
|
+
A bare `nuka check` covers `featuresDir` and `additionalFeatureDirs` ("The
|
|
81
|
+
loop" in `SKILL.md`, step 6); pass any other feature path directly, or the
|
|
82
|
+
one file you care about goes unchecked. `nuka check` takes the targets
|
|
83
|
+
`nuka run` takes (several files, or a directory) and selects the same
|
|
84
|
+
files, so `nuka check <targets>` reports the errors `nuka run <targets>`
|
|
85
|
+
would stop on. `:line` belongs to `nuka run`. Notes and `--fail-on`:
|
|
86
|
+
`maintenance.md`.
|
|
87
|
+
|
|
88
|
+
The walk that finds those feature files skips `node_modules` and any
|
|
89
|
+
directory whose name starts with `.`, at every depth: a `.feature` file
|
|
90
|
+
there is not checked and not run, and the skip reports nothing.
|
|
91
|
+
|
|
92
|
+
## Running
|
|
93
|
+
|
|
94
|
+
1. Commit before the run you report: the run summary names the commit and
|
|
95
|
+
whether the tree had uncommitted changes, which tells the reviewer a run
|
|
96
|
+
may not match the pull request. Debugging against a dirty tree is fine.
|
|
97
|
+
2. `nuka run <feature>`, repeat until every scenario is green. It first
|
|
98
|
+
reports what `nuka check` reports for the selected scenarios and exits 2
|
|
99
|
+
before executing anything on an error (a failed scenario exits 1, so 2
|
|
100
|
+
always means nothing ran); `--no-check` skips that check to run a
|
|
101
|
+
scenario `check` refuses. stderr prints a boundary line per scenario, one
|
|
102
|
+
line per step as it finishes, and, once the run ends, every path it
|
|
103
|
+
actually wrote plus a summary line. A failed step adds its error's first
|
|
104
|
+
line and its step record path, and each failed scenario gets a
|
|
105
|
+
`scenario-failed` finding after the summary, whose `do:` line reruns it.
|
|
106
|
+
stdout is empty unless you ask: `--records` writes NDJSON there, one
|
|
107
|
+
scenario's `run.json` entry per line, and `run.json` is on disk either
|
|
108
|
+
way. To act on the result, pass `--json` instead: stdout is then
|
|
109
|
+
`run.json` itself, one envelope `{ schema_version, nukadoko, command,
|
|
110
|
+
verdict, findings, ... }` with the run's fields beside `findings`
|
|
111
|
+
(`commit`, `environments`, `selection`, `order`, counts, `table`, and per
|
|
112
|
+
scenario its `role`, steps with `line`, `status`, `record`, a failed
|
|
113
|
+
one's `error` and `used`, and a failed scenario's `do`); the run writes
|
|
114
|
+
the same bytes beside its summary, which is rendered from it. nukadoko
|
|
115
|
+
then writes nothing to stderr: every warning and failed scenario is a
|
|
116
|
+
finding. Only Node's own process warnings and a step's own output reach
|
|
117
|
+
it: a `MODULE_TYPELESS_PACKAGE_JSON` warning goes with
|
|
118
|
+
`package-type-missing` (a note), and under `"type": "commonjs"` a "Failed
|
|
119
|
+
to load the ES module" warning goes with `step-file-import-failed`
|
|
120
|
+
(`config-invalid` for the config). Text a step, hook, or fixture writes
|
|
121
|
+
through `console.log` or `process.stdout.write` goes to stderr; a child
|
|
122
|
+
process spawned with `stdio: "inherit"` still writes to stdout. The run
|
|
123
|
+
also writes a Markdown run summary for the person reviewing it, to
|
|
124
|
+
`.nukadoko/runs/<run_id>/summary.md` (the `summary` line names it), and
|
|
125
|
+
to `$GITHUB_STEP_SUMMARY` when that is set; `nuka report --format
|
|
126
|
+
markdown --out <path>` writes it again for a CI step that posts it as a
|
|
127
|
+
pull request comment. A compat World constructor that throws fails that
|
|
128
|
+
scenario only: stderr gets one setup line and no step record, and later
|
|
129
|
+
scenarios still run. With no target, `nuka run` runs `featuresDir`, which
|
|
130
|
+
is what `npm run test:scenarios` does. When a scenario fails, diagnose it
|
|
131
|
+
(`references/diagnosing.md`) before running the whole feature again.
|
|
132
|
+
`<feature>:<line>` or `--tag <expression>` narrows while iterating, but
|
|
133
|
+
end on a run of the whole feature: a partial run's summary covers only
|
|
134
|
+
what it selected and says `selection: partial` in its header, as
|
|
135
|
+
run.json's `selection` does; stderr does not.
|
|
136
|
+
3. A failure that reproduces one time in several is a case for
|
|
137
|
+
`nuka run <feature>:<line> --repeat <n>`, not for a shell loop: every
|
|
138
|
+
execution lands under one run id, its summary cell counts them
|
|
139
|
+
(`pass (3 runs)`, or `flaky@12 (3 runs)` when they disagree), and a
|
|
140
|
+
scenario that failed at least once gets a `repeat` line after the
|
|
141
|
+
failed list, `<passed> of <n> passed`. Read the failing executions'
|
|
142
|
+
records and screenshots (`references/diagnosing.md`): the count says
|
|
143
|
+
how often, never why.
|
|
144
|
+
4. A green run proves only the order it ran in: an environment's
|
|
145
|
+
scenarios share one world, so one can pass on data an earlier one left.
|
|
146
|
+
Before reporting a feature of several scenarios, run it again with
|
|
147
|
+
`--order shuffled`. A failed scenario's `do:` line replays what ran
|
|
148
|
+
before it: red again there is an order dependence. Delete the line's
|
|
149
|
+
targets to find the scenario it depends on, and make it stand alone: a
|
|
150
|
+
Given for what it needs, and no claim on what others leave behind.
|
|
151
|
+
|
|
152
|
+
## The pull request
|
|
153
|
+
|
|
154
|
+
Push the feature and its steps and open the pull request. CI runs the
|
|
155
|
+
feature and posts the run summary on it (`docs/ci.md` in the nukadoko
|
|
156
|
+
package has the workflow) from `nuka run --base <the base>`: its table
|
|
157
|
+
says what changed in each criterion since the base and whether a world
|
|
158
|
+
where the behaviour is absent shows its Then failing
|
|
159
|
+
(`references/verdicts.md`). In a shallow clone, fetch the base first;
|
|
160
|
+
the refusal's `do:` line is the command.
|
|
161
|
+
A person reads the feature and the summary: the run is the evidence. The
|
|
162
|
+
team records the approval where it records approvals; nukadoko writes or
|
|
163
|
+
commits nothing else for it. Whether the criteria still hold later is a
|
|
164
|
+
question for the next CI run, not the old summary, and a failed run that
|
|
165
|
+
a later run fixed is history the pull request can show.
|
|
166
|
+
|
|
167
|
+
## What a run writes
|
|
168
|
+
|
|
169
|
+
`nuka run` writes its records, `run.json`, and the run summary, and no
|
|
170
|
+
report. `nuka report` renders a finished run afterwards, from the run
|
|
171
|
+
directory alone, so a run directory downloaded from CI renders too:
|
|
172
|
+
|
|
173
|
+
```sh
|
|
174
|
+
nuka report --format allure # .nukadoko/export/allure-results/
|
|
175
|
+
nuka report --format messages --out messages.ndjson
|
|
176
|
+
nuka report --format markdown # the run summary, on stdout
|
|
177
|
+
nuka report .nukadoko/runs/<run_id> --format allure --out reports/allure
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
With no run directory it renders the newest run; stderr names what it wrote.
|
|
181
|
+
|
|
182
|
+
Open the two report formats for different reasons. Allure is nukadoko's
|
|
183
|
+
own dashboard: every step's trace, HTTP log, validated result, and a
|
|
184
|
+
timeline of what it waited for and clicked, with zero project wiring.
|
|
185
|
+
Render it with Allure's own CLI: `npx allure watch <dir> --output
|
|
186
|
+
<report-dir>` picks up each render while you iterate, and `npx allure
|
|
187
|
+
generate` and `npx allure open` serve a finished one. Nukadoko never renders
|
|
188
|
+
HTML itself. The messages stream is for the opposite reason: feeding a
|
|
189
|
+
suite's existing cucumber-js-era formatter or JUnit-based CI while it
|
|
190
|
+
migrates, not for reading by hand. It leaves out every control, so JUnit
|
|
191
|
+
reads a green run as green; under `--base` an `unproven` or `moved` row is
|
|
192
|
+
no failure there, so gate on the exit code. Allure keeps a control as
|
|
193
|
+
`<scenario> (control)`, failed if it was.
|
|
194
|
+
|
|
195
|
+
Rendering the same run again replaces what its last render wrote under
|
|
196
|
+
`<stateDir>/export/`. Those files leave with their run: `nuka run` keeps the
|
|
197
|
+
newest `retention.runs` runs (default 20) and removes older ones with their
|
|
198
|
+
export files at the end of every run, printing one `retention:` line when it
|
|
199
|
+
did. `nuka clean` removes all of them at once. A report written with `--out`
|
|
200
|
+
outside `export/` and `runs/` is yours to keep.
|
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
# Writing a scenario that can be wrong
|
|
2
|
+
|
|
3
|
+
The criteria are fixed before the implementation exists, so a scenario is
|
|
4
|
+
evidence only if nothing in it came from the implementation. Each rule
|
|
5
|
+
below says what to write, shows the weak form and the strong form, and
|
|
6
|
+
names the finding that enforces it, or says `review` when no check can
|
|
7
|
+
decide it without guessing. `examples/` beside this file holds three
|
|
8
|
+
finished projects (`cli.md`, `http-api.md`, `workflow.md`) that follow
|
|
9
|
+
every rule, with the output of real runs.
|
|
10
|
+
|
|
11
|
+
## S1. A Then claims a value, not a verdict
|
|
12
|
+
|
|
13
|
+
Bad: `Then the command succeeds`, `Then the output contains "food"`.
|
|
14
|
+
Good: `Then it exits with 0`, then `And the output is` with the exact
|
|
15
|
+
lines in a docstring. The step declares claims, and each expected value
|
|
16
|
+
is a key the sentence fills or a literal its fixed words state:
|
|
17
|
+
`defineStep` refuses `{ literal: 0 }` under "the command succeeds", and
|
|
18
|
+
`Then the list is empty` may claim `[]`.
|
|
19
|
+
Checked by: `then-without-claims` for a Then bound to a step that runs,
|
|
20
|
+
and `claim-compares-itself` for a claim whose two sides are one value;
|
|
21
|
+
whether the sentence says enough is review.
|
|
22
|
+
|
|
23
|
+
## S2. Every scenario has a Then, after the When
|
|
24
|
+
|
|
25
|
+
Bad: a scenario of a Given and a When. It runs green and gates nothing.
|
|
26
|
+
Good: at least one Then line, last.
|
|
27
|
+
Checked by: `scenario-without-then` for a scenario with no Then line,
|
|
28
|
+
one of only `*` lines, or one whose Then lines bind no claim step;
|
|
29
|
+
`from-order-violation` for a Then that reads a step placed after it,
|
|
30
|
+
`events-producer-missing` for one that counts that step's execution events,
|
|
31
|
+
and `files-producer-missing` for one that reads the files its commands changed.
|
|
32
|
+
|
|
33
|
+
## S3. Expected values come from the criteria, never from a run
|
|
34
|
+
|
|
35
|
+
Bad: run the program, paste what it printed into the docstring, run green.
|
|
36
|
+
Good: the docstring holds the example the criteria gave. When the criteria
|
|
37
|
+
give none, write the question beside the scenario and stop. When the run
|
|
38
|
+
is red, the implementation or the criteria are wrong; the docstring is not
|
|
39
|
+
edited to match without the person's word.
|
|
40
|
+
Checked by: review, and the loop's order: the feature is written before
|
|
41
|
+
the first `nuka run`.
|
|
42
|
+
|
|
43
|
+
## S4. The sentence names what a user sees
|
|
44
|
+
|
|
45
|
+
Bad: `Then the users Map has one entry with confirmed = true`.
|
|
46
|
+
Good: `Then the sign-in is accepted`.
|
|
47
|
+
Bad: `When the POST handler is called with {"name":"lamp"}`.
|
|
48
|
+
Good: `When I POST this body to /items`, the body in a docstring. The
|
|
49
|
+
route is the public surface of an API; a handler, a table, or a Map is
|
|
50
|
+
not. The mechanism lives in the step file and can change without the
|
|
51
|
+
sentence.
|
|
52
|
+
Checked by: review.
|
|
53
|
+
|
|
54
|
+
## S5. Values live in the sentence, the table, or the docstring
|
|
55
|
+
|
|
56
|
+
Bad: a step whose `run()` holds `"correct horse"`.
|
|
57
|
+
Good: `a registration for {email:string} with password {password:string}
|
|
58
|
+
is submitted`. The reviewer sees every value the scenario depends on.
|
|
59
|
+
Checked by: `unknown-capture-key` and `unfillable-required-key` keep the
|
|
60
|
+
pattern and `args` together; a literal inside `run()` is review.
|
|
61
|
+
|
|
62
|
+
## S6. A negative path is its own scenario and claims the exact refusal
|
|
63
|
+
|
|
64
|
+
Bad: `Then the registration fails`.
|
|
65
|
+
Good: `Then the registration is refused because "email already
|
|
66
|
+
registered"`. The When step returns the outcome (`outcome: "refused"`,
|
|
67
|
+
`reason`) and does not throw on a refusal, so the Then claims both
|
|
68
|
+
through `from`.
|
|
69
|
+
Checked by: review.
|
|
70
|
+
|
|
71
|
+
## S7. Each Outline row is told apart by its name
|
|
72
|
+
|
|
73
|
+
Bad: `Scenario Outline: a bad request body` over three rows: the run
|
|
74
|
+
summary lists the same name three times.
|
|
75
|
+
Good: `Scenario Outline: a bad request body: <body> answers <status>`;
|
|
76
|
+
the run prints `a bad request body: {} answers 422`.
|
|
77
|
+
Checked by: `outline-rows-share-name`.
|
|
78
|
+
|
|
79
|
+
## S8. A scenario starts from nothing it did not establish
|
|
80
|
+
|
|
81
|
+
Bad: scenario 2 reads the item scenario 1 created. The server
|
|
82
|
+
`nukadoko.program.ts` starts serves every scenario of the run, as a
|
|
83
|
+
fixture with `scope: "process"` does. Measured in `examples/http-api.md`:
|
|
84
|
+
the read got `{"id":2,"name":"lamp"}` where the feature expected id 1.
|
|
85
|
+
Good: `Given an item named "lamp" exists` in the scenario that reads it,
|
|
86
|
+
and claims on what the scenario created (the body the Given returned),
|
|
87
|
+
never on everything the server holds. A fixture that holds state is
|
|
88
|
+
scoped per scenario; `scope: "process"` is for a resource no scenario
|
|
89
|
+
writes to, or one each scenario resets.
|
|
90
|
+
Checked by: `state-missing` when a line's step requires a state no
|
|
91
|
+
earlier line of the scenario gives (`states.md`), and review.
|
|
92
|
+
`repeated-scenario-prefix` names a process-scope fixture only when every
|
|
93
|
+
shared step declares `mutates: false`; for any other opening it names the
|
|
94
|
+
step that may write.
|
|
95
|
+
|
|
96
|
+
## S9. One action per scenario, one claim per Then line
|
|
97
|
+
|
|
98
|
+
Bad: `Then it exits with 0 and prints "food: 5.5"`.
|
|
99
|
+
Good: `Then it exits with 0` and `And the output is` on two lines: two
|
|
100
|
+
step records, two failure messages, two things a reviewer can read.
|
|
101
|
+
Checked by: review.
|
|
102
|
+
|
|
103
|
+
## S10. A Given establishes; the When is the action under test
|
|
104
|
+
|
|
105
|
+
Bad: `Given I run tally with "missing.csv"`, then `Then it exits with 2`.
|
|
106
|
+
Good: `Given an empty directory`, `When I run tally with "missing.csv"`.
|
|
107
|
+
The same step can be the When of one scenario and a Given of another: a
|
|
108
|
+
registration is the action in "a short password" and the setup in "sign
|
|
109
|
+
in before confirming". The keyword says which it is in this scenario.
|
|
110
|
+
A scenario that breaks a rule on purpose, such as signing in before
|
|
111
|
+
confirming, uses a step that does not require what the rule demands
|
|
112
|
+
(`states.md`).
|
|
113
|
+
Checked by: `from-order-violation` when the action written as a Given has
|
|
114
|
+
no Given before it to read from (`examples/cli.md`),
|
|
115
|
+
`claims-outside-then` for a claim step in Given or When position, and
|
|
116
|
+
`then-without-claims` for a step that runs in Then position; the rest is
|
|
117
|
+
review.
|
|
118
|
+
|
|
119
|
+
## S11. A failing step says what it saw on its first line
|
|
120
|
+
|
|
121
|
+
`nuka run` prints the first line of the error beside the failed step; the
|
|
122
|
+
rest is in the step record. A Then gets this from its claims: a broken
|
|
123
|
+
claim's line names both values and where each came from. Measured in
|
|
124
|
+
`examples/cli.md`: `claim broken: "food: 5.5\nrent: 100"
|
|
125
|
+
(from:run-tally@16.stdout as text) equal "food: 5.5\nrent: 101"
|
|
126
|
+
(sentence:expected); first difference at line 2: actual "rent: 100",
|
|
127
|
+
expected "rent: 101"`.
|
|
128
|
+
Bad: a Given or a When that throws `new Error("setup failed")`, which
|
|
129
|
+
prints nothing it saw.
|
|
130
|
+
Good: a message that names what it saw, such as the exit code and the
|
|
131
|
+
first line of stderr of the program the Given ran.
|
|
132
|
+
Checked by: review.
|
|
133
|
+
|
|
134
|
+
## S12. The criteria sit under `Feature:`, verbatim, and each scenario proves one
|
|
135
|
+
|
|
136
|
+
Bad: a feature whose free text paraphrases the ticket, or a scenario no
|
|
137
|
+
criterion asks for.
|
|
138
|
+
Good: the criteria copied as written under `Feature:`
|
|
139
|
+
(`writing-the-feature.md`), and every scenario traceable to one of them.
|
|
140
|
+
A scenario no criterion produced is a missing criterion (ask) or not
|
|
141
|
+
acceptance (delete).
|
|
142
|
+
Checked by: review.
|
|
143
|
+
|
|
144
|
+
## Shapes that come up
|
|
145
|
+
|
|
146
|
+
- **A program's input file.** The Given writes it under `scratch.dir()`
|
|
147
|
+
and returns the directory; the When runs the program with that
|
|
148
|
+
directory as `cwd`, read through `from` (`nuka scaffold --command
|
|
149
|
+
--from <given>.dir --cwd dir`). Each `scratch.dir()` call is a new
|
|
150
|
+
directory, so a step that makes its own never sees a file a Given wrote.
|
|
151
|
+
- **Arguments.** One `{argv:string}` capture split on whitespace
|
|
152
|
+
(`nuka scaffold --command --argv argv`, no quoting) keeps one When step
|
|
153
|
+
for every flag; one capture per argument keeps the sentence closer to
|
|
154
|
+
prose, and is the shape for an argument that holds a space. Pick one
|
|
155
|
+
per project and keep it.
|
|
156
|
+
- **An HTTP API.** `nukadoko.program.ts` starts the server and the steps
|
|
157
|
+
read its URL from `baseURL`. One request step per sentence the reviewer
|
|
158
|
+
reads (`I request that item`, `I request the item list`), each returning
|
|
159
|
+
`status` and `body`; a Then lists every request step in `from`. A slash in a
|
|
160
|
+
pattern is escaped: `I POST this body to \/items`.
|
|
161
|
+
- **Outline or scenarios.** An Outline when the rows differ only in values
|
|
162
|
+
and share every sentence; separate scenarios when a row needs its own
|
|
163
|
+
sentence. A Background holds a Given that every scenario of the file
|
|
164
|
+
shares, and nothing else.
|
|
165
|
+
- **The same producer twice.** When a step runs twice in one scenario, a
|
|
166
|
+
`from` that names it reads the most recent result.
|
|
167
|
+
|
|
168
|
+
## How this file grows
|
|
169
|
+
|
|
170
|
+
A lesson from a real run is promoted in three stages, and each stage
|
|
171
|
+
replaces the one before it:
|
|
172
|
+
|
|
173
|
+
1. **An example row.** Add the decision to the "Decisions" table of the
|
|
174
|
+
example for that kind of project (`examples/<shape>.md`): the date, the
|
|
175
|
+
decision, what was chosen, and why. Add a new example file when no
|
|
176
|
+
existing shape fits.
|
|
177
|
+
2. **A rule here.** A decision becomes a rule when it comes up in a second
|
|
178
|
+
example or a second project, or when a red run traced back to its
|
|
179
|
+
absence. A rule has a `Bad:`, a `Good:`, and a `Checked by:` line; the
|
|
180
|
+
test suite refuses a rule without all three.
|
|
181
|
+
3. **A finding code.** A rule that `nuka check` can decide
|
|
182
|
+
from the feature file and the step contracts alone, with no guess about
|
|
183
|
+
intent, becomes a code. The rule then names that code on its
|
|
184
|
+
`Checked by:` line, and the code's own `fix:` carries the edit.
|
|
185
|
+
|
|
186
|
+
This file stays at 200 lines or fewer and `SKILL.md` at 120, both enforced
|
|
187
|
+
by a test. When a rule does not fit, remove one: a rule that no example
|
|
188
|
+
has cited for two releases, and that no code enforces, is the first to go.
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
# States a step requires, gives, and ends
|
|
2
|
+
|
|
3
|
+
Some steps need what an earlier line did rather than a value it returned:
|
|
4
|
+
a person signed in, a tab in the room, a book open on the page. `from`
|
|
5
|
+
cannot carry that, because nothing is returned. Declare it as a state, and
|
|
6
|
+
`nuka check` judges the order of the lines before any browser opens.
|
|
7
|
+
|
|
8
|
+
## Declaring one
|
|
9
|
+
|
|
10
|
+
```ts
|
|
11
|
+
requires: [["signed-in", "person"]], // on the step that cannot work without it
|
|
12
|
+
gives: [["signed-in", "person"]], // on the step that leaves it holding
|
|
13
|
+
ends: [["signed-in", "person"]], // on the step that undoes it
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
The second element names the args key whose value tells holders apart, so
|
|
17
|
+
aki signed in says nothing about ben. A state one reader holds is the bare
|
|
18
|
+
name: `requires: ["book-open"]`. Write each state the same way in every
|
|
19
|
+
step, keyed everywhere or bare everywhere; `state-shape-mismatch` names
|
|
20
|
+
the steps that differ. A claim step may `requires`; it has no `gives` or
|
|
21
|
+
`ends`, because it changes nothing.
|
|
22
|
+
|
|
23
|
+
Three rules decide what to declare:
|
|
24
|
+
|
|
25
|
+
- `requires` is what the step's own `run` or `observe` cannot do its work
|
|
26
|
+
without, whatever the program does: the button it clicks is not there,
|
|
27
|
+
the tab does not exist. It is never a business rule a scenario breaks on
|
|
28
|
+
purpose to see the program refuse. That scenario uses a step that
|
|
29
|
+
requires nothing ("aki tries to open the settings page").
|
|
30
|
+
- `from` or `requires`: when `run` reads a value an earlier step returned,
|
|
31
|
+
`from`; when it needs only that an earlier line did something,
|
|
32
|
+
`requires`.
|
|
33
|
+
- `gives` covers what the step does through its parts and the fixtures it
|
|
34
|
+
builds. A state every scenario starts with (a seeded account, a context
|
|
35
|
+
fixture that loads a signed-in storage state) is not one a step
|
|
36
|
+
requires: no line gives it.
|
|
37
|
+
|
|
38
|
+
## Composing a scenario with them
|
|
39
|
+
|
|
40
|
+
`nuka steps --json` and `nuka describe <step>` list each step's
|
|
41
|
+
`requires` with `given_by`, the steps with a pattern whose `gives` name
|
|
42
|
+
it: one of those lines goes before the line that requires it, for the
|
|
43
|
+
same holder. A line that ends a state needs the giving line again before
|
|
44
|
+
the next line that requires it.
|
|
45
|
+
|
|
46
|
+
## When `nuka check` reports `state-missing`
|
|
47
|
+
|
|
48
|
+
The finding is at the requiring line and says why it can only run without
|
|
49
|
+
the state: no step gives it (often a typo; the fix lists the names steps
|
|
50
|
+
give), no earlier line gives it to this holder (it names the lines that
|
|
51
|
+
gave it to someone else), or an earlier line ended it. Its `fix:` names
|
|
52
|
+
the line to paste and where. A later line that needs the same state for
|
|
53
|
+
the same holder is folded into it ("line 12 requires it too"): one line
|
|
54
|
+
settles both. When the fix also names an earlier step that "gives it
|
|
55
|
+
without saying so", read that step: if it does sign the person in, add the
|
|
56
|
+
state to its `gives` instead of adding a line.
|
|
57
|
+
|
|
58
|
+
`nuka run` refuses the scenario before any step runs, `--no-check`
|
|
59
|
+
included. Never satisfy the finding by deleting a `requires`: a step that
|
|
60
|
+
truly needs the state fails in the browser instead, minutes later.
|
|
61
|
+
|
|
62
|
+
The check stays silent where it cannot read what happened: after a compat
|
|
63
|
+
step or a line no step matches, when a compat Before or AfterStep hook or
|
|
64
|
+
a custom World applies, and after a composite whose parts give or end the
|
|
65
|
+
state while the composite says nothing (`parts.md`). Silence there is not
|
|
66
|
+
a pass; declare the composite's `gives` so the lines after it are judged.
|