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
|
@@ -0,0 +1,505 @@
|
|
|
1
|
+
# Migrating a cucumber-js + Playwright suite
|
|
2
|
+
|
|
3
|
+
For teams with an existing cucumber-js suite running against Playwright,
|
|
4
|
+
feature files and step definitions living under `features/` (cucumber-js's
|
|
5
|
+
own layout convention, and nukadoko's default too). No rewrite: the goal is
|
|
6
|
+
to run the suite, unchanged, on nukadoko's harness, then promote pieces at
|
|
7
|
+
your own pace. An existing suite can be CommonJS (no `"type": "module"` in
|
|
8
|
+
its own `package.json`); this door works there too, using `.mts` in place
|
|
9
|
+
of `.ts` for both nukadoko's config and its step files (Stage 0 below). For
|
|
10
|
+
a full worked example of every stage below, with real captured command
|
|
11
|
+
output, see
|
|
12
|
+
[examples/migration](https://github.com/meganemura/nukadoko/tree/main/typescript/examples/migration).
|
|
13
|
+
|
|
14
|
+
Nothing below applies if there is no cucumber-js suite to begin with. A
|
|
15
|
+
project already running Playwright Test directly, with no feature files and
|
|
16
|
+
no glue to switch, starts from a different door instead: see
|
|
17
|
+
[docs/typescript/migration-playwright-test.md](migration-playwright-test.md). A suite
|
|
18
|
+
already shaped as typed steps, in a DSL of its own, starts at
|
|
19
|
+
[Coming from a typed-step DSL](#coming-from-a-typed-step-dsl). Whatever the
|
|
20
|
+
starting point, [Working rules](#working-rules) holds on every path; an
|
|
21
|
+
agent doing the migration reads it before the first change.
|
|
22
|
+
|
|
23
|
+
## Stage 0: install and point nukadoko at your suite
|
|
24
|
+
|
|
25
|
+
Install nukadoko, then run `nuka init` (or hand-write `nukadoko.config.ts`)
|
|
26
|
+
from the project root:
|
|
27
|
+
|
|
28
|
+
```ts
|
|
29
|
+
import { defineConfig } from "nukadoko";
|
|
30
|
+
|
|
31
|
+
export default defineConfig({
|
|
32
|
+
featuresDir: "features", // point this at your existing features/
|
|
33
|
+
});
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
The app under test goes in the same file, as `program`. A suite that
|
|
37
|
+
starts the app itself today (a `BeforeAll` hook, a shell script, a CI
|
|
38
|
+
step) moves that recipe there, and nukadoko starts the app on a port of its
|
|
39
|
+
own for each run and stops it after:
|
|
40
|
+
|
|
41
|
+
```ts
|
|
42
|
+
import { defineConfig } from "nukadoko";
|
|
43
|
+
|
|
44
|
+
export default defineConfig({
|
|
45
|
+
featuresDir: "features",
|
|
46
|
+
program: () => ({
|
|
47
|
+
serve: { command: "npm start", ready: "/" }, // how the app under test starts
|
|
48
|
+
env: { PORT: "{port}" },
|
|
49
|
+
}),
|
|
50
|
+
});
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
A suite that runs against an app someone else starts writes
|
|
54
|
+
`url: "http://localhost:..."` there instead of `serve`. "Program" in
|
|
55
|
+
docs/spec.md has every field.
|
|
56
|
+
|
|
57
|
+
In a CommonJS suite, `nuka init` writes `nukadoko.config.mts` instead
|
|
58
|
+
(same content, and it says so on stderr); step files need the same `.mts`
|
|
59
|
+
extension there. Under `"type": "commonjs"`, Node reads a plain `.ts` file
|
|
60
|
+
as CommonJS, and nukadoko is ESM-only, so a hand-written
|
|
61
|
+
`nukadoko.config.ts` fails to import. The error names that file and the
|
|
62
|
+
cause, and, because the file is `.ts`, says to rename it to `.mts`. With no
|
|
63
|
+
`"type"`, Node loads a `.ts` file only after it parses it again, with a
|
|
64
|
+
`MODULE_TYPELESS_PACKAGE_JSON` warning on every load.
|
|
65
|
+
|
|
66
|
+
`nuka init` refuses to run if `nukadoko.config.ts` or `nukadoko.config.mts`
|
|
67
|
+
already exists, creates `<featuresDir>/steps/`, adds `.nukadoko/`, `.env`, and `.env.*` to
|
|
68
|
+
`.gitignore` (with `!.env.example` to keep the example tracked), and ends with a self-check that discovers the (still empty)
|
|
69
|
+
vocabulary. `featuresDir` defaults to `features` (cucumber-js's own
|
|
70
|
+
convention), so most suites need no override; discovery walks the whole
|
|
71
|
+
directory, so step files living elsewhere under it
|
|
72
|
+
(`features/step_definitions/`, `features/support/`) need no reshuffling
|
|
73
|
+
either.
|
|
74
|
+
|
|
75
|
+
A cucumber-js suite that reads `this.parameters` was given that object by
|
|
76
|
+
`worldParameters` in its cucumber.js profile, or by `--world-parameters`
|
|
77
|
+
on the command line. Put the same object on `worldParameters` in
|
|
78
|
+
`nukadoko.config.ts`. The World constructor receives it as `parameters`.
|
|
79
|
+
The default is `{}`. There is no command line flag for it: the config key
|
|
80
|
+
is the only place the object is set.
|
|
81
|
+
|
|
82
|
+
```ts
|
|
83
|
+
export default defineConfig({
|
|
84
|
+
worldParameters: { baseUrl: "http://localhost:..." },
|
|
85
|
+
});
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
## Stage 1: switch the import
|
|
89
|
+
|
|
90
|
+
Change the one import your step files use:
|
|
91
|
+
|
|
92
|
+
```ts
|
|
93
|
+
// before: import { Given, When, Then } from "@cucumber/cucumber";
|
|
94
|
+
import { Given, When, Then } from "nukadoko/compat";
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
Everything below that import keeps working, unchanged, except for the
|
|
98
|
+
differences listed under [Known limits](#known-limits):
|
|
99
|
+
|
|
100
|
+
- string and RegExp patterns, matched exactly as cucumber-js matches them
|
|
101
|
+
(no named-capture requirement: that discipline belongs to typed steps).
|
|
102
|
+
- both registration shapes: `Given(pattern, fn)` and
|
|
103
|
+
`Given(pattern, { timeout }, fn)`, with that timeout honored.
|
|
104
|
+
- a `World` (`this`); `Before`/`After` hooks written any of the three ways
|
|
105
|
+
cucumber-js accepts (`Before(fn)`, `Before({ tags }, fn)`, or the
|
|
106
|
+
bare-string `Before("@tag", fn)`), filtered by a single `@tag` or
|
|
107
|
+
`not @tag`; custom `setWorldConstructor` subclasses. A hook receives
|
|
108
|
+
cucumber's hook parameter, so `Before(function ({ pickle }) {...})` works
|
|
109
|
+
as written. `After` receives `result.duration`, and `result.message` and
|
|
110
|
+
`error` when the scenario failed. `AfterStep` receives those too, plus
|
|
111
|
+
`pickleStep` and `testStepId` for the step that just ran.
|
|
112
|
+
- `this.attach` in cucumber-js's forms: a string, including
|
|
113
|
+
`base64:<media type>` (decoded into the file), a buffer,
|
|
114
|
+
`{ mediaType, fileName }`, and a readable stream. A stream returns a
|
|
115
|
+
promise, so the step awaits it. `this.link` takes one or more URLs, one
|
|
116
|
+
declared link each. A second argument is another URL, not a name.
|
|
117
|
+
- A custom World constructor that throws fails that scenario. stderr gets
|
|
118
|
+
one setup line, the scenario record is failed and cites no step record,
|
|
119
|
+
later scenarios in the same run still execute, and the messages export
|
|
120
|
+
is finalized.
|
|
121
|
+
- `{ name }` on `Before`, `After`, `BeforeAll`, and `AfterAll`. The string
|
|
122
|
+
is stored and used as the hook's title. It does not change which
|
|
123
|
+
scenarios run, the timeout, or the order. `AfterStep` does not accept
|
|
124
|
+
`name`. `BeforeAll` and `AfterAll` still reject `on`, because that option
|
|
125
|
+
chooses which process runs the hook.
|
|
126
|
+
- `AfterStep`, registered the same three ways as `Before`/`After`. It runs
|
|
127
|
+
once per step that actually executed in the scenario, not once for the
|
|
128
|
+
whole scenario the way `Before`/`After` do: a step this scenario skipped
|
|
129
|
+
because an earlier one already failed never began, so `AfterStep` doesn't
|
|
130
|
+
run for it either: there is no "after" for a step that never started.
|
|
131
|
+
- `Status`, cucumber-js's own `TestStepResultStatus` enum, re-exported under
|
|
132
|
+
the same name: `result.status === Status.FAILED` inside a `Before` /
|
|
133
|
+
`After` / `AfterStep` hook now imports and compares correctly.
|
|
134
|
+
- `DataTable` (`raw()`/`rows()`/`hashes()`/`rowsHash()`/`transpose()`): a
|
|
135
|
+
step calling `table.hashes()` keeps working exactly as written (zero
|
|
136
|
+
friction, measured migrating examples/migration's own suite).
|
|
137
|
+
- `allure.*` calls (`attach`/`log`/`link`, labels, parameters) inside
|
|
138
|
+
glue: they land in the step record's `declared` field, not vanishing.
|
|
139
|
+
- `setDefaultTimeout(ms)`, filling in for any step or hook that didn't
|
|
140
|
+
declare its own timeout, last call winning as in cucumber-js. A negative
|
|
141
|
+
value means no timeout, including `setDefaultTimeout(-1)` and a step or
|
|
142
|
+
hook `{ timeout: -1 }`. Zero still times out. Never calling it leaves
|
|
143
|
+
steps unbounded rather than adopting cucumber's 5-second default: a suite
|
|
144
|
+
shouldn't start failing for slow steps because it migrated.
|
|
145
|
+
- `BeforeAll` / `AfterAll`, bracketing the whole run, with `{ timeout }` if
|
|
146
|
+
you pass one. They run only when at least one scenario was selected, take
|
|
147
|
+
no `tags`, and get no World (`this`): none exists yet when `BeforeAll`
|
|
148
|
+
runs. `BeforeAll` stops at its first failure and no scenario runs;
|
|
149
|
+
`AfterAll` is attempted anyway, every registration runs even if a sibling
|
|
150
|
+
threw, and teardown unwinds in reverse registration order.
|
|
151
|
+
|
|
152
|
+
### What the switch does not carry
|
|
153
|
+
|
|
154
|
+
Eight public cucumber-js suites were audited against this door, their glue
|
|
155
|
+
read as text and never run. **When that audit ran, none of them went
|
|
156
|
+
through on the import switch alone.** Supporting the most common blockers
|
|
157
|
+
it found has since brought two of the eight to where nothing in their glue
|
|
158
|
+
is rejected any more; the other six still need a short pass first. (Read as
|
|
159
|
+
a static claim, which is what it is: their glue no longer contains anything
|
|
160
|
+
this door turns away. Nobody ran those suites.) Everything below fails
|
|
161
|
+
loudly, but not all at the same moment: some of it `nuka check` already
|
|
162
|
+
names before you run anything, some of it only surfaces on the first
|
|
163
|
+
`nuka run` that reaches the step: each item below says which, so the pass
|
|
164
|
+
is a list you can work through, not a hunt. A difference that changes a
|
|
165
|
+
value without a failure is not on this list. [Known limits](#known-limits)
|
|
166
|
+
lists the measured ones.
|
|
167
|
+
|
|
168
|
+
- **`setParallelCanAssign`, used as a value**: `nukadoko/compat` does not
|
|
169
|
+
export it. An ES module's named import is resolved at link time, so
|
|
170
|
+
importing it and calling it takes the whole import statement (and with
|
|
171
|
+
it the file) down; split the import or drop the call. Caught before
|
|
172
|
+
anything runs: `nuka check` reports the file as `step-file-import-failed`,
|
|
173
|
+
carrying Node's own error message; if `check` was skipped, the same
|
|
174
|
+
failure surfaces on the first `nuka run` that tries to import the file.
|
|
175
|
+
This name stays unsupported by decision because `setParallelCanAssign`
|
|
176
|
+
decides which pickle a worker may receive. nukadoko distributes whole feature
|
|
177
|
+
files, so its worker assignment has no pickle-level decision for this
|
|
178
|
+
callback to control. Declare file-level mutual exclusion with an
|
|
179
|
+
`@nukadoko:serial` tag on the feature. Accepting the call as a
|
|
180
|
+
no-op would be worse than refusing it: it would import cleanly, run, and
|
|
181
|
+
leave a suite believing its parallel-assignment rule was in effect while
|
|
182
|
+
nothing enforced it, exactly the quiet failure this door exists to refuse
|
|
183
|
+
(docs/typescript/doors.md "Compat steps (the migration door)"). Failing at the import
|
|
184
|
+
instead keeps that promise, the same way every other name on this list
|
|
185
|
+
fails. `nuka run --concurrency <n>` is what hands those whole feature
|
|
186
|
+
files to worker processes.
|
|
187
|
+
(`AfterStep`, `Status`, `BeforeAll`, `AfterAll` and `setDefaultTimeout`
|
|
188
|
+
were on this list when the audit ran and are now supported; see above.)
|
|
189
|
+
- **The same kind of name, used only as a type** is a different case, not a
|
|
190
|
+
smaller version of the one above, and it depends on how the import is
|
|
191
|
+
written. Node loads glue by type stripping, which erases an `import type`
|
|
192
|
+
(or an inline `type` name) and keeps every other import. Written with
|
|
193
|
+
`type`, nothing by that name is imported at run time: neither `nuka
|
|
194
|
+
check` nor `nuka run` sees anything wrong, and only `tsc` complains,
|
|
195
|
+
which is `tsc`'s job. Written without `type`, the import stays, and the
|
|
196
|
+
file fails with Node's "does not provide an export named" error, which
|
|
197
|
+
`nuka check` reports as `step-file-import-failed`; for a type that
|
|
198
|
+
`nukadoko/compat` exports, the finding says so. Add `type` to such an
|
|
199
|
+
import; `"verbatimModuleSyntax": true` makes `tsc` find every one.
|
|
200
|
+
cucumber-js glue often imports `IWorldOptions` beside `World` without
|
|
201
|
+
`type`, so this is worth a search before the first run. (`IWorldOptions` and
|
|
202
|
+
`ITestCaseHookParameter`, the audit's own examples of this category, are
|
|
203
|
+
now exported, aliases for `WorldConstructorParams`/`HookParameter`, and
|
|
204
|
+
typecheck the same as any other compat name.)
|
|
205
|
+
- **CommonJS glue**: nukadoko is ESM-only. Extension decides how discovery
|
|
206
|
+
treats a file: `.ts`, `.mts`, `.js`, and `.mjs` are all walked and
|
|
207
|
+
imported now (a suite written entirely in plain `.js`, not just `.ts`, is
|
|
208
|
+
no longer invisible to discovery the way it used to be); a `.cjs` or `.cts`
|
|
209
|
+
file is walked far enough to be named, never imported at all, so it never reaches
|
|
210
|
+
an import to fail -- `nuka check` reports it as
|
|
211
|
+
`step-file-unsupported-extension` instead. Inside a file discovery does
|
|
212
|
+
import, `require("nukadoko/compat")` still fails outright with
|
|
213
|
+
`ERR_PACKAGE_PATH_NOT_EXPORTED`, the same as it always has: an extension
|
|
214
|
+
alone does not make a file's own code ES module glue. Two of the eight
|
|
215
|
+
suites are CommonJS throughout; the door admits ES module glue only.
|
|
216
|
+
Caught before anything runs either way: `step-file-unsupported-extension`
|
|
217
|
+
for a `.cjs` or `.cts` file, or `nuka check`'s `step-file-import-failed` (or the
|
|
218
|
+
first `nuka run` if `check` was skipped) for a `require()` call inside a
|
|
219
|
+
file discovery does open.
|
|
220
|
+
- **Deep subpath imports** such as
|
|
221
|
+
`import DataTable from "@cucumber/cucumber/lib/models/data_table"` have no
|
|
222
|
+
equivalent here; import `DataTable` from `nukadoko/compat` instead. Caught
|
|
223
|
+
the same way: `nuka check`'s `step-file-import-failed`, or the first
|
|
224
|
+
`nuka run` if `check` was skipped.
|
|
225
|
+
- **A hook's tag expression beyond a single `@tag` / `not @tag`** (`and`,
|
|
226
|
+
`or`, parentheses). `nuka check` reports every violating hook up front
|
|
227
|
+
(`unsupported-hook-tag-expression`); `nuka run` enforces the same rule but
|
|
228
|
+
stops at the first one it hits, since a run exits rather than lists.
|
|
229
|
+
- **Returning `"pending"` or `"skipped"`** from a step or hook fails with a
|
|
230
|
+
message naming what to write instead. This is not visible to `nuka check`:
|
|
231
|
+
it is a property of what the function does when it actually runs, not of
|
|
232
|
+
how its file imports, so nothing before that execution can name the fault.
|
|
233
|
+
It surfaces on the first `nuka run` that reaches it.
|
|
234
|
+
- **Done-callback glue** (`function (arg, done) {...}`) fails with the same
|
|
235
|
+
kind of message, and `nuka check` reports it first as `done-callback-arity`.
|
|
236
|
+
A hook is over the limit when Before, After, or AfterStep declares two or
|
|
237
|
+
more parameters, or when BeforeAll or AfterAll declares one or more. A
|
|
238
|
+
matched compat step is over the limit when its function declares more
|
|
239
|
+
parameters than the line's captures plus a table or docstring. An
|
|
240
|
+
unmatched step stays silent, because the capture count comes from the
|
|
241
|
+
line that selected it. cucumber-js gives both the return strings and the
|
|
242
|
+
callback meaning; nukadoko does not, and says so rather than passing the
|
|
243
|
+
step.
|
|
244
|
+
|
|
245
|
+
Run the suite with `nuka run features/your.feature`. Every step gets a
|
|
246
|
+
step record; nothing else has to change for that to start happening.
|
|
247
|
+
|
|
248
|
+
## The measured upgrade (optional)
|
|
249
|
+
|
|
250
|
+
Glue that launches its own Playwright browser or request client keeps
|
|
251
|
+
working, with no trace and no page log: nukadoko does not hand it a
|
|
252
|
+
context. A request a step sends through such a request client still lands
|
|
253
|
+
in `http.jsonl`, as a `node:http` or `node:https` line, because the client
|
|
254
|
+
sends from the step's own process. A World subclass assigns
|
|
255
|
+
that page and request with `this.page = ...` and `this.request = ...`,
|
|
256
|
+
and a later read returns that assignment, ahead of the page `openPage()`
|
|
257
|
+
or `openRequest()` stored. Replace that bootstrapping
|
|
258
|
+
with `await this.openPage()` / `await this.openRequest()` (delegating to
|
|
259
|
+
the same context a mixed scenario's typed steps share, one browser and one
|
|
260
|
+
session per scenario), and that step's step record gains a trace and the
|
|
261
|
+
page's own lines in `http.jsonl`, no other code change.
|
|
262
|
+
|
|
263
|
+
## Stage 1.5: declare what you rely on
|
|
264
|
+
|
|
265
|
+
Two independent, incremental moves, safe to take alone, in either order:
|
|
266
|
+
|
|
267
|
+
- **World keys**: wrap the keys you rely on in `defineWorld({ key:
|
|
268
|
+
someZodSchema })` and extend it: `class MyWorld extends defineWorld({
|
|
269
|
+
seededCount: z.number() })`. That key's writes are now validated (a write
|
|
270
|
+
that fails its schema fails the step and is never recorded); every other
|
|
271
|
+
key keeps working, measured but unvalidated. `this` on `MyWorld` is typed
|
|
272
|
+
for the declared keys too. Do not declare `page` or `request`. They are
|
|
273
|
+
harness getters. A subclass can still assign them. Reach the harness
|
|
274
|
+
objects with `await this.openPage()` and `await this.openRequest()`.
|
|
275
|
+
`defineWorld` refuses either name at import.
|
|
276
|
+
`nuka check` reports `step-file-import-failed`, and `nuka run` stops with
|
|
277
|
+
the same message, which names the field.
|
|
278
|
+
- **Parameter types**: a support-side `defineParameterType` call still
|
|
279
|
+
works, and `config.parameterTypes` is the typed-era home: moving the
|
|
280
|
+
registration changes nothing about what any pattern matches, unless it
|
|
281
|
+
sets `preferForRegexpMatch`. A transformer's `this` is the scenario's
|
|
282
|
+
World, and a Promise it returns is awaited before the step, for a string
|
|
283
|
+
pattern and a RegExp pattern alike. `preferForRegexpMatch` picks the
|
|
284
|
+
type for a RegExp group that several types match, as in cucumber-js.
|
|
285
|
+
`config.parameterTypes` has no such key, so a registration that sets it
|
|
286
|
+
stays in support code while a RegExp step relies on it. Moved to config
|
|
287
|
+
with the key, it is a config error. Moved without it, a RegExp group that
|
|
288
|
+
two types match fails the step with "matches multiple parameter types"
|
|
289
|
+
again.
|
|
290
|
+
|
|
291
|
+
## Stage 2: promote steps
|
|
292
|
+
|
|
293
|
+
Promote a producer before its consumer: turn the step that used to stash
|
|
294
|
+
data onto `this` into a `defineStep` with a `returns` schema, then have the
|
|
295
|
+
reader declare `from: { key: [producerStep, "resultKey"] }` for the key it
|
|
296
|
+
used to read off `this` (see docs/spec.md "Chaining steps"). That covers
|
|
297
|
+
what most existing writes to `this` turn out to be: one named value read by
|
|
298
|
+
one named key. When the read is not that (the value needs reshaping, which
|
|
299
|
+
producer to read is decided at run time, or the whole result is wanted, not
|
|
300
|
+
one key of it), keep the argument optional and fall back to `resultOf`,
|
|
301
|
+
one of `run`'s own fixtures, called as `resultOf(producerModule)`, the
|
|
302
|
+
same read `this` used to answer, only now against a validated result
|
|
303
|
+
rather than a bag. A promoted step gains a typed contract, a validated
|
|
304
|
+
`result`, and single-step execution via `nuka do`, none of which a compat
|
|
305
|
+
step has.
|
|
306
|
+
|
|
307
|
+
A `Then` is promoted to a claim step, not to a step with `run`. Its
|
|
308
|
+
`expect` calls become `claims`: each one reads its value through `from`
|
|
309
|
+
or an `observe` (not `resultOf`, which throws in a claim step), and takes
|
|
310
|
+
its expected value from the sentence, so a
|
|
311
|
+
sentence such as `the command succeeds` is reworded to state the value
|
|
312
|
+
(`it exits with 0`). See docs/spec.md "Claims". Until then a compat `Then`
|
|
313
|
+
stays a compat `Then`: a compat step cannot declare claims, and nothing
|
|
314
|
+
in the compat door changes what it does. Promote a `Then` after its
|
|
315
|
+
producer, since its claims read the producer's `returns`.
|
|
316
|
+
|
|
317
|
+
Only a claim proves a criterion (docs/spec.md "Verdicts"). A failed
|
|
318
|
+
assertion in a compat step, or in a step with `run`, bound in `Then`
|
|
319
|
+
position is `broke`, not `fail`, so a compat suite's criteria are `held`
|
|
320
|
+
or `failed`, never `proven`, until their `Then`s become claim steps.
|
|
321
|
+
Under `nuka run --base`, a new or changed one is `unproven` (red) for
|
|
322
|
+
the same reason, unless it is tagged `@held` and passes at the base, and
|
|
323
|
+
its reason says that its `Then` is a compat step, which judges no claim.
|
|
324
|
+
Promote the `Then` of a criterion before you change it, or tag it
|
|
325
|
+
`@held` when the base already has the behaviour.
|
|
326
|
+
|
|
327
|
+
## The dashboard is `nuka check`
|
|
328
|
+
|
|
329
|
+
`nuka check` is the running meter of how much migration is left:
|
|
330
|
+
|
|
331
|
+
- `then-compat-step` warns when a compat step is bound in `Then` position:
|
|
332
|
+
a compat step cannot declare claims, so nukadoko cannot see what it
|
|
333
|
+
judges there (see docs/spec.md "Claims"). This flags a step with no
|
|
334
|
+
static signal at all in that spot, not one the tool has caught doing
|
|
335
|
+
anything. Promoting it to a claim step (`defineStep` with `claims`) is
|
|
336
|
+
how it gains claims to check.
|
|
337
|
+
- `step-file-import-failed` errors on a step file whose import threw: an
|
|
338
|
+
unsupported name used as a value, a CommonJS `require`, or a deep subpath
|
|
339
|
+
import (the first three gaps in "What the switch does not carry" above),
|
|
340
|
+
carrying Node's own error message and the file path. The rest of the
|
|
341
|
+
project is still discovered and reported alongside it: a migrating
|
|
342
|
+
suite's normal state is some glue still broken, not a reason for the
|
|
343
|
+
dashboard to go blank.
|
|
344
|
+
- `step-file-unsupported-extension` errors on a `.cjs` or `.cts` file discovery walked
|
|
345
|
+
under `featuresDir` and never imported: unlike the gaps above, there is
|
|
346
|
+
no import attempt behind this one to fail, so it gets its own code rather
|
|
347
|
+
than reusing `step-file-import-failed`. Names the file path either way.
|
|
348
|
+
- `no-step-files-found` errors when the walk under `featuresDir` turned up
|
|
349
|
+
nothing loadable at all, naming the directory it scanned -- the way a
|
|
350
|
+
suite in an entirely unsupported shape (every glue file `.cjs`, or
|
|
351
|
+
`featuresDir` pointed somewhere with none in it) is told apart from a
|
|
352
|
+
suite that just has nothing to report yet.
|
|
353
|
+
- `unsupported-hook-tag-expression` errors on every hook whose tag
|
|
354
|
+
expression goes beyond a single `@tag` / `not @tag`, not just the first
|
|
355
|
+
one `nuka run` would stop at.
|
|
356
|
+
- `done-callback-arity` errors when a compat hook declares more parameters
|
|
357
|
+
than nukadoko passes, or when a matched compat step's function declares
|
|
358
|
+
more parameters than that line's captures plus a table or docstring.
|
|
359
|
+
Returning `"pending"` or `"skipped"` is still a run-time failure: the
|
|
360
|
+
return value is not known until the function runs.
|
|
361
|
+
- `undefined-step-check-suppressed` warns when an import failure above is
|
|
362
|
+
holding back the `undefined-step` errors it would otherwise cause: one
|
|
363
|
+
broken file's own steps going missing from the vocabulary can otherwise
|
|
364
|
+
read as a pile of unrelated undefined steps. Fix the import failure
|
|
365
|
+
first; the suppressed findings reappear as real `undefined-step` errors
|
|
366
|
+
once the file imports cleanly.
|
|
367
|
+
- Step records tell the same story at run time: `world` (compat steps only) and
|
|
368
|
+
`declared` shrink as more of the suite promotes to typed steps whose
|
|
369
|
+
consumers read from them via `from` (or `resultOf` where a key name
|
|
370
|
+
cannot say what is needed).
|
|
371
|
+
|
|
372
|
+
## The way back
|
|
373
|
+
|
|
374
|
+
The import switch is reversible, and that is a standing design rule rather
|
|
375
|
+
than a happy accident. Switch back to `@cucumber/cucumber` (restoring
|
|
376
|
+
whatever Playwright bootstrapping `openPage()`/`openRequest()` replaced),
|
|
377
|
+
and everything still sitting on compat is a plain cucumber-js suite again.
|
|
378
|
+
|
|
379
|
+
A step promoted to `defineStep` is a different matter, and nothing above
|
|
380
|
+
should be read as covering it. `defineStep` is nukadoko's own API: there is
|
|
381
|
+
no import to switch back. What that actually costs is worth being specific
|
|
382
|
+
about, because it is narrower than "locked in" suggests.
|
|
383
|
+
|
|
384
|
+
What a promoted step gives up on the way out is everything built on its
|
|
385
|
+
schemas: the `args`/`returns` validation, the step record's `result`, `from`
|
|
386
|
+
and the binding-order check that reads it, and the contract checks
|
|
387
|
+
`nuka check` performs.
|
|
388
|
+
|
|
389
|
+
What it keeps is the body. `run` is written against Playwright's own `Page`
|
|
390
|
+
and `APIRequestContext`, and nukadoko deliberately does not wrap them (see
|
|
391
|
+
docs/spec.md "Out of scope"), so the code doing the actual work moves as it
|
|
392
|
+
stands into a cucumber-js step, with the destructured `page`/`request`
|
|
393
|
+
fixtures replaced by whatever the World hands out. The rest is mechanical:
|
|
394
|
+
drop the named captures from the pattern (`{name:string}` → `{string}`),
|
|
395
|
+
write what `returns` returned onto `this` again, and read what `from`
|
|
396
|
+
declared off `this` again.
|
|
397
|
+
|
|
398
|
+
nukadoko ships no tool for that conversion, and this is stated as a limit
|
|
399
|
+
rather than as an argument against promoting. The import's reversibility
|
|
400
|
+
exists to make the first step cost one edit, not to make the typed side
|
|
401
|
+
optional: compat is where a suite arrives, and every reason to run it on
|
|
402
|
+
this tool at all (a validated `result`, a contract `nuka check` can hold a
|
|
403
|
+
feature against, `from`, a run summary that attests to more than "it ran")
|
|
404
|
+
lives on the other side of the promotion. Promote the steps whose contracts
|
|
405
|
+
you want, which over time should be most of the ones that matter.
|
|
406
|
+
|
|
407
|
+
## Coming from a typed-step DSL
|
|
408
|
+
|
|
409
|
+
If there are no feature files and no cucumber glue, the compat door above
|
|
410
|
+
does not apply. `pattern` is optional on `defineStep`: a step with no
|
|
411
|
+
pattern is still complete vocabulary, runnable with `nuka do` and readable
|
|
412
|
+
with `nuka describe`. That gives a different pair of stages from the same
|
|
413
|
+
rule: move each step to a typed `defineStep` first, and give it a Gherkin
|
|
414
|
+
`pattern` later, when a feature file makes it worth doing.
|
|
415
|
+
|
|
416
|
+
A source DSL that already carries a description, args, returns, a write
|
|
417
|
+
flag, and a run function translates directly: `defineStep` has a field
|
|
418
|
+
for each. A translated schema that JSON Schema cannot represent does not
|
|
419
|
+
stop `nuka describe`: it still prints that step's contract, names the
|
|
420
|
+
step, and exits 1.
|
|
421
|
+
|
|
422
|
+
## Working rules
|
|
423
|
+
|
|
424
|
+
These hold whichever door the suite came in through.
|
|
425
|
+
|
|
426
|
+
- **Two stages, never at once.** Change one thing, then the next. When a
|
|
427
|
+
step breaks after two changes landed together, nothing tells which one
|
|
428
|
+
broke it. Here the pair is "switch the import", then "add typing"; the
|
|
429
|
+
other doors derive their own pair from the same rule.
|
|
430
|
+
- **Say where you are before the first change.** Name the stage, what it
|
|
431
|
+
touches, and what it leaves alone. Switching the import is reversible
|
|
432
|
+
(see [The way back](#the-way-back)); promoting a step to `defineStep` is
|
|
433
|
+
not, so it gets the owner's word before the first one, not after the
|
|
434
|
+
tenth.
|
|
435
|
+
- **The suite keeps running partway migrated.** Compat and typed steps
|
|
436
|
+
share a feature file. Never make "fully typed" a precondition for
|
|
437
|
+
"runs". `nuka run` refuses a scenario `nuka check` reports an error for:
|
|
438
|
+
fix the finding, or pass `--no-check` while the rest catches up.
|
|
439
|
+
- **Delete compat glue only after its typed replacement passes.** Write
|
|
440
|
+
the new step, run it with `nuka do`, then remove the old one.
|
|
441
|
+
- **Fix what `nuka check` and `nuka run` report, not a hunch.** Each
|
|
442
|
+
finding names the file and a `fix:` or `do:` line.
|
|
443
|
+
|
|
444
|
+
Facts a migration runs into:
|
|
445
|
+
|
|
446
|
+
- `envFiles` points at the env files the suite already has (`KEY=VALUE`,
|
|
447
|
+
with the rules in docs/spec.md "Environments and secrets"). A line that
|
|
448
|
+
is not a blank, a comment, or a binding is `env-file-skipped-line`. A
|
|
449
|
+
suite that ran once per target (a shell loop, one CI job per profile)
|
|
450
|
+
becomes one run: name each target in `environments` of the program
|
|
451
|
+
in `nukadoko.config.ts` and pass `nuka run --env a --env b`.
|
|
452
|
+
- A `package.json` with no `"type"` loads a `.ts` file with a Node
|
|
453
|
+
warning, and `nuka check` notes it as `package-type-missing`.
|
|
454
|
+
- `nuka run` writes no report of its own. A formatter or a JUnit-based CI
|
|
455
|
+
that read cucumber messages renders them after each run with
|
|
456
|
+
`nuka report --format messages --out <path>`, and `--format allure`
|
|
457
|
+
does the same for Allure. A scenario tagged with a condition runs as a
|
|
458
|
+
control where the condition does not hold. The messages stream leaves
|
|
459
|
+
every control out, so JUnit reads a green run as green; Allure keeps
|
|
460
|
+
each one, named `<scenario> (control)`, and shows one that failed as a
|
|
461
|
+
failed result by design. Gate CI on `nuka run`'s exit code.
|
|
462
|
+
- A scenario cucumber-js reported green can be red here with
|
|
463
|
+
`unexpected-failure`: its steps passed while a request got a 5xx, its
|
|
464
|
+
page threw an error nothing caught, or the program reported an error
|
|
465
|
+
with `handled: false`. Fix the program, or, when the criteria say the
|
|
466
|
+
scenario causes that failure, tag it as the finding's `fix:` line spells
|
|
467
|
+
(docs/spec.md "Failures underneath").
|
|
468
|
+
- The walk for `.feature` files skips `node_modules` and every directory
|
|
469
|
+
whose name starts with `.`, at any depth, and says nothing about it.
|
|
470
|
+
- A glue loop that slept and tried again becomes `poll` on the fixture
|
|
471
|
+
bag. Its `timeout` is a budget for the whole call (docs/spec.md
|
|
472
|
+
"Context API").
|
|
473
|
+
- A global `After` hook that cleaned up can become a fixture's teardown.
|
|
474
|
+
`nuka check` reports `fixture-structural-violation` when the fixture's
|
|
475
|
+
destructuring cannot be read or names an unknown fixture.
|
|
476
|
+
- A promoted schema that coerces its capture (`z.coerce.number()` on a
|
|
477
|
+
`{string}`) is not `capture-type-mismatch`: the run accepts it.
|
|
478
|
+
|
|
479
|
+
## Known limits
|
|
480
|
+
|
|
481
|
+
- A hook's own network traffic sits outside any step's boundary: it is
|
|
482
|
+
never in any step's record.
|
|
483
|
+
- World measurement only sees a World's own data properties; `#private`
|
|
484
|
+
fields never appear in `world.reads`/`world.writes`, by construction.
|
|
485
|
+
- Declared attachment file contents are not redacted: the same honest
|
|
486
|
+
limit traces and screenshots already have.
|
|
487
|
+
- A `BeforeAll`/`AfterAll` failure is reported on stderr and in the exit
|
|
488
|
+
code only. Records are written per scenario, and these hooks belong to no
|
|
489
|
+
scenario, so there is nowhere yet for a run-level one to go.
|
|
490
|
+
|
|
491
|
+
The differences below do not fail: the suite runs, and a value or an order
|
|
492
|
+
is not what cucumber-js gives. Each one was measured by running the same
|
|
493
|
+
glue under cucumber-js 13.2.0 and under `nuka run`. Search the glue for
|
|
494
|
+
each one before you rely on the run.
|
|
495
|
+
|
|
496
|
+
- `AfterStep` hooks run in registration order. cucumber-js runs them in
|
|
497
|
+
reverse registration order, the order both tools use for `After` hooks.
|
|
498
|
+
- A hook's `result.message` is the error message only (`boom`).
|
|
499
|
+
cucumber-js gives the stack text (`Error: boom` and the frames below it).
|
|
500
|
+
`result.exception` is not set.
|
|
501
|
+
- A step with no `{ timeout }`, in a suite that never calls
|
|
502
|
+
`setDefaultTimeout`, has no time limit. cucumber-js fails it after 5
|
|
503
|
+
seconds.
|
|
504
|
+
- `table.raw()` returns a copy. In cucumber-js, a change to a row of the
|
|
505
|
+
returned array also changes what `table.hashes()` returns later.
|