nukadoko 0.6.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.
Files changed (200) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +541 -3
  3. data/README.ja.md +20 -5
  4. data/README.md +12 -6
  5. data/docs/ci.ja.md +542 -0
  6. data/docs/ci.md +635 -0
  7. data/docs/commands.ja.md +1524 -0
  8. data/docs/commands.md +1281 -0
  9. data/docs/engines.json +19 -0
  10. data/docs/execution-events.ja.md +336 -0
  11. data/docs/execution-events.md +423 -0
  12. data/docs/glossary.json +1348 -0
  13. data/docs/guide.ja.md +733 -0
  14. data/docs/guide.md +815 -0
  15. data/docs/intent.ja.md +133 -0
  16. data/docs/intent.md +156 -0
  17. data/docs/layout.ja.md +442 -0
  18. data/docs/layout.md +399 -0
  19. data/docs/releasing.ja.md +186 -0
  20. data/docs/releasing.md +237 -0
  21. data/docs/ruby/reference.ja.md +302 -0
  22. data/docs/ruby/reference.md +368 -0
  23. data/docs/spec.ja.md +8916 -0
  24. data/docs/spec.md +11250 -0
  25. data/docs/tutorial.ja.md +451 -0
  26. data/docs/tutorial.md +458 -0
  27. data/docs/typescript/adopting.ja.md +231 -0
  28. data/docs/typescript/adopting.md +251 -0
  29. data/docs/typescript/doors.ja.md +301 -0
  30. data/docs/typescript/doors.md +329 -0
  31. data/docs/typescript/migration-playwright-test.ja.md +189 -0
  32. data/docs/typescript/migration-playwright-test.md +212 -0
  33. data/docs/typescript/migration.ja.md +391 -0
  34. data/docs/typescript/migration.md +505 -0
  35. data/docs/typescript/reference.ja.md +176 -0
  36. data/docs/typescript/reference.md +197 -0
  37. data/docs/typescript/upgrading.ja.md +1774 -0
  38. data/docs/typescript/upgrading.md +2224 -0
  39. data/docs/web-app.ja.md +627 -0
  40. data/docs/web-app.md +659 -0
  41. data/docs/writing-scenarios.ja.md +544 -0
  42. data/docs/writing-scenarios.md +563 -0
  43. data/lib/nukadoko/base.rb +12 -5
  44. data/lib/nukadoko/changed_files.rb +95 -0
  45. data/lib/nukadoko/check.rb +459 -51
  46. data/lib/nukadoko/claim_drops.rb +271 -0
  47. data/lib/nukadoko/claim_line.rb +24 -4
  48. data/lib/nukadoko/claim_rules.rb +143 -1
  49. data/lib/nukadoko/claim_sides.rb +157 -9
  50. data/lib/nukadoko/cli.rb +395 -48
  51. data/lib/nukadoko/codes.json +246 -21
  52. data/lib/nukadoko/codes.rb +21 -4
  53. data/lib/nukadoko/command.rb +120 -13
  54. data/lib/nukadoko/command_help.rb +128 -0
  55. data/lib/nukadoko/compat.rb +469 -0
  56. data/lib/nukadoko/criteria.rb +1 -1
  57. data/lib/nukadoko/definition.rb +157 -7
  58. data/lib/nukadoko/error_frames.rb +6 -3
  59. data/lib/nukadoko/events/count.rb +146 -0
  60. data/lib/nukadoko/events/counted.rb +114 -0
  61. data/lib/nukadoko/events/format.rb +257 -0
  62. data/lib/nukadoko/events/lists.rb +154 -0
  63. data/lib/nukadoko/events/path.rb +285 -0
  64. data/lib/nukadoko/events/read.rb +284 -0
  65. data/lib/nukadoko/events/reader.rb +490 -0
  66. data/lib/nukadoko/events/selection.rb +252 -0
  67. data/lib/nukadoko/events/tally.rb +438 -0
  68. data/lib/nukadoko/features.rb +2 -2
  69. data/lib/nukadoko/fixtures.rb +160 -35
  70. data/lib/nukadoko/http_recording.rb +6 -2
  71. data/lib/nukadoko/intent.rb +364 -0
  72. data/lib/nukadoko/intent_file.rb +81 -0
  73. data/lib/nukadoko/intent_view.rb +190 -0
  74. data/lib/nukadoko/js_json.rb +2 -1
  75. data/lib/nukadoko/judge.rb +2 -2
  76. data/lib/nukadoko/judgment_file.rb +1 -1
  77. data/lib/nukadoko/judgments.rb +4 -4
  78. data/lib/nukadoko/measure_mcp.rb +202 -0
  79. data/lib/nukadoko/parts.rb +8 -2
  80. data/lib/nukadoko/path_view.rb +252 -0
  81. data/lib/nukadoko/place_rows.rb +161 -0
  82. data/lib/nukadoko/program.rb +1265 -51
  83. data/lib/nukadoko/program_log.rb +122 -0
  84. data/lib/nukadoko/program_shape.rb +385 -0
  85. data/lib/nukadoko/project_fixtures.rb +43 -10
  86. data/lib/nukadoko/project_program.rb +5 -4
  87. data/lib/nukadoko/repeated_prefix.rb +310 -0
  88. data/lib/nukadoko/report_run.rb +3 -3
  89. data/lib/nukadoko/run.rb +1148 -159
  90. data/lib/nukadoko/run_record.rb +70 -46
  91. data/lib/nukadoko/scaffold.rb +24 -6
  92. data/lib/nukadoko/schema.rb +15 -2
  93. data/lib/nukadoko/secrets.rb +55 -5
  94. data/lib/nukadoko/states.rb +478 -0
  95. data/lib/nukadoko/step.rb +71 -2
  96. data/lib/nukadoko/step_fixtures.rb +52 -3
  97. data/lib/nukadoko/summary.rb +799 -29
  98. data/lib/nukadoko/table.rb +4 -2
  99. data/lib/nukadoko/text_fit.rb +20 -7
  100. data/lib/nukadoko/trace.rb +152 -45
  101. data/lib/nukadoko/tree_passes.rb +95 -33
  102. data/lib/nukadoko/underneath.rb +311 -0
  103. data/lib/nukadoko/version.rb +1 -1
  104. data/lib/nukadoko/vocabulary.rb +166 -23
  105. data/lib/nukadoko/walk.rb +2 -2
  106. data/lib/nukadoko/walk_step.rb +1 -1
  107. data/lib/nukadoko.rb +23 -0
  108. data/llms.txt +41 -34
  109. data/sig/generated/nukadoko/base.rbs +4 -4
  110. data/sig/generated/nukadoko/changed_files.rbs +42 -0
  111. data/sig/generated/nukadoko/check.rbs +147 -10
  112. data/sig/generated/nukadoko/claim_drops.rbs +135 -0
  113. data/sig/generated/nukadoko/claim_line.rbs +11 -0
  114. data/sig/generated/nukadoko/claim_rules.rbs +49 -4
  115. data/sig/generated/nukadoko/claim_sides.rbs +63 -12
  116. data/sig/generated/nukadoko/cli.rbs +80 -7
  117. data/sig/generated/nukadoko/codes.rbs +19 -4
  118. data/sig/generated/nukadoko/command.rbs +68 -1
  119. data/sig/generated/nukadoko/command_help.rbs +18 -0
  120. data/sig/generated/nukadoko/compat.rbs +392 -0
  121. data/sig/generated/nukadoko/criteria.rbs +1 -1
  122. data/sig/generated/nukadoko/definition.rbs +50 -0
  123. data/sig/generated/nukadoko/error_frames.rbs +1 -1
  124. data/sig/generated/nukadoko/events/count.rbs +69 -0
  125. data/sig/generated/nukadoko/events/counted.rbs +70 -0
  126. data/sig/generated/nukadoko/events/format.rbs +163 -0
  127. data/sig/generated/nukadoko/events/lists.rbs +47 -0
  128. data/sig/generated/nukadoko/events/path.rbs +161 -0
  129. data/sig/generated/nukadoko/events/read.rbs +109 -0
  130. data/sig/generated/nukadoko/events/reader.rbs +226 -0
  131. data/sig/generated/nukadoko/events/selection.rbs +100 -0
  132. data/sig/generated/nukadoko/events/tally.rbs +227 -0
  133. data/sig/generated/nukadoko/features.rbs +6 -4
  134. data/sig/generated/nukadoko/fixtures.rbs +67 -11
  135. data/sig/generated/nukadoko/http_recording.rbs +1 -1
  136. data/sig/generated/nukadoko/intent.rbs +132 -0
  137. data/sig/generated/nukadoko/intent_file.rbs +46 -0
  138. data/sig/generated/nukadoko/intent_view.rbs +69 -0
  139. data/sig/generated/nukadoko/judgment_file.rbs +1 -1
  140. data/sig/generated/nukadoko/judgments.rbs +1 -1
  141. data/sig/generated/nukadoko/measure_mcp.rbs +104 -0
  142. data/sig/generated/nukadoko/parts.rbs +2 -2
  143. data/sig/generated/nukadoko/path_view.rbs +105 -0
  144. data/sig/generated/nukadoko/place_rows.rbs +43 -0
  145. data/sig/generated/nukadoko/program.rbs +627 -23
  146. data/sig/generated/nukadoko/program_log.rbs +67 -0
  147. data/sig/generated/nukadoko/program_shape.rbs +147 -0
  148. data/sig/generated/nukadoko/project_fixtures.rbs +16 -3
  149. data/sig/generated/nukadoko/project_program.rbs +2 -1
  150. data/sig/generated/nukadoko/repeated_prefix.rbs +172 -0
  151. data/sig/generated/nukadoko/report_run.rbs +1 -1
  152. data/sig/generated/nukadoko/run.rbs +286 -41
  153. data/sig/generated/nukadoko/run_record.rbs +20 -12
  154. data/sig/generated/nukadoko/scaffold.rbs +3 -0
  155. data/sig/generated/nukadoko/schema.rbs +5 -0
  156. data/sig/generated/nukadoko/secrets.rbs +26 -3
  157. data/sig/generated/nukadoko/states.rbs +214 -0
  158. data/sig/generated/nukadoko/step.rbs +58 -1
  159. data/sig/generated/nukadoko/step_fixtures.rbs +39 -0
  160. data/sig/generated/nukadoko/summary.rbs +256 -2
  161. data/sig/generated/nukadoko/table.rbs +3 -2
  162. data/sig/generated/nukadoko/trace.rbs +108 -33
  163. data/sig/generated/nukadoko/tree_passes.rbs +36 -8
  164. data/sig/generated/nukadoko/underneath.rbs +141 -0
  165. data/sig/generated/nukadoko/vocabulary.rbs +45 -6
  166. data/skills/nukadoko/SKILL.md +18 -18
  167. data/skills/nukadoko/references/checking-steps.md +16 -83
  168. data/skills/nukadoko/references/diagnosing.md +6 -6
  169. data/skills/nukadoko/references/evidence.md +19 -6
  170. data/skills/nukadoko/references/exploring.md +22 -7
  171. data/skills/nukadoko/references/fixtures.md +12 -32
  172. data/skills/nukadoko/references/judgments.md +12 -0
  173. data/skills/nukadoko/references/maintenance.md +1 -1
  174. data/skills/nukadoko/references/merge-risk.md +1 -1
  175. data/skills/nukadoko/references/parts.md +46 -23
  176. data/skills/nukadoko/references/{perturbed-worlds.md → perturbed-systems.md} +30 -12
  177. data/skills/nukadoko/references/program.md +168 -169
  178. data/skills/nukadoko/references/reviewing.md +20 -20
  179. data/skills/nukadoko/references/ruby/checking-steps.md +106 -0
  180. data/skills/nukadoko/references/ruby/examples/cli.md +212 -0
  181. data/skills/nukadoko/references/ruby/fixtures.md +34 -0
  182. data/skills/nukadoko/references/ruby/program.md +112 -0
  183. data/skills/nukadoko/references/ruby/step-files.md +115 -0
  184. data/skills/nukadoko/references/running.md +34 -34
  185. data/skills/nukadoko/references/scenario-rules.md +7 -6
  186. data/skills/nukadoko/references/states.md +7 -1
  187. data/skills/nukadoko/references/step-files.md +41 -120
  188. data/skills/nukadoko/references/typescript/checking-steps.md +129 -0
  189. data/skills/nukadoko/references/{examples → typescript/examples}/cli.md +1 -1
  190. data/skills/nukadoko/references/{examples → typescript/examples}/http-api.md +6 -6
  191. data/skills/nukadoko/references/{examples → typescript/examples}/workflow.md +1 -1
  192. data/skills/nukadoko/references/typescript/fixtures.md +56 -0
  193. data/skills/nukadoko/references/typescript/program.md +111 -0
  194. data/skills/nukadoko/references/typescript/step-files.md +104 -0
  195. data/skills/nukadoko/references/verdicts.md +10 -10
  196. data/skills/nukadoko/references/writing-steps.md +67 -67
  197. data/skills/nukadoko/references/writing-the-feature.md +1 -1
  198. data/skills/nukadoko-verification/SKILL.md +13 -8
  199. metadata +103 -7
  200. data/skills/nukadoko/references/ruby.md +0 -80
@@ -2,96 +2,31 @@
2
2
 
3
3
  ## The shape of a step file
4
4
 
5
- One step per file, as the file's `default` export. Discovery reads that
6
- export and nothing else, and the file name is the step's name: the
7
- `nuka do <name>` you call it by, and the name every finding and step
8
- record uses for it. Feature files and step files both live under the
9
- configured `featuresDir`, `features` unless the project says otherwise,
10
- with feature files ending in `.feature`. A file a scenario runs as a process (a fake server, a fixture script) belongs outside `featuresDir`: discovery imports every module under it on every `nuka check`, top-level code included.
11
-
12
- Step files end in `.ts`, except in a CommonJS project (no
13
- `"type": "module"` in `package.json`), where they end in `.mts` instead.
14
- Under `"type": "commonjs"`, Node reads a plain `.ts` file as CommonJS, and
15
- nukadoko is ESM-only. With no `"type"`, Node loads a `.ts` file only after
16
- it parses it again, with a `MODULE_TYPELESS_PACKAGE_JSON` warning.
17
- `nuka init` already wrote a matching `nukadoko.config.mts` in that case
18
- (`running.md`, "Setting up"), so the same rule applies to every
19
- step file underneath it.
20
-
21
- Node runs a step file by erasing its types, so write TypeScript that
22
- erases cleanly. Import another step file by its own name, `.ts` included
23
- (`import openAccount from "./open-account.ts"`), the spelling `nuka
24
- scaffold --from` writes. When `tsconfig.json` sets neither
25
- `rewriteRelativeImportExtensions` nor `allowImportingTsExtensions`, or a
26
- file in its `extends` chain cannot be read, scaffold writes `./open-account.js` and a `note:` line instead; `nuka`
27
- loads the `.ts` file under that name, so keep it. Import a type with `import type`: a type imported
28
- without it stays an import and fails with "does not provide an export
29
- named". An `enum`, a `namespace`, or a constructor parameter property does
30
- not load at all; `nuka check` reports `step-file-import-failed` at its
31
- line. Write an object with `as const` and a field assigned in the
32
- constructor instead.
33
-
34
- ```ts
35
- // features/steps/set-product-out-of-stock.ts
36
- import { defineStep, z } from "nukadoko";
37
-
38
- export default defineStep({
39
- pattern: "the product {sku:string} is out of stock",
40
- description: "Set a product's stock to zero",
41
- args: z.object({ sku: z.string().describe("The product's own SKU") }),
42
- returns: z.object({
43
- stock: z.number().describe("The stock left after the write"),
44
- }),
45
- // mutates defaults to true, so a writing step can leave it out; a step
46
- // that only reads has to say mutates: false.
47
- async run({ request }, args) {
48
- const res = await request.post(`/products/${args.sku}/stock`, {
49
- data: { stock: 0 },
50
- });
51
- return res.json();
52
- },
53
- });
54
- ```
55
-
56
- `z` above comes from nukadoko itself, so there is nothing to install
57
- separately for it. If your own project already uses zod and you want to
58
- pass one of its own schemas into a step, that schema needs to be zod 4.
59
-
60
- `pattern` is one string. Use `patterns: [...]` for a step that answers to
61
- more than one line, and omit both for a step only ever reached by name.
62
-
63
- `returns` can be left out. It then defaults to an empty object, and `run`
64
- may return nothing, which fits a Given that only sets something up. A
65
- Then has no `run` at all: it declares `claims`, and an `observe` when
66
- no earlier step returned the value (`checking-steps.md`). A Given or When
67
- that observes something (a page, a response, a file) returns what it
68
- observed, and declares `returns` for it: without one, a returned key
69
- fails the step as `result_invalid`, naming the key.
70
-
71
- `run`'s first argument, and `observe`'s, has to be written as an object destructuring
72
- pattern, every time, because nukadoko reads which fixtures to build from
73
- that pattern's source text without ever calling `run`. A step needing no
74
- fixtures at all writes `run({}, args)`, and one needing neither writes
75
- `run()`. A fixture the project declares in `nukadoko.config.ts` also needs
76
- a `StepFixtures` declaration before `tsc` accepts a step that
77
- destructures it ("Declaring a fixture" in `fixtures.md` shows the block). `run({ sum })` reads `sum` as a fixture; when `sum` is an args
78
- key, `nuka check` says so and names `run({}, { sum })`. Any other parameter, `_ctx` included, is refused. `page`,
79
- `context` and `request` are Playwright's own objects, so reach for
80
- Playwright's documentation for what to call on them rather than guessing.
81
- On the compat door those same `page` and `request` names are harness
82
- getters, not bag fields: `defineWorld` refuses them. `nuka check` reports
83
- `step-file-import-failed`, and `nuka run` stops with the same message,
84
- which names the field. Reach them with `await this.openPage()` and
85
- `await this.openRequest()`.
86
-
87
- A typed step's `run` has a deadline: `stepTimeout` in `nukadoko.config.ts`,
88
- twenty minutes unless the project sets it. A step that waits longer by
89
- design (an export, a batch job) declares its own `timeout` in milliseconds
90
- on `defineStep`, which overrides `stepTimeout` for that step only. There is
91
- no value meaning "no limit". `nuka steps` and `nuka describe` show a
92
- declared `timeout`; a step that shows none runs under `stepTimeout`.
93
- Any other key on `defineStep` (a leftover `rationale`, a misspelling)
94
- does nothing, and `nuka check` warns `step-option-ignored` for it.
5
+ How a step file is written in your engine is in `typescript/step-files.md`
6
+ or `ruby/step-files.md`, with the same headings in both; read the one for
7
+ the config file the project has. What follows holds in both.
8
+
9
+ One step per file. The file name is the step's name: the `nuka do <name>`
10
+ you call it by, and the name every finding and step record uses for it.
11
+ Feature files and step files both live under the configured `featuresDir`,
12
+ `features` unless the project says otherwise, with feature files ending
13
+ in `.feature`. A file a scenario runs as a process (a fake server, a
14
+ fixture script) belongs outside `featuresDir`: discovery loads every file
15
+ under it on every `nuka check`, top-level code included.
16
+
17
+ `returns` can be left out, and the step then returns nothing, which fits
18
+ a Given that only sets something up. A Then has no `run` at all: it
19
+ declares `claims`, and an `observe` when no earlier step returned the
20
+ value (`checking-steps.md`). A Given or When that observes something (a
21
+ page, a response, a file) returns what it observed, and declares
22
+ `returns` for it: without one, a returned key fails the step as
23
+ `result_invalid`, naming the key.
24
+
25
+ nukadoko reads which fixtures a step needs from the parameters of `run`
26
+ and `observe`, without calling them ("The fixtures a step names" on your
27
+ engine's page). `page`, `context`, and `page_as` are Playwright's own
28
+ objects, so reach for Playwright's documentation for what to call on them
29
+ rather than guessing.
95
30
 
96
31
  ## Return more than what a later step cites
97
32
 
@@ -107,12 +42,12 @@ return is exactly what stays missing from that step record too.
107
42
 
108
43
  ## Several people in one scenario
109
44
 
110
- When the app tells people apart by a cookie, give each person a browser context of their own:
111
- `await pageAs(name, { javaScriptEnabled: false })` returns Playwright's
112
- `Page` (a `context.newPage()` tab shares cookies). Later calls for a name
113
- return the same page; other options there throw. A name is 1 to 64
114
- lowercase letters, digits, and hyphens, starting with a letter or digit, or it throws:
115
- take it from the feature line, lowercased (`pageAs(name.toLowerCase())`); records tag it with `as`.
45
+ When the app tells people apart by a cookie, give each person a browser
46
+ context of their own (`pageAs`, "Several people in one scenario" on your
47
+ engine's page). Later calls for a name return the same page; other
48
+ options there throw. A name is 1 to 64 lowercase letters, digits, and
49
+ hyphens, starting with a letter or digit, or it throws: take it from the
50
+ feature line, lowercased. Records tag it with `as`.
116
51
 
117
52
  ## `page.goto` and baseURL
118
53
 
@@ -150,25 +85,19 @@ opens a capture. A literal one is escaped with a backslash, `I POST this
150
85
  body to \/items`, which a JSON string in the step file writes as
151
86
  `"I POST this body to \\/items"`. Unescaped, `nuka scaffold` refuses the
152
87
  pattern and `nuka check` reports `pattern-syntax-error`, both naming the
153
- column (`examples/http-api.md`).
88
+ column (`typescript/examples/http-api.md`).
154
89
 
155
90
  Do not carry a list of type names around. Get one wrong and `nuka check`
156
91
  prints the parameter types **this** project has registered, custom ones
157
- from `nukadoko.config.ts` included, which is the only list that is true
92
+ from the config included, which is the only list that is true
158
93
  here rather than true of nukadoko in general.
159
94
 
160
95
  Add to that list instead of working around it when a pattern keeps
161
- needing the same shape spelled out by hand. `parameterTypes` in
162
- `nukadoko.config.ts` takes a `{ name, regexp, transformer? }` entry per
163
- type: a `negation` type matching an optional `" not"` and turning it into
164
- a `z.boolean()` lets a pattern write `will{negated:negation} return`
165
- straight into an `args` key of that type. `transformer` only coerces the
166
- matched text. It runs with the scenario's World as `this`, and a Promise
167
- it returns is awaited before the step. The `args` schema is still what
168
- actually validates it. The
169
- one thing a project cannot do is redefine a built-in name (`int`,
170
- `string`, and the rest): that would quietly change what every pattern
171
- already using it means.
96
+ needing the same shape spelled out by hand: `parameterTypes` in the
97
+ config ("Parameter types" on your engine's page). The `args` schema is
98
+ still what validates the value. The one thing a project cannot do is
99
+ redefine a built-in name (`int`, `string`, and the rest): that would
100
+ quietly change what every pattern already using it means.
172
101
 
173
102
  The pattern and the schema are checked against each other, both ways: a
174
103
  key the pattern captures that `args` has no field for is an error, and so
@@ -177,22 +106,14 @@ Neither side can drift away from the other quietly, so adding an `args`
177
106
  field and forgetting the capture costs you one `nuka check`, never a
178
107
  browser session.
179
108
 
180
- `capture-type-mismatch` is the type half of that comparison: the JS type
109
+ `capture-type-mismatch` is the type half of that comparison: the type
181
110
  of a built-in capture against the field's primitive type. `{int}`,
182
111
  `{float}`, `{double}`, `{byte}`, `{short}`, and `{long}` give a number;
183
112
  `{word}`, `{string}`, the anonymous `{key:}`, and `{bigdecimal}` give a
184
113
  string; `{biginteger}` gives a bigint. A number capture against a string
185
114
  or boolean field is the finding, and so is any other pair that differs. A
186
- pipe or transform is read through its input side. A union, `z.any()`, a
187
- preprocess, and a custom parameter type are never reported. It does not fire when the schema coerces the captured value
188
- (`z.coerce.number()` for a `{string}`, `z.coerce.string()` for an
189
- `{int}`), because the run accepts that capture. A field that does not
190
- coerce still is that finding. The one-line description is `nuka check
191
- --codes`.
192
-
193
- A record stores a bigint as its decimal string, and `nuka do --args`
194
- takes a `z.bigint()` field the same way (`{"count":"123"}`), not as a JSON
195
- number.
115
+ field that accepts more than one type, and a custom parameter type, are
116
+ never reported.
196
117
 
197
118
  Capturing the same key twice in one pattern is refused too. One args
198
119
  field holds one value, and keeping the last capture would drop the
@@ -0,0 +1,129 @@
1
+ # Claim steps in TypeScript
2
+
3
+ What a claim means, where its values come from, and every compare are in
4
+ `../checking-steps.md`. This page is how a TypeScript step file writes one.
5
+
6
+ ## A claim step
7
+
8
+ A Then declares `claims` in place of `run`. `defineStep` refuses a claim
9
+ step that also declares `run`, `returns`, `mutates`, or `parts`. Write
10
+ claims as plain data (no getter, Proxy, class instance, hole, or unknown
11
+ key) and export what `defineStep` returned: it validates one frozen copy,
12
+ and a copy of the step (`{ ...step }`) fails. A key the line states is
13
+ required in `args`, with no default, and its schema must not rewrite the
14
+ value: `z.coerce`, a transform, a pipe, `trim`, `catch`, a default inside,
15
+ or a refine on an object, an array, or the args object is refused.
16
+
17
+ ```ts
18
+ // conformance/cases/cli/steps-ts/exits-with.ts
19
+ import { defineStep, z } from "nukadoko";
20
+ import runTally from "./run-tally.ts";
21
+
22
+ export default defineStep({
23
+ description: "The process exit code is exactly this",
24
+ pattern: "it exits with {code:int}",
25
+ args: z.object({
26
+ code: z.number().describe("The expected exit code"),
27
+ exitCode: runTally.returns.shape.exitCode,
28
+ }),
29
+ from: {
30
+ exitCode: [runTally, "exitCode"],
31
+ },
32
+ claims: [{ actual: "exitCode", compare: "equal", expected: "code" }],
33
+ });
34
+ ```
35
+
36
+ ## An expected value an earlier step returned
37
+
38
+ `from` names the step and its key; the step is imported, so a rename is a
39
+ type error, and `<step>.returns.shape.<key>` reuses its schema.
40
+
41
+ ```ts
42
+ // conformance/cases/http-api/steps-ts/list-has-created-item.ts
43
+ import { defineStep, z } from "nukadoko";
44
+ import anItemExists from "./an-item-exists.ts";
45
+ import listItems from "./list-items.ts";
46
+
47
+ export default defineStep({
48
+ description: "The item list holds the item an earlier step created, id and name",
49
+ pattern: "the list has the item that was created",
50
+ args: z.object({
51
+ body: z.unknown().describe("The list the request got"),
52
+ created: anItemExists.returns.shape.body,
53
+ }),
54
+ from: { body: [listItems, "body"], created: [anItemExists, "body"] },
55
+ claims: [{ actual: "body", compare: "has-item", expected: { from: "created" } }],
56
+ });
57
+ ```
58
+
59
+ ## Observe and poll
60
+
61
+ `observe(fixtures, args)` takes the same destructured first argument as
62
+ `run`. Give every `args` and `returns` field a `.describe()`, so
63
+ `nuka describe` connects a criterion's wording to the field that answers
64
+ it. `poll` is `{ timeout_ms, settled? }`, or `false`.
65
+
66
+ ```ts
67
+ // conformance/cases/poll/steps-ts/job-ends.ts
68
+ import { defineStep, z } from "nukadoko";
69
+ import startJob from "./start-job.ts";
70
+
71
+ export default defineStep({
72
+ pattern: "the job ends {wanted:string}",
73
+ description: "The job an earlier step started reaches this status in GET /jobs/:id",
74
+ args: z.object({
75
+ wanted: z.string().describe("The status the job is expected to reach"),
76
+ id: startJob.returns.shape.id,
77
+ }),
78
+ from: { id: [startJob, "id"] },
79
+ async observe({ request }, { id }) {
80
+ const res = await request.get(`/jobs/${id}`);
81
+ const job = (await res.json()) as { status: string };
82
+ return { status: job.status };
83
+ },
84
+ poll: { timeout_ms: 3000, settled: [{ actual: "status", compare: "not-equal", expected: { literal: "running" } }] },
85
+ claims: [{ actual: "status", compare: "equal", expected: "wanted" }],
86
+ });
87
+ ```
88
+
89
+ ## A page by role and name
90
+
91
+ `observe` returns the page or a locator, and nukadoko takes its ARIA
92
+ snapshot. A When may still wait with Playwright's `expect` before it acts;
93
+ outside `playwright test`, on Playwright 1.61.1, a failing `expect.soft`
94
+ throws at once, and `toMatchAriaSnapshot`, `toHaveScreenshot`, and
95
+ `toMatchSnapshot` throw `"<name>() must be called during the test"`.
96
+
97
+ ```ts
98
+ // conformance/engine/projects/claim-aria/steps-ts/scores-form-shows.ts
99
+ import { defineStep, z } from "nukadoko";
100
+
101
+ export default defineStep({
102
+ pattern: "the scores form shows",
103
+ description: "The scores form's accessibility tree against the tree the docstring states",
104
+ args: z.object({ tree: z.string().describe("Part of the ARIA snapshot the form shows") }),
105
+ observe: ({ page }) => ({ form: page.getByRole("form", { name: "Scores" }) }),
106
+ poll: { timeout_ms: 2000 },
107
+ claims: [{ actual: "form", compare: "fits-aria-snapshot", expected: "tree" }],
108
+ });
109
+ ```
110
+
111
+ ## The files an earlier step changed
112
+
113
+ `files` names the paths the commands of an earlier step changed, read
114
+ from that step's record, and a claim reads the key as its actual. Its
115
+ expected value is the sentence's: a capture, the docstring, or a word.
116
+
117
+ ```ts
118
+ // conformance/engine/projects/changed-files/steps-ts/notes-include.ts
119
+ import { defineStep, z } from "nukadoko";
120
+ import writeNotes from "./write-notes.ts";
121
+
122
+ export default defineStep({
123
+ pattern: "the notes include {path:string}",
124
+ description: "The notes the program added include one path",
125
+ args: z.object({ path: z.string().describe("A path under notes/") }),
126
+ files: { written: { of: writeNotes, change: "added", under: "notes" } },
127
+ claims: [{ actual: "written", compare: "has-item", expected: "path" }],
128
+ });
129
+ ```
@@ -5,7 +5,7 @@ nukadoko 0.16.1 and rescaffolded with the releases after it (which added
5
5
  `nuka scaffold --cwd` and then `--argv`, and moved its Thens to claims) on Node 24.22.0. Every output block below is copied
6
6
  from a real run of that project, which is `examples/acceptance/cli/` in
7
7
  the nukadoko repository; CI runs it. The rules it follows are in
8
- `../scenario-rules.md`.
8
+ `../../scenario-rules.md`.
9
9
 
10
10
  ## The ticket
11
11
 
@@ -6,7 +6,7 @@ in the release after 0.21.0, which also put the count behind a switch,
6
6
  and that program moved into `nukadoko.config.ts` in the release after 0.26.0. Every output block below is copied from a real run of
7
7
  that project, which is `examples/acceptance/http-api/` in the nukadoko
8
8
  repository; CI runs it. The rules it follows are in
9
- `../scenario-rules.md`.
9
+ `../../scenario-rules.md`.
10
10
 
11
11
  ## The ticket
12
12
 
@@ -100,7 +100,7 @@ Feature: items API
100
100
  `count-off`. `ITEM_COUNT` is `{condition.item_count}`, so the server
101
101
  reads the side its environment declares. The server starts each log line with
102
102
  the request's `traceparent`, so each step record holds the server's
103
- lines for its own requests in `program-log.txt`.
103
+ lines for its own requests in `program-log.main.txt`.
104
104
  - `an-item-exists` (Given): POSTs a name and returns the `id` the API
105
105
  assigned and the `body` it answered.
106
106
  - `create-item` (When): `I POST this body to \/items`; sends the docstring
@@ -293,9 +293,9 @@ criteria: 7 held, 1 proven, 0 failed
293
293
  ```
294
294
 
295
295
  Each environment opens with three lines, cut above after the first:
296
- `environment count-off`, `world count-off: serve started:` with the
297
- command and the ready URL it waits for, then `world count-off: serve
298
- 0.1s, http://localhost:<port>` with the path of the world's `program.log`,
296
+ `environment count-off`, `system count-off: serve started:` with the
297
+ command and the ready URL it waits for, then `system count-off: serve
298
+ 0.1s, http://localhost:<port>` with the path of the system's `program.log`,
299
299
  which holds what the server printed. The first version's
300
300
  `repeated-scenario-prefix` note is gone: the two scenarios that create an
301
301
  item no longer begin with the same line.
@@ -334,7 +334,7 @@ control's 2 runs, and the summary opens with the table:
334
334
  | 2026-10-16 | The whole body against a docstring, or one claim per field | the whole body | the ticket names the body's fields; a scenario per field would repeat the request | none |
335
335
  | 2026-10-17 | Acting on `repeated-scenario-prefix` | not acted on | the shared Given writes state the scenario reads | S8 |
336
336
  | 2026-10-17 | `mutates` on the POST steps | the default `true`, no go-ahead | they change the API's state, but only on the server the fixture started | SKILL.md "Before the first command" |
337
- | 2026-10-24 | Where the API server runs | the program, one server for the run | the program is how nukadoko starts a program, and its `program.log` and run.json's `worlds` say which program answered; a fixture that starts one in-process says neither | S8 |
337
+ | 2026-10-24 | Where the API server runs | the program, one server for the run | the program is how nukadoko starts a program, and its `program.log` and run.json's `systems` say which program answered; a fixture that starts one in-process says neither | S8 |
338
338
  | 2026-10-24 | Expected bodies against a shared server | claims on what the scenario created: the name it sent, an id of at least 1, the body its Given returned | the exact bodies broke as soon as an earlier scenario had created an item (measured above) | S8 |
339
339
  | 2026-10-24 | The unknown id | `0` | the API numbers items from 1, so no run reaches it; `42` exists once a run, or `--repeat`, has created 42 items | none |
340
340
  | 2026-10-24 | A criterion behind a switch | two environments, `count-off` and `count-on`, with `conditions`, and `@with:item_count` on the scenario | one run shows the scenario breaking where the switch is off, a control that proves it; a scenario that only ran with the switch on would say nothing about whether it notices the count | none |
@@ -5,7 +5,7 @@ test directly, built with nukadoko 0.16.1 on Node 24.22.0, with its Thens
5
5
  moved to claims in the release after 0.21.0. Every output
6
6
  block below is copied from a real run of that project, which is
7
7
  `examples/acceptance/workflow/` in the nukadoko repository; CI runs it.
8
- The rules it follows are in `../scenario-rules.md`.
8
+ The rules it follows are in `../../scenario-rules.md`.
9
9
 
10
10
  ## The ticket
11
11
 
@@ -0,0 +1,56 @@
1
+ # Fixtures in TypeScript
2
+
3
+ When to declare a fixture, and how setup and teardown run, are in
4
+ `../fixtures.md`. This page is how `nukadoko.config.ts` declares one.
5
+
6
+ ## A project fixture
7
+
8
+ `defineFixtures` in the config's `fixtures` declares each one. A fixture
9
+ receives the fixtures it names and a `use` function; what follows
10
+ `await use(value)` is its teardown. `[fixture, { scope: "process" }]`
11
+ keeps one value for the whole run of an environment.
12
+
13
+ ```ts
14
+ // conformance/cases/workflow/config.ts
15
+ import { defineConfig, defineFixtures } from "nukadoko";
16
+ import { createStore, type Store } from "./src/signup.ts";
17
+
18
+ export default defineConfig({
19
+ fixtures: defineFixtures({
20
+ store: async ({}, use) => { await use(createStore()); },
21
+ }),
22
+ });
23
+
24
+ declare module "nukadoko" {
25
+ interface StepFixtures {
26
+ store: Store;
27
+ }
28
+ }
29
+ ```
30
+
31
+ `tsc` needs the `declare module` block: without it, a step that
32
+ destructures `store` fails with `Property 'store' does not exist on type
33
+ 'FixtureBag'`. `nuka check` does not need it, because it reads fixture
34
+ names from the source text. A step reaches the fixture the same way it
35
+ reaches `page`: `async run({ store }, args)`.
36
+
37
+ ## Replacing a built-in
38
+
39
+ A fixture named like a built-in replaces it for every step, and receives
40
+ the built-in under the same name.
41
+
42
+ ```ts
43
+ // conformance/cases/page-override/config.ts
44
+ import { defineConfig, defineFixtures } from "nukadoko";
45
+
46
+ export default defineConfig({
47
+ fixtures: defineFixtures({
48
+ page: async ({ page }, use) => {
49
+ await page.addInitScript(() => {
50
+ (window as unknown as { wrapped: string }).wrapped = "by the project";
51
+ });
52
+ await use(page);
53
+ },
54
+ }),
55
+ });
56
+ ```
@@ -0,0 +1,111 @@
1
+ # The program in TypeScript
2
+
3
+ What the program is, how a system starts it, and every field are in
4
+ `../program.md`. This page is how `nukadoko.config.ts` writes it.
5
+
6
+ ## The program
7
+
8
+ `program` is a function that returns how the program starts. A command
9
+ is an argv array, or a string split on whitespace.
10
+
11
+ ```ts
12
+ import { defineConfig } from "nukadoko";
13
+
14
+ export default defineConfig({
15
+ program: () => ({
16
+ build: ["npm run build"], // once per run, in the tree's root
17
+ prepare: ["node dist/migrate.js"], // once per system, with env below
18
+ serve: { command: "node dist/server.js", ready: "/health" },
19
+ env: { PORT: "{port}", DATABASE_PATH: "{dir}/app.sqlite3" },
20
+ }),
21
+ });
22
+ ```
23
+
24
+ ## Several services
25
+
26
+ Each service is an entry of `services`, with its own fields and `root`,
27
+ and `primary` names the one the steps reach. An environment moves a
28
+ service to a URL under its own `services`, so the same steps run there:
29
+
30
+ ```ts
31
+ export default defineConfig({
32
+ program: () => ({
33
+ primary: "shop",
34
+ services: {
35
+ shop: {
36
+ serve: { command: "node relay.mjs --port {port}", ready: "/whoami" },
37
+ env: { NAME: "shop", PEER_URL: "{service.billing.url}" },
38
+ },
39
+ billing: {
40
+ root: "billing",
41
+ serve: { command: "node ../relay.mjs --port {port}", ready: "/whoami" },
42
+ env: { NAME: "billing", PEER_URL: "{service.shop.url}" },
43
+ },
44
+ },
45
+ environments: {
46
+ local: {},
47
+ staging: { services: { shop: { url: "https://shop.staging.acme.example" }, billing: { url: "https://billing.staging.acme.example" } } },
48
+ },
49
+ defaultEnvironments: ["local"],
50
+ }),
51
+ });
52
+ ```
53
+
54
+ A step destructures `services` and reads a service by name; a name the
55
+ program does not write throws `UnknownServiceError`:
56
+
57
+ ```ts
58
+ async run({ request, services }) {
59
+ const response = await request.get(`${services.billing!.url}/whoami`);
60
+ return { name: ((await response.json()) as { name: string }).name };
61
+ },
62
+ ```
63
+
64
+ ## Steps reach
65
+
66
+ `stepsReach: "url"` makes a service URL the only way into the program, so
67
+ `runCommand` throws `CommandRefusedError` there instead of starting a
68
+ process. The program's own test API, called by `setup`, is what seeds the
69
+ system then, and every step reads what `setup` returned as `setupResult`:
70
+
71
+ ```ts
72
+ export default defineConfig({
73
+ program: () => ({
74
+ stepsReach: "url",
75
+ serve: { command: "bin/rails server -p {port}", ready: "/up" },
76
+ setup: async ({ url, conditions }) => {
77
+ const answer = await fetch(`${url}/test/tenants`, {
78
+ method: "POST",
79
+ headers: { "content-type": "application/json" },
80
+ body: JSON.stringify({ flags: conditions }),
81
+ });
82
+ return { tenant: ((await answer.json()) as { tenant: string }).tenant };
83
+ },
84
+ environments: { scratch: { stepsReach: "any" }, staging: { url: "https://staging.acme.example" } },
85
+ }),
86
+ });
87
+ ```
88
+
89
+ The value's shape is the project's own, declared once, so every step that
90
+ reads it is checked against it:
91
+
92
+ ```ts
93
+ declare module "nukadoko" {
94
+ interface SetupResult {
95
+ tenant: string;
96
+ }
97
+ }
98
+ ```
99
+
100
+ ## Environments
101
+
102
+ An entry of `environments` overrides any field of the program, and
103
+ `env` merges by key:
104
+
105
+ ```ts
106
+ env: { CHECKOUT_V2: "{condition.checkout_v2}" },
107
+ environments: {
108
+ "checkout-v1": { conditions: { checkout_v2: false } },
109
+ "checkout-v2": { conditions: { checkout_v2: true } },
110
+ },
111
+ ```