nukadoko 0.5.0 → 0.7.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 +553 -3
- data/README.ja.md +22 -6
- data/README.md +13 -7
- data/docs/ci.ja.md +542 -0
- data/docs/ci.md +635 -0
- data/docs/commands.ja.md +1524 -0
- data/docs/commands.md +1281 -0
- data/docs/engines.json +19 -0
- data/docs/execution-events.ja.md +336 -0
- data/docs/execution-events.md +423 -0
- data/docs/glossary.json +1348 -0
- data/docs/guide.ja.md +733 -0
- data/docs/guide.md +815 -0
- data/docs/intent.ja.md +133 -0
- data/docs/intent.md +156 -0
- data/docs/layout.ja.md +442 -0
- data/docs/layout.md +399 -0
- data/docs/releasing.ja.md +186 -0
- data/docs/releasing.md +237 -0
- data/docs/ruby/reference.ja.md +302 -0
- data/docs/ruby/reference.md +368 -0
- data/docs/spec.ja.md +8916 -0
- data/docs/spec.md +11250 -0
- data/docs/tutorial.ja.md +451 -0
- data/docs/tutorial.md +458 -0
- data/docs/typescript/adopting.ja.md +231 -0
- data/docs/typescript/adopting.md +251 -0
- data/docs/typescript/doors.ja.md +301 -0
- data/docs/typescript/doors.md +329 -0
- data/docs/typescript/migration-playwright-test.ja.md +189 -0
- data/docs/typescript/migration-playwright-test.md +212 -0
- data/docs/typescript/migration.ja.md +391 -0
- data/docs/typescript/migration.md +505 -0
- data/docs/typescript/reference.ja.md +176 -0
- data/docs/typescript/reference.md +197 -0
- data/docs/typescript/upgrading.ja.md +1774 -0
- data/docs/typescript/upgrading.md +2224 -0
- data/docs/web-app.ja.md +627 -0
- data/docs/web-app.md +659 -0
- data/docs/writing-scenarios.ja.md +544 -0
- data/docs/writing-scenarios.md +563 -0
- data/lib/nukadoko/base.rb +12 -5
- data/lib/nukadoko/changed_files.rb +95 -0
- data/lib/nukadoko/check.rb +459 -51
- data/lib/nukadoko/claim_drops.rb +271 -0
- data/lib/nukadoko/claim_line.rb +24 -4
- data/lib/nukadoko/claim_rules.rb +143 -1
- data/lib/nukadoko/claim_sides.rb +157 -9
- data/lib/nukadoko/cli.rb +403 -50
- data/lib/nukadoko/codes.json +246 -21
- data/lib/nukadoko/codes.rb +21 -4
- data/lib/nukadoko/command.rb +120 -13
- data/lib/nukadoko/command_help.rb +128 -0
- data/lib/nukadoko/compat.rb +469 -0
- data/lib/nukadoko/criteria.rb +1 -1
- data/lib/nukadoko/definition.rb +157 -7
- data/lib/nukadoko/error_frames.rb +6 -3
- data/lib/nukadoko/events/count.rb +146 -0
- data/lib/nukadoko/events/counted.rb +114 -0
- data/lib/nukadoko/events/format.rb +257 -0
- data/lib/nukadoko/events/lists.rb +154 -0
- data/lib/nukadoko/events/path.rb +285 -0
- data/lib/nukadoko/events/read.rb +284 -0
- data/lib/nukadoko/events/reader.rb +490 -0
- data/lib/nukadoko/events/selection.rb +252 -0
- data/lib/nukadoko/events/tally.rb +438 -0
- data/lib/nukadoko/features.rb +2 -2
- data/lib/nukadoko/fixtures.rb +160 -35
- data/lib/nukadoko/http_recording.rb +6 -2
- data/lib/nukadoko/intent.rb +364 -0
- data/lib/nukadoko/intent_file.rb +81 -0
- data/lib/nukadoko/intent_view.rb +190 -0
- data/lib/nukadoko/js_json.rb +2 -1
- data/lib/nukadoko/judge.rb +2 -2
- data/lib/nukadoko/judgment_file.rb +22 -1
- data/lib/nukadoko/judgments.rb +33 -3
- data/lib/nukadoko/measure_mcp.rb +202 -0
- data/lib/nukadoko/parts.rb +8 -2
- data/lib/nukadoko/path_view.rb +252 -0
- data/lib/nukadoko/place_rows.rb +161 -0
- data/lib/nukadoko/program.rb +1265 -51
- data/lib/nukadoko/program_log.rb +122 -0
- data/lib/nukadoko/program_shape.rb +385 -0
- data/lib/nukadoko/project_fixtures.rb +43 -10
- data/lib/nukadoko/project_program.rb +5 -4
- data/lib/nukadoko/repeated_prefix.rb +310 -0
- data/lib/nukadoko/report_run.rb +3 -3
- data/lib/nukadoko/run.rb +1156 -159
- data/lib/nukadoko/run_record.rb +70 -46
- data/lib/nukadoko/scaffold.rb +24 -6
- data/lib/nukadoko/schema.rb +15 -2
- data/lib/nukadoko/secrets.rb +55 -5
- data/lib/nukadoko/states.rb +478 -0
- data/lib/nukadoko/step.rb +71 -2
- data/lib/nukadoko/step_fixtures.rb +52 -3
- data/lib/nukadoko/summary.rb +803 -30
- data/lib/nukadoko/table.rb +4 -2
- data/lib/nukadoko/text_fit.rb +20 -7
- data/lib/nukadoko/trace.rb +152 -45
- data/lib/nukadoko/tree_passes.rb +95 -33
- data/lib/nukadoko/underneath.rb +311 -0
- data/lib/nukadoko/verdict.rb +18 -1
- data/lib/nukadoko/version.rb +1 -1
- data/lib/nukadoko/vocabulary.rb +166 -23
- data/lib/nukadoko/walk.rb +2 -2
- data/lib/nukadoko/walk_step.rb +1 -1
- data/lib/nukadoko.rb +23 -0
- data/llms.txt +42 -35
- data/sig/generated/nukadoko/base.rbs +4 -4
- data/sig/generated/nukadoko/changed_files.rbs +42 -0
- data/sig/generated/nukadoko/check.rbs +147 -10
- data/sig/generated/nukadoko/claim_drops.rbs +135 -0
- data/sig/generated/nukadoko/claim_line.rbs +11 -0
- data/sig/generated/nukadoko/claim_rules.rbs +49 -4
- data/sig/generated/nukadoko/claim_sides.rbs +63 -12
- data/sig/generated/nukadoko/cli.rbs +80 -7
- data/sig/generated/nukadoko/codes.rbs +19 -4
- data/sig/generated/nukadoko/command.rbs +68 -1
- data/sig/generated/nukadoko/command_help.rbs +18 -0
- data/sig/generated/nukadoko/compat.rbs +392 -0
- data/sig/generated/nukadoko/criteria.rbs +1 -1
- data/sig/generated/nukadoko/definition.rbs +50 -0
- data/sig/generated/nukadoko/error_frames.rbs +1 -1
- data/sig/generated/nukadoko/events/count.rbs +69 -0
- data/sig/generated/nukadoko/events/counted.rbs +70 -0
- data/sig/generated/nukadoko/events/format.rbs +163 -0
- data/sig/generated/nukadoko/events/lists.rbs +47 -0
- data/sig/generated/nukadoko/events/path.rbs +161 -0
- data/sig/generated/nukadoko/events/read.rbs +109 -0
- data/sig/generated/nukadoko/events/reader.rbs +226 -0
- data/sig/generated/nukadoko/events/selection.rbs +100 -0
- data/sig/generated/nukadoko/events/tally.rbs +227 -0
- data/sig/generated/nukadoko/features.rbs +6 -4
- data/sig/generated/nukadoko/fixtures.rbs +67 -11
- data/sig/generated/nukadoko/http_recording.rbs +1 -1
- data/sig/generated/nukadoko/intent.rbs +132 -0
- data/sig/generated/nukadoko/intent_file.rbs +46 -0
- data/sig/generated/nukadoko/intent_view.rbs +69 -0
- data/sig/generated/nukadoko/judgment_file.rbs +7 -1
- data/sig/generated/nukadoko/judgments.rbs +10 -0
- data/sig/generated/nukadoko/measure_mcp.rbs +104 -0
- data/sig/generated/nukadoko/parts.rbs +2 -2
- data/sig/generated/nukadoko/path_view.rbs +105 -0
- data/sig/generated/nukadoko/place_rows.rbs +43 -0
- data/sig/generated/nukadoko/program.rbs +627 -23
- data/sig/generated/nukadoko/program_log.rbs +67 -0
- data/sig/generated/nukadoko/program_shape.rbs +147 -0
- data/sig/generated/nukadoko/project_fixtures.rbs +16 -3
- data/sig/generated/nukadoko/project_program.rbs +2 -1
- data/sig/generated/nukadoko/repeated_prefix.rbs +172 -0
- data/sig/generated/nukadoko/report_run.rbs +1 -1
- data/sig/generated/nukadoko/run.rbs +286 -41
- data/sig/generated/nukadoko/run_record.rbs +20 -12
- data/sig/generated/nukadoko/scaffold.rbs +3 -0
- data/sig/generated/nukadoko/schema.rbs +5 -0
- data/sig/generated/nukadoko/secrets.rbs +26 -3
- data/sig/generated/nukadoko/states.rbs +214 -0
- data/sig/generated/nukadoko/step.rbs +58 -1
- data/sig/generated/nukadoko/step_fixtures.rbs +39 -0
- data/sig/generated/nukadoko/summary.rbs +256 -2
- data/sig/generated/nukadoko/table.rbs +3 -2
- data/sig/generated/nukadoko/trace.rbs +108 -33
- data/sig/generated/nukadoko/tree_passes.rbs +36 -8
- data/sig/generated/nukadoko/underneath.rbs +141 -0
- data/sig/generated/nukadoko/verdict.rbs +8 -0
- data/sig/generated/nukadoko/vocabulary.rbs +45 -6
- data/skills/nukadoko/SKILL.md +18 -18
- data/skills/nukadoko/references/checking-steps.md +16 -83
- data/skills/nukadoko/references/diagnosing.md +6 -6
- data/skills/nukadoko/references/done.md +22 -0
- data/skills/nukadoko/references/evidence.md +19 -6
- data/skills/nukadoko/references/exploring.md +22 -7
- data/skills/nukadoko/references/fixtures.md +12 -32
- data/skills/nukadoko/references/judgments.md +18 -0
- data/skills/nukadoko/references/maintenance.md +1 -1
- data/skills/nukadoko/references/merge-risk.md +1 -1
- data/skills/nukadoko/references/parts.md +46 -23
- data/skills/nukadoko/references/{perturbed-worlds.md → perturbed-systems.md} +30 -12
- data/skills/nukadoko/references/program.md +168 -169
- data/skills/nukadoko/references/reviewing.md +20 -20
- data/skills/nukadoko/references/ruby/checking-steps.md +106 -0
- data/skills/nukadoko/references/ruby/examples/cli.md +212 -0
- data/skills/nukadoko/references/ruby/fixtures.md +34 -0
- data/skills/nukadoko/references/ruby/program.md +112 -0
- data/skills/nukadoko/references/ruby/step-files.md +115 -0
- data/skills/nukadoko/references/running.md +34 -34
- data/skills/nukadoko/references/scenario-rules.md +7 -6
- data/skills/nukadoko/references/states.md +7 -1
- data/skills/nukadoko/references/step-files.md +41 -120
- data/skills/nukadoko/references/typescript/checking-steps.md +129 -0
- data/skills/nukadoko/references/{examples → typescript/examples}/cli.md +1 -1
- data/skills/nukadoko/references/{examples → typescript/examples}/http-api.md +6 -6
- data/skills/nukadoko/references/{examples → typescript/examples}/workflow.md +1 -1
- data/skills/nukadoko/references/typescript/fixtures.md +56 -0
- data/skills/nukadoko/references/typescript/program.md +111 -0
- data/skills/nukadoko/references/typescript/step-files.md +104 -0
- data/skills/nukadoko/references/verdicts.md +10 -10
- data/skills/nukadoko/references/writing-steps.md +67 -67
- data/skills/nukadoko/references/writing-the-feature.md +1 -1
- data/skills/nukadoko-verification/SKILL.md +13 -8
- metadata +103 -7
- data/skills/nukadoko/references/ruby.md +0 -80
data/docs/guide.md
ADDED
|
@@ -0,0 +1,815 @@
|
|
|
1
|
+
# The nukadoko guide
|
|
2
|
+
|
|
3
|
+
The [README](../README.md) says what nukadoko is, walks a first scenario,
|
|
4
|
+
explains how a run is judged, and puts it in CI in one step. This guide
|
|
5
|
+
holds the rest of what a project meets while it uses nukadoko. The design
|
|
6
|
+
itself is in [spec.md](spec.md).
|
|
7
|
+
|
|
8
|
+
- [An HTTP API](#an-http-api) and [Calling the program with fetch](#calling-the-program-with-fetch)
|
|
9
|
+
- [Setup details](#setup-details), [Upgrading](#upgrading), and [Secrets need no manifest](#secrets-need-no-manifest)
|
|
10
|
+
- [Before / after](#before--after) and [What it fixes](#what-it-fixes)
|
|
11
|
+
- [Reports fill themselves](#reports-fill-themselves)
|
|
12
|
+
- [Self-healing, with the deviation on the record](#self-healing-with-the-deviation-on-the-record)
|
|
13
|
+
- [The compat door](#the-compat-door) and [Try it against your own suite first](#try-it-against-your-own-suite-first)
|
|
14
|
+
- [CI runs in depth](#ci-runs-in-depth)
|
|
15
|
+
- [The bed has to be tended](#the-bed-has-to-be-tended)
|
|
16
|
+
|
|
17
|
+
## An HTTP API
|
|
18
|
+
|
|
19
|
+
The program under test is described by the config's `program`, a
|
|
20
|
+
function that returns how the program starts. nukadoko starts it for each run
|
|
21
|
+
on a free port of its own, waits until it answers, sends every step's
|
|
22
|
+
requests there, and stops it after the scenarios:
|
|
23
|
+
|
|
24
|
+
```ruby
|
|
25
|
+
# nukadoko.config.rb
|
|
26
|
+
Nukadoko.config(
|
|
27
|
+
program: -> {
|
|
28
|
+
{
|
|
29
|
+
serve: { command: "ruby src/server.rb" },
|
|
30
|
+
env: { PORT: "{port}" },
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
)
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
```ts
|
|
37
|
+
// nukadoko.config.ts
|
|
38
|
+
import { defineConfig } from "nukadoko";
|
|
39
|
+
|
|
40
|
+
export default defineConfig({
|
|
41
|
+
program: () => ({
|
|
42
|
+
serve: { command: "node src/server.ts" },
|
|
43
|
+
env: { PORT: "{port}" },
|
|
44
|
+
}),
|
|
45
|
+
});
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
`{port}` is the port nukadoko picked, and the program listens where `PORT`
|
|
49
|
+
says. The command is split on whitespace and runs with no shell. The
|
|
50
|
+
program is ready once `/` answers 2xx; `serve.ready` names another path.
|
|
51
|
+
A line on stderr names the URL and `program.log`, which holds what the
|
|
52
|
+
program printed, beside the run's records. `port: "auto"`, the default,
|
|
53
|
+
picks a free port when the system starts. Two runs at once can still race
|
|
54
|
+
for the same one: a server that then cannot listen and exits fails its
|
|
55
|
+
system, or, when the other run's server already answered its ready check,
|
|
56
|
+
is reported as `program-exited` when the system stops. In the TypeScript
|
|
57
|
+
engine the program also takes `build` and `prepare` commands, a directory
|
|
58
|
+
of its own for each run's database (`{dir}`), and `url` for a server
|
|
59
|
+
nukadoko does not start: "Program" in [docs/spec.md](spec.md#program)
|
|
60
|
+
has every field.
|
|
61
|
+
|
|
62
|
+
Here the server answers `/greet/<name>` with the text `Hello, <name>!`. With this feature:
|
|
63
|
+
|
|
64
|
+
```gherkin
|
|
65
|
+
# features/greet.feature
|
|
66
|
+
Feature: greet API
|
|
67
|
+
|
|
68
|
+
Scenario: greets by name
|
|
69
|
+
When I request the greeting for "Ada"
|
|
70
|
+
Then the greeting is "Hello, Ada!"
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
scaffold the When step and its Then, and the scenario runs with no edit.
|
|
74
|
+
The When step sends its request through the `request` fixture. In
|
|
75
|
+
TypeScript that is Playwright's `request`, so install `playwright` too
|
|
76
|
+
([Install](../README.md#install)).
|
|
77
|
+
|
|
78
|
+
```sh
|
|
79
|
+
nuka scaffold get-greeting --pattern "I request the greeting for {name:string}" --request "GET /greet/{name}"
|
|
80
|
+
nuka scaffold greeting-is --pattern "the greeting is {text:string}" --then --from get-greeting.body
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
`get-greeting` is one `GET` call on `request` that returns `status` and
|
|
84
|
+
`body` (the response text). Each request
|
|
85
|
+
lands in the step record's `http.jsonl`.
|
|
86
|
+
|
|
87
|
+
`--request "<METHOD> <path>"` resolves the path against the program's
|
|
88
|
+
URL. Each `{key}` in the path is that args key's value, put in as it is,
|
|
89
|
+
and `--body <key>` sends an args key (the line's `docstring`, say) as the
|
|
90
|
+
request's data. A value the request does not read throws by name until
|
|
91
|
+
it is placed. The step declares that it mutates: the method is a proxy for write
|
|
92
|
+
semantics, so the author says when it does not.
|
|
93
|
+
|
|
94
|
+
## Calling the program with fetch
|
|
95
|
+
|
|
96
|
+
A step can call the program with the language's own HTTP client instead
|
|
97
|
+
(`Net::HTTP` in Ruby, `fetch` in TypeScript), which needs nothing
|
|
98
|
+
installed. `base_url` (`baseURL` in TypeScript) is the URL of the program
|
|
99
|
+
nukadoko started, from the program above:
|
|
100
|
+
|
|
101
|
+
```ruby
|
|
102
|
+
# features/steps/get_greeting.rb
|
|
103
|
+
class GetGreeting < Nukadoko::Step
|
|
104
|
+
description "GET /greet/<name> from the program under test"
|
|
105
|
+
pattern "I request the greeting for {name:string}"
|
|
106
|
+
args { string :name }
|
|
107
|
+
returns do
|
|
108
|
+
number :status
|
|
109
|
+
string :message
|
|
110
|
+
end
|
|
111
|
+
|
|
112
|
+
def run(base_url:, args:)
|
|
113
|
+
response = Net::HTTP.get_response(URI("#{base_url}/greet/#{URI.encode_www_form_component(args.name)}"))
|
|
114
|
+
{ status: response.code.to_i, message: JSON.parse(response.body)["message"] }
|
|
115
|
+
end
|
|
116
|
+
end
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
```ts
|
|
120
|
+
// features/steps/get-greeting.ts
|
|
121
|
+
import { defineStep, z } from "nukadoko";
|
|
122
|
+
|
|
123
|
+
export default defineStep({
|
|
124
|
+
description: "GET /greet/<name> from the program under test",
|
|
125
|
+
pattern: "I request the greeting for {name:string}",
|
|
126
|
+
args: z.object({ name: z.string() }),
|
|
127
|
+
returns: z.object({ status: z.number(), message: z.string() }),
|
|
128
|
+
async run({ baseURL }, { name }) {
|
|
129
|
+
const response = await fetch(`${baseURL}/greet/${encodeURIComponent(name)}`);
|
|
130
|
+
const body = (await response.json()) as { message: string };
|
|
131
|
+
return { status: response.status, message: body.message };
|
|
132
|
+
},
|
|
133
|
+
});
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
Each call lands in the step record's `http.jsonl` with its request body
|
|
137
|
+
and response body, the same as a `request` call.
|
|
138
|
+
|
|
139
|
+
The Then step comes from `nuka scaffold message-is --pattern "the message
|
|
140
|
+
is {text:string}" --then --from get-greeting.message`, the same way
|
|
141
|
+
`output-says` came from `run-greet`. The message carries no newline, so
|
|
142
|
+
its claim needs no `view` and runs as scaffolded, with no edit. The
|
|
143
|
+
feature:
|
|
144
|
+
|
|
145
|
+
```gherkin
|
|
146
|
+
# features/greet.feature
|
|
147
|
+
Feature: greet API
|
|
148
|
+
|
|
149
|
+
Scenario: greets by name
|
|
150
|
+
When I request the greeting for "Ada"
|
|
151
|
+
Then the message is "Hello, Ada!"
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
## Setup details
|
|
155
|
+
|
|
156
|
+
`nuka init` sets up a CLI or API project ([An HTTP API](#an-http-api)
|
|
157
|
+
shows the API shape). It adds `.nukadoko/` to
|
|
158
|
+
`.gitignore` unless a line there already ignores that directory
|
|
159
|
+
(`.nukadoko`, `/.nukadoko/`, and `.nukadoko/**` count), and
|
|
160
|
+
`"test:scenarios": "nuka run"` to the `package.json` scripts, unless a
|
|
161
|
+
script by that name already exists; when that script runs something else,
|
|
162
|
+
`init` says so on stderr. `npm run
|
|
163
|
+
test:scenarios` is then the one command a person or CI runs: `nuka run`
|
|
164
|
+
with no target runs `featuresDir`, and it reports what `nuka check` reports
|
|
165
|
+
for those scenarios and stops before executing anything when one is an
|
|
166
|
+
error.
|
|
167
|
+
When `tsconfig.json` has an `include` that leaves out `features/` or the
|
|
168
|
+
config file, `init` appends the missing entries to it and keeps the rest of
|
|
169
|
+
the file as it was, comments and trailing commas included. A
|
|
170
|
+
`tsconfig.json` with no `include` of its own
|
|
171
|
+
already checks every file. When its `compilerOptions` names neither
|
|
172
|
+
`allowImportingTsExtensions` nor `rewriteRelativeImportExtensions`, `init`
|
|
173
|
+
adds `"rewriteRelativeImportExtensions": true` (TypeScript 5.7 or later),
|
|
174
|
+
so `tsc` accepts the `./run-greet.ts` import that `nuka scaffold --from`
|
|
175
|
+
writes. That option is valid whether the project emits or not, and it
|
|
176
|
+
changes only the output of an import that names a `.ts` file. A file
|
|
177
|
+
that `tsconfig.json` extends can name the option instead, and then `init`
|
|
178
|
+
leaves it alone. When the options come only through `extends` and no
|
|
179
|
+
file there names it, or `init` cannot read one, `init` says so on
|
|
180
|
+
stderr. In a project whose `tsconfig.json` sets neither option to true,
|
|
181
|
+
`nuka scaffold --from` writes `./run-greet.js` instead, the name `tsc`
|
|
182
|
+
accepts under any options and `nuka` loads as `run-greet.ts`, and says so
|
|
183
|
+
in one `note:` line on stderr. `init` takes one flag: `--allure` writes
|
|
184
|
+
`allurerc.mjs` and creates the directory `nuka report` writes Allure
|
|
185
|
+
results to (see
|
|
186
|
+
[Reports fill themselves](#reports-fill-themselves)). `init` always adds
|
|
187
|
+
`.env`, `.env.*`, and `!.env.example` to `.gitignore`; delete those lines
|
|
188
|
+
if the project commits a `.env` on purpose.
|
|
189
|
+
Run `nuka` from the directory that holds the config, the package in a
|
|
190
|
+
workspace: a command run where there is none says so on stderr, names a
|
|
191
|
+
config in a parent directory if one exists, and `nuka scaffold` then
|
|
192
|
+
refuses to write.
|
|
193
|
+
|
|
194
|
+
Node runs the step files by erasing their types, so two kinds of
|
|
195
|
+
TypeScript do not load. Syntax with run-time behavior (an `enum`, a
|
|
196
|
+
`namespace`, a constructor parameter property) is refused, and `nuka check`
|
|
197
|
+
reports `step-file-import-failed` at its line with the rewrite to make. A
|
|
198
|
+
name imported without `type` that is only a type stays an import and fails
|
|
199
|
+
with Node's "does not provide an export named" error. For a type that
|
|
200
|
+
nukadoko itself exports, such as `IWorldOptions`, the finding says to
|
|
201
|
+
write `import type`. Setting
|
|
202
|
+
`"erasableSyntaxOnly": true` and `"verbatimModuleSyntax": true` in
|
|
203
|
+
`compilerOptions` makes `tsc` report both before `nuka` runs. An import
|
|
204
|
+
that names a `.js` file next to a `.ts` file (`./run-greet.js` for
|
|
205
|
+
`run-greet.ts`) still loads under `nuka`, which maps the one to the
|
|
206
|
+
other; plain `node` does not, which is why the scaffold writes the `.ts`
|
|
207
|
+
name.
|
|
208
|
+
|
|
209
|
+
nukadoko ships its TypeScript source alongside `dist/`, so stack traces
|
|
210
|
+
point to the actual code. An agent reading
|
|
211
|
+
`node_modules` can see why something works, not only its type.
|
|
212
|
+
|
|
213
|
+
If an existing `package.json` has no `"type": "module"`, the project uses
|
|
214
|
+
CommonJS, as a plain `npm init -y` does. `nuka init` still works. It writes
|
|
215
|
+
`nukadoko.config.mts` instead of `nukadoko.config.ts` and prints a one-line
|
|
216
|
+
reminder that step files also need `.mts`. nukadoko supports only ESM. In
|
|
217
|
+
such a project, Node first reads a plain `.ts` file as CommonJS, then
|
|
218
|
+
reparses it as an ES module with a warning on every load. With
|
|
219
|
+
`"type": "commonjs"`, it does not reparse, and the file fails to import.
|
|
220
|
+
|
|
221
|
+
<details>
|
|
222
|
+
<summary>No `package.json` yet (Rails, Django, and other non-Node repos)?</summary>
|
|
223
|
+
|
|
224
|
+
Create one first. Skip `npm init -y`. It copies the first line of the
|
|
225
|
+
existing `README.md` into `description` and the directory name into `name`.
|
|
226
|
+
Writing the minimum by hand is more reliable:
|
|
227
|
+
|
|
228
|
+
```json
|
|
229
|
+
{ "private": true, "type": "module" }
|
|
230
|
+
```
|
|
231
|
+
|
|
232
|
+
`"type": "module"` keeps every generated file as `.ts`, which is the simpler
|
|
233
|
+
of the two paths above. Leaving it out is still supported (see the CommonJS
|
|
234
|
+
paragraph above). However, a hand-written `nukadoko.config.ts` in such a
|
|
235
|
+
project loads with a warning, and fails to import under
|
|
236
|
+
`"type": "commonjs"`. That error names the file and the cause, and says to
|
|
237
|
+
rename it to `nukadoko.config.mts`. `nuka init` writes
|
|
238
|
+
`nukadoko.config.mts` instead. You do not need to add `.nukadoko/` to
|
|
239
|
+
`.gitignore` yourself because `nuka init` does that. It also adds `.env`
|
|
240
|
+
and `.env.*`, and leaves `.env.example` tracked. The screenshots nukadoko
|
|
241
|
+
takes cover a loaded secret the page shows, but traces inside the state
|
|
242
|
+
directory are not redacted, so it contains sensitive data.
|
|
243
|
+
|
|
244
|
+
</details>
|
|
245
|
+
|
|
246
|
+
## Upgrading
|
|
247
|
+
|
|
248
|
+
Use `npm install -D nukadoko@latest`. npm writes a caret range during
|
|
249
|
+
installation. While the major version is 0, a caret also pins the minor
|
|
250
|
+
(`^0.14.1` allows `0.14.x` only; for `0.0.x` it pins the patch), so
|
|
251
|
+
`npm update` alone never moves beyond the initially installed minor.
|
|
252
|
+
While this is 0.x, any release can change the public API. Read the
|
|
253
|
+
[changelog](https://github.com/meganemura/nukadoko/blob/main/typescript/CHANGELOG.md) instead of relying on the range for safety.
|
|
254
|
+
For what to actually fix after a breaking change, see
|
|
255
|
+
[docs/typescript/upgrading.md](typescript/upgrading.md).
|
|
256
|
+
|
|
257
|
+
## Secrets need no manifest
|
|
258
|
+
|
|
259
|
+
Point `envFiles` at the existing env files, and git classifies them. An
|
|
260
|
+
untracked file is a secret source, so every value it defines is redacted
|
|
261
|
+
from logs and step records. A tracked file whose working tree matches HEAD
|
|
262
|
+
is plain configuration and stays unchanged. Uncommitted edits in a tracked
|
|
263
|
+
file are redacted the same way. No manifest or manual copy into a second
|
|
264
|
+
file is required.
|
|
265
|
+
|
|
266
|
+
## Before / after
|
|
267
|
+
|
|
268
|
+
Promoting a step from regex glue to a typed one. The feature line's text
|
|
269
|
+
doesn't change: only the step definition behind it does.
|
|
270
|
+
|
|
271
|
+
Before (cucumber-js, position capture, untyped, stashed on the World: the
|
|
272
|
+
per-scenario `this` object cucumber-js gives every step):
|
|
273
|
+
|
|
274
|
+
<!-- engine: typescript -->
|
|
275
|
+
```ts
|
|
276
|
+
// features/steps/project.ts (cucumber-js)
|
|
277
|
+
import { Given } from "@cucumber/cucumber";
|
|
278
|
+
|
|
279
|
+
Given("a project {string} exists", async function (name: string) {
|
|
280
|
+
const res = await this.request.post("/projects", { data: { name } });
|
|
281
|
+
const body = await res.json();
|
|
282
|
+
this.project = body; // stashed on World — no schema, no type
|
|
283
|
+
});
|
|
284
|
+
```
|
|
285
|
+
|
|
286
|
+
After (a nukadoko step, named capture, a schema, step-record-backed):
|
|
287
|
+
|
|
288
|
+
```ruby
|
|
289
|
+
# features/steps/create_project.rb
|
|
290
|
+
class CreateProject < Nukadoko::Step
|
|
291
|
+
pattern "a project {name:string} exists"
|
|
292
|
+
description "Create a project and return its id"
|
|
293
|
+
args { string :name }
|
|
294
|
+
returns do
|
|
295
|
+
string :id
|
|
296
|
+
string :name
|
|
297
|
+
end
|
|
298
|
+
mutates true
|
|
299
|
+
|
|
300
|
+
def run(request:, args:)
|
|
301
|
+
request.post("/projects", data: { name: args.name }).json
|
|
302
|
+
end
|
|
303
|
+
end
|
|
304
|
+
```
|
|
305
|
+
|
|
306
|
+
```ts
|
|
307
|
+
// features/steps/create-project.ts
|
|
308
|
+
import { defineStep, z } from "nukadoko";
|
|
309
|
+
|
|
310
|
+
export default defineStep({
|
|
311
|
+
pattern: "a project {name:string} exists",
|
|
312
|
+
description: "Create a project and return its id",
|
|
313
|
+
args: z.object({ name: z.string() }),
|
|
314
|
+
returns: z.object({ id: z.string(), name: z.string() }),
|
|
315
|
+
mutates: true,
|
|
316
|
+
async run({ request }, args) {
|
|
317
|
+
const res = await request.post("/projects", { data: args });
|
|
318
|
+
return res.json();
|
|
319
|
+
},
|
|
320
|
+
});
|
|
321
|
+
```
|
|
322
|
+
|
|
323
|
+
- Named capture (`{name:string}`) binds the value to `args.name` by name.
|
|
324
|
+
With position capture, reordering two same-typed values in the pattern
|
|
325
|
+
silently swaps which one lands where; `nuka check` also flags a bare
|
|
326
|
+
`{string}` as an error before that can happen.
|
|
327
|
+
- `args` and `returns` are schemas validated at the run boundary.
|
|
328
|
+
`result` in the step record is something the tool validated, not just
|
|
329
|
+
whatever the step handed back. In TypeScript they are zod, and `z` comes
|
|
330
|
+
from nukadoko itself, so there is no zod to install separately; if your
|
|
331
|
+
own project already uses zod and passes one of its own schemas in, that
|
|
332
|
+
schema needs to be zod 4.
|
|
333
|
+
- `request` above (and `page` for browser steps) is a fixture the step
|
|
334
|
+
names in `run`'s parameters; only the names a step actually takes ever
|
|
335
|
+
get built, so a step that never names `page` never launches a browser
|
|
336
|
+
(and a project with no such step does not install Playwright at all; see
|
|
337
|
+
[Install](../README.md#install)). `page` is Playwright's own `Page`, not
|
|
338
|
+
a nukadoko wrapper, so existing Playwright knowledge and helpers carry
|
|
339
|
+
over directly. In TypeScript `request` is Playwright's
|
|
340
|
+
`APIRequestContext` too.
|
|
341
|
+
- `request.post("/projects", ...)` above resolves that relative path
|
|
342
|
+
against the URL of the program the config's `program` starts or names
|
|
343
|
+
([An HTTP API](#an-http-api)). Without a program, only an absolute
|
|
344
|
+
URL works.
|
|
345
|
+
- `nuka do create-project --args '{"name":"acme"}'` runs this step by
|
|
346
|
+
itself and prints its step record. This record is the unit of an agent's
|
|
347
|
+
exploration loop, and the command requires no prior setup.
|
|
348
|
+
|
|
349
|
+
## What it fixes
|
|
350
|
+
|
|
351
|
+
Each row is a place where the mapping between a sentence and an execution
|
|
352
|
+
used to go soft. They are stated against cucumber-js because that is where
|
|
353
|
+
they are most familiar, not because it is the only layer that has them.
|
|
354
|
+
|
|
355
|
+
| The failure | What nukadoko does about it |
|
|
356
|
+
|---|---|
|
|
357
|
+
| Duplicate steps: which one matched? | `nuka check` reports **duplicate patterns** (the same text registered twice) and **ambiguous steps** (one line in a feature that two different patterns could both match), before anything runs |
|
|
358
|
+
| `this.foo`: an untyped bag | A step returns a value against a `returns` schema; a later step declares `from` to read one key of it by name: a dependency that shows up as an import in the diff, a read that lands on the receiving step's step record, and a binding order `nuka check` verifies before anything runs (see [Chaining steps](spec.md#chaining-steps)) |
|
|
359
|
+
| A report that only says `passed` | Every execution writes a step record: validated result, the HTTP calls with their bodies, the processes, and the files the tool itself recorded, what it saw but could not measure, evidence, environment, target version |
|
|
360
|
+
| Undefined steps found at run time | `nuka check <feature>` fails on them statically, and names the text that matched nothing |
|
|
361
|
+
| A `Then` that judges in code, or quietly acts | A typed `Then` declares claims instead of code: which value it reads, how it compares it, and where the expected value comes from, which is the sentence unless the step says otherwise. nukadoko compares, and the record and the run summary name both values. `nuka check` refuses a `Then` bound to a step that runs, and a claim step bound in `Given` or `When` (see [Claims](spec.md#claims)) |
|
|
362
|
+
| A scenario that passes whether or not the feature is there | An environment declares the switches of its program as `conditions`, and a scenario tagged `@with:<switch>` also runs where the switch is off, as a control that never turns the run red. A Then that fails there, at the same line in two runs, makes the row `proven`; a row whose control passed stays `held`, and the run summary's table shows which is which (see [Verdicts](spec.md#verdicts)) |
|
|
363
|
+
| A step that quietly mutates state | `mutates` is a declaration nukadoko trusts, not a number it re-derives: a step declaring `mutates: true` is refused before it runs in a read-only environment; what actually ran is still recorded on the step record for review |
|
|
364
|
+
|
|
365
|
+
The last row requires precision because the tool once failed on a count
|
|
366
|
+
instead of the promise. That behavior stated what the measurement could
|
|
367
|
+
not support. The count used the HTTP method as a proxy for a write. This
|
|
368
|
+
proxy fails for GraphQL, RPC-over-POST, and vendor query APIs that perform
|
|
369
|
+
a pure read over POST. A truthful `mutates: false` step that calls one of
|
|
370
|
+
these APIs still looks like a write. No general HTTP-layer rule can
|
|
371
|
+
distinguish that call from a real write. Nukadoko therefore trusts the
|
|
372
|
+
declaration and never infers a write from a method. The step record keeps
|
|
373
|
+
each request it measured, with its method, URL, status, and bodies, as a
|
|
374
|
+
fact, not a verdict, and it names what it could not measure instead of
|
|
375
|
+
guessing.
|
|
376
|
+
|
|
377
|
+
## Reports fill themselves
|
|
378
|
+
|
|
379
|
+
A classic Cucumber run shows only the evidence that a team wires up. Each
|
|
380
|
+
project must write and maintain hook boilerplate for traces and screenshots.
|
|
381
|
+
[Allure](https://allurereport.org/) is a test-report dashboard; nukadoko
|
|
382
|
+
writes results in its format and never renders HTML itself.
|
|
383
|
+
`nuka report --format allure` fills the report from every step record of a
|
|
384
|
+
finished run without additional wiring. It adds
|
|
385
|
+
the validated result, trace, HTTP log, environment, and version. One item cannot be added on the report side in
|
|
386
|
+
classic Cucumber because Cucumber discards step return values: the
|
|
387
|
+
validated result for each step.
|
|
388
|
+
|
|
389
|
+
Under each step sits a timeline of what happened inside it, built from
|
|
390
|
+
absolute timestamps: the stages it reached, every wait with its real
|
|
391
|
+
duration and how many attempts it took, and every Playwright call it made
|
|
392
|
+
including the assertions. One attempt and forty attempts ask for opposite
|
|
393
|
+
fixes, and nothing else in a report tells them apart. Each claim of a
|
|
394
|
+
`Then` follows the timeline as a child step of its own, named by its claim
|
|
395
|
+
line and passed or failed, with both values and where each came from as
|
|
396
|
+
parameters. Counts of what the
|
|
397
|
+
page itself said (console errors, uncaught errors, failed requests) sit
|
|
398
|
+
beside the step, so a step that passed while the page threw three
|
|
399
|
+
uncaught errors says so without anyone opening an attachment. The trace
|
|
400
|
+
attached is that step's own, not the whole scenario's, so the failing
|
|
401
|
+
step opens directly instead of being scrubbed for. That same `trace.zip`
|
|
402
|
+
also sits under the step record on its own, and opens outside Allure with
|
|
403
|
+
`npx playwright show-trace <evidence.dir>/trace.zip`. The step record is
|
|
404
|
+
attached whole as well, which is what keeps this list from going stale:
|
|
405
|
+
anything a step record gains later arrives in the report without a second
|
|
406
|
+
mapping to remember.
|
|
407
|
+
|
|
408
|
+
`nuka report --format messages` writes a cucumber-messages (NDJSON) stream
|
|
409
|
+
of the same run, so a migrating team's existing formatters and JUnit-based
|
|
410
|
+
CI keep working: confirmed by running our own stream through
|
|
411
|
+
`@cucumber/junit-xml-formatter`, not just asserted. That formatter names
|
|
412
|
+
a test case from the scenario, so a plain Scenario run in two
|
|
413
|
+
environments is two test cases of one name there. A control (a
|
|
414
|
+
scenario run where its condition does not hold) is left out of the
|
|
415
|
+
stream, so JUnit reads a green run as green. It does not read every red
|
|
416
|
+
run as red: under `--base` an `unproven` or `moved` row is no failed
|
|
417
|
+
test case there, so gate on `nuka run`'s exit code. Allure keeps a
|
|
418
|
+
control, named `<scenario> (control)`, with the status it ran to. See
|
|
419
|
+
[Allure results](spec.md#allure-results) and
|
|
420
|
+
[Messages stream](spec.md#messages-stream).
|
|
421
|
+
|
|
422
|
+
`nuka run` writes neither. `nuka report` renders them after the run, from
|
|
423
|
+
the run directory alone, so a run directory copied off a CI machine renders
|
|
424
|
+
too, and one run can be rendered again in another format:
|
|
425
|
+
|
|
426
|
+
```sh
|
|
427
|
+
npx nuka run
|
|
428
|
+
npx nuka report --format allure # .nukadoko/export/allure-results
|
|
429
|
+
npx nuka report --format messages --out messages.ndjson
|
|
430
|
+
npx nuka report .nukadoko/runs/<run_id> --format allure --out reports/allure
|
|
431
|
+
```
|
|
432
|
+
|
|
433
|
+
With no run directory it renders the newest run. `--out` moves where the
|
|
434
|
+
output lands; without it, Allure results go to
|
|
435
|
+
`.nukadoko/export/allure-results` and the other two formats go to stdout.
|
|
436
|
+
|
|
437
|
+
Since nukadoko writes results and never HTML, rendering them is Allure 3's
|
|
438
|
+
CLI (`npm i -g allure`, or `npx allure` as below):
|
|
439
|
+
|
|
440
|
+
```sh
|
|
441
|
+
R=.nukadoko/export/allure-results
|
|
442
|
+
npx allure watch $R --output .nukadoko/allure-report # live, re-renders as a run writes
|
|
443
|
+
npx allure generate $R --output .nukadoko/allure-report
|
|
444
|
+
npx allure open .nukadoko/allure-report # serve one already generated
|
|
445
|
+
```
|
|
446
|
+
|
|
447
|
+
A generated report's `index.html` cannot open directly through `file://`.
|
|
448
|
+
The report's SPA fetches `widgets/*.json` during loading, which `file://`
|
|
449
|
+
cannot serve. The header and footer still render, so the broken report can
|
|
450
|
+
look valid at a glance. This problem occurs after someone downloads a CI
|
|
451
|
+
report artifact and opens `index.html` locally. Serve the report with
|
|
452
|
+
`npx allure open` or `npx allure watch` instead.
|
|
453
|
+
|
|
454
|
+
`nuka init --allure` writes `allurerc.mjs` at the project root (skipped, with a
|
|
455
|
+
message, if a project already has one under any name Allure auto-detects);
|
|
456
|
+
without it, every nukadoko failure lands in Allure 3's one built-in
|
|
457
|
+
"Product errors" category instead of one of the nine `error.kind` ones. A
|
|
458
|
+
project not using `init` can copy
|
|
459
|
+
[examples/allure/allurerc.mjs](https://github.com/meganemura/nukadoko/blob/main/typescript/examples/allure/allurerc.mjs)
|
|
460
|
+
by hand.
|
|
461
|
+
|
|
462
|
+
Pass `--output` to each command. Allure defaults it to `allure-report/`
|
|
463
|
+
in the current directory, and `watch` writes there too, so the default
|
|
464
|
+
leaves a generated report sitting in your repository root, untracked and
|
|
465
|
+
un-ignored, from nothing more than looking at a report. Sending it under
|
|
466
|
+
`.nukadoko/` puts it where `nuka init` already added a gitignore entry.
|
|
467
|
+
|
|
468
|
+
Use `watch` while iterating. Leave it running in one terminal, and run
|
|
469
|
+
`nuka run` then `nuka report --format allure` in another; the report
|
|
470
|
+
updates when the render lands. `watch` serves on a random port (`--port`
|
|
471
|
+
selects one) and opens a browser only with `--open`. `nuka init --allure`
|
|
472
|
+
creates `.nukadoko/export/allure-results/` so `watch` can start before the
|
|
473
|
+
first render.
|
|
474
|
+
|
|
475
|
+
Rendering the same run again replaces what its last render wrote, so the
|
|
476
|
+
directory holds one copy of each scenario. A run's files leave with the
|
|
477
|
+
run once it is older than the newest `retention.runs` runs (default 20),
|
|
478
|
+
so a report shows at most that many runs; `nuka clean` empties the
|
|
479
|
+
directory at once, together with the records.
|
|
480
|
+
|
|
481
|
+
## Self-healing, with the deviation on the record
|
|
482
|
+
|
|
483
|
+
A scripted scenario breaks because the app changed, not because the test was
|
|
484
|
+
wrong. The repair loop nukadoko is built for:
|
|
485
|
+
|
|
486
|
+
1. An agent re-runs the goal adaptively through `nuka do`, one step at a
|
|
487
|
+
time, reading each step record to decide the next call. It is not replaying
|
|
488
|
+
the broken scenario; it is finding out what works now.
|
|
489
|
+
2. Those step records record the sequence that actually worked, which, by
|
|
490
|
+
definition, deviates from the scripted one. They are the narrative of the
|
|
491
|
+
repair, not its proof, and the agent cites them in the PR as exactly
|
|
492
|
+
that.
|
|
493
|
+
3. The PR updates the typed steps or the feature file, and its proof is the
|
|
494
|
+
repaired scenario running green: its entry in `run.json` and its step records,
|
|
495
|
+
reviewed like any other change.
|
|
496
|
+
|
|
497
|
+
Step 2 is the critical part. **Self-healing without an audit trail lets a
|
|
498
|
+
suite silently stop testing anything.** A scenario rewritten to match the
|
|
499
|
+
app's current behavior still passes, but nobody can see that its former
|
|
500
|
+
check disappeared. Here, the reviewer can read a record of the deviation.
|
|
501
|
+
Attestation always passes through the scenario instead of an ad-hoc
|
|
502
|
+
sequence.
|
|
503
|
+
|
|
504
|
+
nukadoko's contribution is that every stage leaves a record. The authoring is
|
|
505
|
+
an agent workflow (the bundled skills, in
|
|
506
|
+
[Skills for coding agents](../README.md#skills-for-coding-agents)), not
|
|
507
|
+
engine magic. See
|
|
508
|
+
[Self-healing, audited](spec.md#self-healing-audited).
|
|
509
|
+
|
|
510
|
+
This loop does **not** catch another way a suite can become hollow. A
|
|
511
|
+
scenario can remain intact while its `Then` becomes weaker. A step record
|
|
512
|
+
shows what the execution did, and a claim shows what a `Then` compared,
|
|
513
|
+
but neither can show whether that comparison still means what the
|
|
514
|
+
criterion says. Review must catch that problem, as
|
|
515
|
+
[What this does not do](../README.md#what-this-does-not-do) explains.
|
|
516
|
+
|
|
517
|
+
## The compat door
|
|
518
|
+
|
|
519
|
+
Nothing before this section assumes an existing suite. This section is for the case
|
|
520
|
+
where there is one.
|
|
521
|
+
|
|
522
|
+
To migrate an existing Cucumber + Playwright suite, switch one import from
|
|
523
|
+
`@cucumber/cucumber` to `nukadoko/compat`. The same pattern syntax, hooks,
|
|
524
|
+
and World continue to work while nukadoko's harness starts measuring step
|
|
525
|
+
records. A World subclass can assign `this.page` and `this.request`. Such
|
|
526
|
+
a page gets no trace and no page log, though a request sent through such a
|
|
527
|
+
`this.request` from a step still lands in `http.jsonl`. Each step can then move to `defineStep` independently, so a
|
|
528
|
+
partially promoted suite continues to pass.
|
|
529
|
+
|
|
530
|
+
The door is an entry point, not a destination. A compat step gains a step
|
|
531
|
+
record with status and timing from the first run; evidence and the page's
|
|
532
|
+
`http.jsonl` lines follow once its glue opens the browser or request through
|
|
533
|
+
`this.openPage()` / `this.openRequest()` (the measured upgrade in
|
|
534
|
+
[docs/typescript/migration.md](typescript/migration.md)). However, nukadoko discards its return value, and its
|
|
535
|
+
step record contains `result: null`. Features that require a validated
|
|
536
|
+
result remain unavailable. `nuka check` has no contract to compare with a
|
|
537
|
+
feature, `from` cannot declare a dependency, and a green run summary
|
|
538
|
+
confirms only that the steps ran. It does not confirm that stated contracts held. These
|
|
539
|
+
limits are the reasons to promote each step.
|
|
540
|
+
|
|
541
|
+
Switching the import back returns a plain cucumber-js suite. That is a
|
|
542
|
+
standing design rule (compat assets must survive both the switch and a
|
|
543
|
+
partial migration), and its job is to make trying nukadoko cost one edit
|
|
544
|
+
instead of a commitment. It is not a property to build a strategy around.
|
|
545
|
+
A step promoted to `defineStep` has no import to switch back: its body
|
|
546
|
+
still moves, since `run` is written against Playwright's own objects, but
|
|
547
|
+
its schemas and everything built on them do not, and nothing here converts
|
|
548
|
+
one back (docs/typescript/migration.md "The way back" covers doing it by hand).
|
|
549
|
+
|
|
550
|
+
The migration cost was measured instead of assumed. An audit compared the
|
|
551
|
+
glue from eight public cucumber-js suites with this door but did not run
|
|
552
|
+
the suites. **None passed with only the import change** during that audit.
|
|
553
|
+
After the identified blockers were fixed, two of the eight had no rejected
|
|
554
|
+
glue. The other six still require a short mechanical pass. Each blocker
|
|
555
|
+
fails during import or the first run instead of silently changing behavior.
|
|
556
|
+
|
|
557
|
+
Three of those suites have since been run rather than read, in
|
|
558
|
+
[nukadoko-lab](https://github.com/meganemura/nukadoko-lab),
|
|
559
|
+
which copies a pinned corpus, rewrites the one import, and runs `nuka run`
|
|
560
|
+
against the result. One passed on the import alone. Of the other two, one
|
|
561
|
+
now passes: step discovery originally read only `.ts` files, so glue
|
|
562
|
+
written as plain `.js` went undiscovered; 0.1.0 widened that to
|
|
563
|
+
`.ts`/`.mts`/`.js`/`.mjs`, and the suite has passed on every version the
|
|
564
|
+
lab has re-tested since. The other still fails: a file outside its glue
|
|
565
|
+
calls a plain `require()`, and discovery walks every file under the
|
|
566
|
+
suite's feature directory, not just the ones that register steps, so that
|
|
567
|
+
throws mid-import and aborts discovery. `nuka check` tolerates the failure
|
|
568
|
+
and names the file; `run` is fail-fast and does not recover. The lab was
|
|
569
|
+
last re-run 2026-08-16. Reading glue as text found the blockers that are
|
|
570
|
+
visible in glue; executing it found two that were not.
|
|
571
|
+
|
|
572
|
+
One blocker deserves naming up front, because it is a go/no-go rather than
|
|
573
|
+
a pass: **a CommonJS suite cannot use the door at all.**
|
|
574
|
+
`require("nukadoko/compat")` fails outright (nukadoko is ESM-only), so a
|
|
575
|
+
CommonJS suite needs a module-format change before anything else. Two of
|
|
576
|
+
the eight audited suites were CommonJS throughout. This is about the
|
|
577
|
+
module format, not the file extension: glue in `.js` or `.mjs` is read
|
|
578
|
+
like any other, and a `.cjs` or `.cts` file is named by `nuka check` rather than
|
|
579
|
+
turning up later as a step nothing defined.
|
|
580
|
+
|
|
581
|
+
See [docs/typescript/migration.md](typescript/migration.md) for the step-by-step guide with
|
|
582
|
+
the audit's findings, and
|
|
583
|
+
[examples/migration](https://github.com/meganemura/nukadoko/tree/main/typescript/examples/migration)
|
|
584
|
+
for a worked example running end to end.
|
|
585
|
+
|
|
586
|
+
Already on Playwright Test, with no cucumber and no Gherkin? That is a
|
|
587
|
+
different door, and
|
|
588
|
+
[docs/typescript/migration-playwright-test.md](typescript/migration-playwright-test.md)
|
|
589
|
+
walks it: the suite stays where it is and keeps its own runner, while an
|
|
590
|
+
operation moves into a plain function that both a spec and a typed step
|
|
591
|
+
call.
|
|
592
|
+
|
|
593
|
+
## Try it against your own suite first
|
|
594
|
+
|
|
595
|
+
You don't have to migrate anything to find out whether this fits. Point an
|
|
596
|
+
agent at your repository with the prompt below; it reports back on your
|
|
597
|
+
suite's shape, what a migration would cost, and what could go wrong.
|
|
598
|
+
|
|
599
|
+
<details>
|
|
600
|
+
<summary>Evaluation prompt (paste into an agent working in your repo)</summary>
|
|
601
|
+
|
|
602
|
+
```
|
|
603
|
+
You are evaluating whether to adopt nukadoko (github.com/meganemura/nukadoko)
|
|
604
|
+
for this project's end-to-end / acceptance tests.
|
|
605
|
+
|
|
606
|
+
1. Read nukadoko's README and its full design spec, docs/spec.md, to
|
|
607
|
+
understand what it actually does today versus what is only designed.
|
|
608
|
+
2. Survey this project's existing E2E / acceptance test assets: feature
|
|
609
|
+
files (or equivalent scenarios), the glue/step code behind them, and how
|
|
610
|
+
CI runs them.
|
|
611
|
+
3. Report back under exactly these five headings, in this order:
|
|
612
|
+
|
|
613
|
+
1. Current state (what test suite exists today): scope, coverage, what
|
|
614
|
+
executes it.
|
|
615
|
+
2. Fit (how typed steps + step records would change the way an agent runs
|
|
616
|
+
this suite's checks): which flows become vocabulary, and what the
|
|
617
|
+
explore-execute-decide loop looks like concretely here.
|
|
618
|
+
3. First three migration moves: the first commands to run and the first
|
|
619
|
+
slice of steps to bind (e.g. `nuka init`, binding an initial slice of
|
|
620
|
+
steps, promoting the hottest existing step to a typed one).
|
|
621
|
+
4. Risks and costs: an estimate of vocabulary size (how many distinct
|
|
622
|
+
typed steps this suite would need), how much of the existing `Then`
|
|
623
|
+
usage only reads and compares (a typed `Then` declares claims, and its
|
|
624
|
+
sentence states the expected value) versus acts or keeps the expected
|
|
625
|
+
value in code, whether the suite is CommonJS, and where secrets currently live
|
|
626
|
+
relative to where nukadoko expects them.
|
|
627
|
+
5. Verdict: adopt / trial / not-yet, with the reasoning.
|
|
628
|
+
|
|
629
|
+
Do not guess at nukadoko internals beyond what its README and docs/spec.md
|
|
630
|
+
state. If something is unclear, not yet implemented, or you don't have
|
|
631
|
+
access to a document you need, say so rather than assuming.
|
|
632
|
+
```
|
|
633
|
+
|
|
634
|
+
</details>
|
|
635
|
+
|
|
636
|
+
## CI runs in depth
|
|
637
|
+
|
|
638
|
+
This section continues [Running this in CI](../README.md#running-this-in-ci)
|
|
639
|
+
in the README, after the one step that runs the whole gate.
|
|
640
|
+
|
|
641
|
+
`nuka run` also prints its own progress and where it wrote to stderr as it
|
|
642
|
+
goes. stdout stays empty unless you
|
|
643
|
+
ask: `nuka run --records` writes each scenario's `run.json` entry there,
|
|
644
|
+
one JSON line per scenario as it finishes, and `nuka run --json` prints
|
|
645
|
+
`run.json` itself instead, the envelope every `--json` prints with the
|
|
646
|
+
run's fields beside `findings`: the commit and whether the tree was dirty,
|
|
647
|
+
each environment it ran in, whether a `:line` target or `--tag` made the run
|
|
648
|
+
`partial`, the counts, the verdict table (one row per criterion, one cell
|
|
649
|
+
per environment, and each row `held`, `proven`, or `failed`), and each
|
|
650
|
+
scenario's steps with their line, status, step record, a claim step's
|
|
651
|
+
claims,
|
|
652
|
+
and, for a failure, its error, the results it read, and the command that
|
|
653
|
+
reruns it. Under `--json` stderr is empty, and a warning is a finding in
|
|
654
|
+
the document, so the document is the only thing an agent's shell shows.
|
|
655
|
+
`run.json` and the step records are on disk in the run's own directory,
|
|
656
|
+
`.nukadoko/runs/<run_id>/`, either way, and the run summary is rendered from `run.json` alone. No output depends on whether stdout or
|
|
657
|
+
stderr is a terminal.
|
|
658
|
+
A failed step prints the first line of its error and the path of its step
|
|
659
|
+
record under its progress line, so a CI log says why it failed. When the
|
|
660
|
+
failed step read from a step whose program exited nonzero, a `used` line
|
|
661
|
+
between the two names that step, its exit code, and the first line of its
|
|
662
|
+
stderr: a Then that claimed against an empty stdout usually broke there. After the
|
|
663
|
+
summary, each failed scenario is a `scenario-failed` finding whose `do:`
|
|
664
|
+
line runs it again.
|
|
665
|
+
|
|
666
|
+
```text
|
|
667
|
+
step 2/2 failed 0.0s the sum is 5
|
|
668
|
+
claim broken: 4 (from:add@4.sum) equal 5 (sentence:expected)
|
|
669
|
+
record .nukadoko/runs/<run_id>/steps/<id>
|
|
670
|
+
...
|
|
671
|
+
failed scenario-failed features/sum.feature:3 two and two: claim broken: 4 (from:add@4.sum) equal 5 (sentence:expected)
|
|
672
|
+
do: nuka run features/sum.feature:3
|
|
673
|
+
```
|
|
674
|
+
|
|
675
|
+
The same facts go into a Markdown run summary, written for a person rather
|
|
676
|
+
than a log: `.nukadoko/runs/<run_id>/summary.md` on every run,
|
|
677
|
+
appended to `$GITHUB_STEP_SUMMARY` when that is set, and printed again for
|
|
678
|
+
any finished run by `nuka report --format markdown` (`--out <path>` for a
|
|
679
|
+
PR comment step). Its first line is `<!-- nukadoko:run -->`, so
|
|
680
|
+
a CI step can update the comment it posted on an earlier push.
|
|
681
|
+
|
|
682
|
+
**A retry that replaces the record is out of scope permanently, not "not
|
|
683
|
+
yet".** A green scenario is no evidence that its waits are placed
|
|
684
|
+
correctly: every wait a scenario needed could have been supplied by
|
|
685
|
+
coincidence, further down, and only a route that does not pass through
|
|
686
|
+
them can show where they actually belong (see [spec.md](spec.md)). A
|
|
687
|
+
step record's `polls` field already keeps that honest, distinguishing one
|
|
688
|
+
attempt that returned immediately from forty attempts spent waiting 20
|
|
689
|
+
seconds; a retry that reruns a whole step until it passes and keeps only
|
|
690
|
+
the winning attempt throws that distinction away to buy a green run. That
|
|
691
|
+
is the shape ruled out here, the one Playwright's own `retries` and
|
|
692
|
+
`testInfo.retry` take, where only the last attempt reaches the final
|
|
693
|
+
report. Running a scenario more than once while keeping every attempt's
|
|
694
|
+
own record, and naming which attempt passed, is a different shape:
|
|
695
|
+
nothing about it makes a record state a fact it cannot support. That shape
|
|
696
|
+
is not ruled out, and `nuka run --repeat <n>` ships it (see
|
|
697
|
+
the end of this section).
|
|
698
|
+
|
|
699
|
+
Ruling out the record-discarding shape does not make the flake it would
|
|
700
|
+
have papered over disappear. A third-party script or CI-runner resource
|
|
701
|
+
contention can fail a scenario whose waits are placed correctly, and
|
|
702
|
+
without a retry that failure still turns the run red. A suite that puts
|
|
703
|
+
`nuka run` on a merge gate needs a human to triage that failure, because
|
|
704
|
+
the fix is not always "the wait was in the wrong place."
|
|
705
|
+
|
|
706
|
+
`nuka run --concurrency <n>` runs feature files in parallel, with a default
|
|
707
|
+
of 1. A full run's wall-clock time falls as concurrency rises, until the
|
|
708
|
+
machine runs out of room to add another worker. Measuring where that
|
|
709
|
+
happens is worth more than guessing it: on one ten-core machine, four
|
|
710
|
+
workers beat eight. The distribution unit is a whole feature file, so the
|
|
711
|
+
run cannot divide work within one file, and a suite in few large files
|
|
712
|
+
gains less than the same scenarios spread across many. Sharding one suite across
|
|
713
|
+
multiple invocations is not available because its records would span
|
|
714
|
+
multiple run ids, which no single run summary can describe. Parallel
|
|
715
|
+
execution makes `nuka run` faster, but it still starts browsers and remains
|
|
716
|
+
the more expensive gate. The split in
|
|
717
|
+
[Running this in CI](../README.md#running-this-in-ci) therefore stays the same: run
|
|
718
|
+
`nuka check` on every PR, and run `nuka run` on merge, deploy, or a nightly
|
|
719
|
+
build to keep a growing suite's PR gate fast.
|
|
720
|
+
|
|
721
|
+
`nuka run --repeat <n>` runs every selected scenario `n` times in one
|
|
722
|
+
invocation, for a failure that reproduces one time in several. Each
|
|
723
|
+
execution is its own record under one run id, and a scenario that failed
|
|
724
|
+
at least once is tallied after the summary, `<passed> of <n> passed`.
|
|
725
|
+
|
|
726
|
+
`nuka run --order shuffled` runs the same selection in an order a seed
|
|
727
|
+
names, for a scenario that passes only because an earlier one left data in
|
|
728
|
+
the program. The feature files are sorted, then each file's scenarios, so
|
|
729
|
+
a file stays whole at any `--concurrency`. The seed is on stderr, in
|
|
730
|
+
`run.json`, and in the summary, and `--order shuffled:<seed>` runs that
|
|
731
|
+
order again. A failed scenario's `do:` line names the scenarios that ran
|
|
732
|
+
before it, so an order dependence fails on it again, where running the
|
|
733
|
+
scenario alone would pass. File order stays the default.
|
|
734
|
+
|
|
735
|
+
`nuka run --env a --env b` runs every selected scenario once in each
|
|
736
|
+
environment, in one run with one run id: all of `a` first, then all of
|
|
737
|
+
`b`, each with its own env files, secrets, version probe, program,
|
|
738
|
+
BeforeAll and AfterAll, and process-scope fixtures. `run.json` holds the
|
|
739
|
+
verdict table, one row per criterion and one cell per environment, and the
|
|
740
|
+
summary opens with it. An environment can declare the switches of its
|
|
741
|
+
program as `conditions`, and a run without `--env` runs every
|
|
742
|
+
environment that declares them, or the ones the program's
|
|
743
|
+
`defaultEnvironments` names:
|
|
744
|
+
|
|
745
|
+
```ruby
|
|
746
|
+
env: { BANNER: "{condition.banner}" },
|
|
747
|
+
environments: {
|
|
748
|
+
"banner-off": { conditions: { banner: false } },
|
|
749
|
+
"banner-on": { conditions: { banner: true } },
|
|
750
|
+
},
|
|
751
|
+
```
|
|
752
|
+
|
|
753
|
+
```ts
|
|
754
|
+
env: { BANNER: "{condition.banner}" },
|
|
755
|
+
environments: {
|
|
756
|
+
"banner-off": { conditions: { banner: false } },
|
|
757
|
+
"banner-on": { conditions: { banner: true } },
|
|
758
|
+
},
|
|
759
|
+
```
|
|
760
|
+
|
|
761
|
+
A scenario tagged `@with:banner` is required in `banner-on` and a
|
|
762
|
+
control in `banner-off`. A control never turns the run red. When its Then
|
|
763
|
+
fails, at the same line in two runs (`--proof-runs`), the row is
|
|
764
|
+
`proven`: the scenario tells the two sides of the switch apart. When it
|
|
765
|
+
passes, the row is `held`, and that is the row to read: the Then does not
|
|
766
|
+
see what the switch changes. A row is `failed`, and the exit code 1, when
|
|
767
|
+
a required cell does not pass. `--env default` names the top-level
|
|
768
|
+
environment, as `run.json` names it, so `--env default --env staging`
|
|
769
|
+
runs both. An environment is still only configuration, in the
|
|
770
|
+
program: what differs between `a` and `b` is whatever
|
|
771
|
+
their fields say. `conditions` sets nothing, and nukadoko does not check
|
|
772
|
+
it against the program: `{condition.banner}` hands the program the side
|
|
773
|
+
its environment declares, so the two cannot disagree.
|
|
774
|
+
|
|
775
|
+
`nuka run --base <git ref>` compares each criterion with the commit the
|
|
776
|
+
ref names, such as `origin/main`, and adds two systems where a row needs
|
|
777
|
+
them. A criterion is its feature file and name, and its content is what a
|
|
778
|
+
person approved (its steps, its Examples row, its condition tags), so a
|
|
779
|
+
renamed or retagged scenario stays `unchanged`. A `new` or `changed`
|
|
780
|
+
one also runs in the `base` system, the base's code under head's
|
|
781
|
+
criteria and steps, and its Then has to fail there, in each of two runs,
|
|
782
|
+
for the row to be `proven`; when nothing shows that, the row is
|
|
783
|
+
`unproven`, and `@held` says the base already had the behaviour. When
|
|
784
|
+
the mapping changed (a step file or helper under the features directory,
|
|
785
|
+
the config's fixtures or parameter types, an environment's conditions),
|
|
786
|
+
an `unchanged` one also runs in the `old` system, head's code under the
|
|
787
|
+
base's criteria and steps, and has to pass there; when it does not, the
|
|
788
|
+
row is `moved`: the approved sentence no longer means what it meant.
|
|
789
|
+
Each system runs in a tree under the run directory, built from that
|
|
790
|
+
tree's program, and resolves packages from head's project. The exit
|
|
791
|
+
code is 1 on a `failed`, `unproven`, or `moved` row, and a `removed`
|
|
792
|
+
row quotes the criterion that went. In a shallow clone, fetch the base
|
|
793
|
+
first; the refusal names the command.
|
|
794
|
+
|
|
795
|
+
## The bed has to be tended
|
|
796
|
+
|
|
797
|
+
A nukadoko is the fermented rice-bran bed that pickles cucumbers. It is
|
|
798
|
+
alive: tended daily it matures, neglected it dies. That is the claim this
|
|
799
|
+
tool makes about a suite's step definitions (a living culture rather than
|
|
800
|
+
a write-once asset), and it is not only a remark about the name.
|
|
801
|
+
|
|
802
|
+
`nuka check` asks whether the project can run right now, and is meant to be
|
|
803
|
+
read before every run. Its notes ask the other question: is any of this
|
|
804
|
+
rotting (see [Checks and notes](spec.md#checks-and-notes)). A `from`
|
|
805
|
+
declaration nothing exercises. A pattern no feature binds. A schema field
|
|
806
|
+
with no description reads fine to a person looking at the file and tells
|
|
807
|
+
the agent choosing between two steps nothing at all. None of those stop a
|
|
808
|
+
run, so a note never changes the exit code; a job that wants one to gate
|
|
809
|
+
names its code with `nuka check --fail-on`. Only a check with no target
|
|
810
|
+
reports notes, because whether a step is bound depends on every feature the
|
|
811
|
+
project scans.
|
|
812
|
+
|
|
813
|
+
---
|
|
814
|
+
|
|
815
|
+
[Japanese](guide.ja.md)
|