@gfdelarue/testkit 0.5.0 → 0.6.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 (95) hide show
  1. package/README.md +136 -110
  2. package/dist/app/bugs/draft.js +2 -2
  3. package/dist/app/bugs/guide.js +1 -1
  4. package/dist/app/bugs/record.js +2 -2
  5. package/dist/app/campaigns/index.js +2 -2
  6. package/dist/app/destroy/index.js +1 -1
  7. package/dist/app/discover/index.js +2 -2
  8. package/dist/app/environments/static-values.js +1 -1
  9. package/dist/app/environments/supplied.js +1 -1
  10. package/dist/app/inspect/index.js +1 -1
  11. package/dist/app/lint/native.js +1 -1
  12. package/dist/app/lint/options.js +1 -1
  13. package/dist/app/run/engine-orchestration.js +1 -1
  14. package/dist/app/run/environment.js +1 -1
  15. package/dist/app/run/orchestrator.js +1 -1
  16. package/dist/app/run/request.js +1 -1
  17. package/dist/app/run/run-finalization.js +1 -1
  18. package/dist/app/run/task-batches.js +1 -1
  19. package/dist/app/run/worker-loop.js +1 -1
  20. package/dist/app/status/model.js +1 -1
  21. package/dist/app/status/runs.js +1 -1
  22. package/dist/app/typecheck/index.js +4 -4
  23. package/dist/cli/command-catalog.js +1 -1
  24. package/dist/cli/command-flags.js +1 -1
  25. package/dist/cli/commands/artifacts.js +2 -2
  26. package/dist/cli/commands/discover.js +1 -1
  27. package/dist/cli/commands/guard/unsafe-entrypoint.js +1 -1
  28. package/dist/cli/commands/run.js +2 -2
  29. package/dist/cli/commands/typecheck.js +1 -1
  30. package/dist/cli/commands/workspace.js +1 -1
  31. package/dist/config/authoring/database-fixture-discovery.js +1 -0
  32. package/dist/config/authoring/index.js +1 -1
  33. package/dist/config/loader/config-loader.js +1 -1
  34. package/dist/config/loader/decode-discovery.js +1 -1
  35. package/dist/config/loader/discover-tests.js +1 -1
  36. package/dist/config/loader/discovery.js +2 -2
  37. package/dist/config/loader/file-metadata.js +1 -1
  38. package/dist/config/loader/groups.js +2 -1
  39. package/dist/config/loader/load.js +1 -1
  40. package/dist/config/loader/managed-configs.js +1 -1
  41. package/dist/config/loader/owned-discovery.js +1 -1
  42. package/dist/config/loader/runtime-isolation.js +1 -1
  43. package/dist/config/loader/skip-config.js +1 -1
  44. package/dist/database/admin.js +2 -2
  45. package/dist/database/configured-steps.js +1 -1
  46. package/dist/domain/identifiers.js +1 -1
  47. package/dist/domain/retired-test-types.js +1 -1
  48. package/dist/domain/suite-selection.js +1 -1
  49. package/dist/domain/test-types.js +1 -1
  50. package/dist/engines/catalog.js +1 -1
  51. package/dist/engines/definitions.js +1 -1
  52. package/dist/engines/environment/index.js +1 -1
  53. package/dist/engines/installations/node-vitest.js +1 -1
  54. package/dist/engines/installations/playwright.js +1 -1
  55. package/dist/engines/managed-module-resolution.js +6 -2
  56. package/dist/engines/node-vitest/adapter/adapter.js +1 -1
  57. package/dist/engines/node-vitest/adapter/driver.js +2 -2
  58. package/dist/engines/node-vitest/adapter/evidence.js +2 -2
  59. package/dist/engines/node-vitest/adapter/workspace.js +8 -24
  60. package/dist/engines/node-vitest/inventory/index.js +2 -2
  61. package/dist/engines/node-vitest/inventory/list-files.js +3 -3
  62. package/dist/engines/node-vitest/runtime/data/index.js +1 -1
  63. package/dist/engines/node-vitest/runtime/data/report.js +1 -1
  64. package/dist/engines/node-vitest/runtime/data/scenario.js +2 -2
  65. package/dist/engines/node-vitest/runtime/runtime-input.js +1 -1
  66. package/dist/engines/playwright/adapter/adapter.js +1 -1
  67. package/dist/engines/playwright/adapter/config.js +2 -2
  68. package/dist/engines/playwright/runtime/managed-test.js +1 -0
  69. package/dist/environment/lifecycle.js +1 -1
  70. package/dist/environment/run-environment.js +1 -1
  71. package/dist/evidence/artifact-config.js +1 -1
  72. package/dist/evidence/maintenance.js +1 -0
  73. package/dist/evidence/read-run.js +1 -1
  74. package/dist/kernel/known-keys.js +1 -0
  75. package/dist/process/execa-bundle.json +1 -1
  76. package/dist/repo/fingerprint-policy.js +1 -1
  77. package/dist/steps/configured-step-testkit-modules.js +1 -1
  78. package/dist/toolchains/index.js +2 -2
  79. package/dist/toolchains/vitest/index.js +1 -1
  80. package/dist/types/config.d.ts +7 -86
  81. package/dist/types/environment.d.ts +6 -0
  82. package/dist/types/node-vitest-data.d.ts +2 -218
  83. package/dist/types/workspace.d.ts +27 -11
  84. package/docs/bug-records.md +3 -8
  85. package/docs/engines.md +63 -17
  86. package/docs/release-notes.md +2116 -0
  87. package/docs/test-types.md +19 -69
  88. package/package.json +2 -5
  89. package/testkit-config-schema.md +65 -128
  90. package/dist/app/lint/rules/data.js +0 -1
  91. package/dist/config/authoring/runtime.js +0 -1
  92. package/dist/engines/node-vitest/runtime/contract/index.js +0 -1
  93. package/dist/engines/node-vitest/runtime/data/http.js +0 -1
  94. package/dist/engines/node-vitest/runtime/data/runner.js +0 -1
  95. package/dist/types/node-vitest-contract.d.ts +0 -75
@@ -4,14 +4,10 @@ declare const ENGINE_IDS: readonly [
4
4
  ];
5
5
  export type EngineId = (typeof ENGINE_IDS)[number];
6
6
  declare const PUBLIC_TEST_TYPES: readonly [
7
- "ui",
8
- "contract",
9
- "data"
7
+ "ui"
10
8
  ];
11
9
  export type PublicTestType = (typeof PUBLIC_TEST_TYPES)[number];
12
10
  declare const RUNNER_PROFILE_IDS: readonly [
13
- "node-vitest-data",
14
- "node-vitest-contract",
15
11
  "node-vitest",
16
12
  "playwright-ui"
17
13
  ];
@@ -23,8 +19,7 @@ declare const RUNTIME_ISOLATION_POLICIES: readonly [
23
19
  export type RuntimeIsolationPolicy = (typeof RUNTIME_ISOLATION_POLICIES)[number];
24
20
  declare const RUN_TYPE_VALUES: readonly [
25
21
  "ui",
26
- "contract",
27
- "data",
22
+ "plain",
28
23
  "all"
29
24
  ];
30
25
  export type RunType = (typeof RUN_TYPE_VALUES)[number];
@@ -55,6 +50,28 @@ export interface SerializedError {
55
50
  diagnostics?: ErrorMetadataObject;
56
51
  stack?: string;
57
52
  }
53
+ declare const RETIRED_SUITE_IDENTITIES: readonly [
54
+ ...{
55
+ readonly engineId: "k6";
56
+ readonly profileId: "k6-http";
57
+ readonly testType: "e2e" | "int" | "load" | "scenario";
58
+ }[],
59
+ {
60
+ readonly engineId: "k6";
61
+ readonly profileId: "k6-dal";
62
+ readonly testType: "dal";
63
+ },
64
+ {
65
+ readonly engineId: "node-vitest";
66
+ readonly profileId: "node-vitest-contract";
67
+ readonly testType: "contract";
68
+ },
69
+ {
70
+ readonly engineId: "node-vitest";
71
+ readonly profileId: "node-vitest-data";
72
+ readonly testType: "data";
73
+ }
74
+ ];
58
75
  export type ReportingRecord = Record<string, unknown>;
59
76
  export interface ReportingFailureRequest extends ReportingRecord {
60
77
  method?: string;
@@ -131,9 +148,9 @@ export interface RunArtifactSuite extends ReportingRecord {
131
148
  files?: RunArtifactFile[];
132
149
  name: string;
133
150
  passedFileCount?: number;
134
- profileId: RunnerProfileId | "k6-dal" | "k6-http";
151
+ profileId: RunnerProfileId | (typeof RETIRED_SUITE_IDENTITIES)[number]["profileId"];
135
152
  skippedFileCount?: number;
136
- testType?: PublicTestType | "dal" | "e2e" | "int" | "load" | "scenario";
153
+ testType?: PublicTestType | (typeof RETIRED_SUITE_IDENTITIES)[number]["testType"];
137
154
  }
138
155
  export interface RunArtifactGroup extends ReportingRecord {
139
156
  name: string;
@@ -370,7 +387,7 @@ export type VitestSelection = Readonly<{
370
387
  project: null | string;
371
388
  runner: "auto" | "managed" | "repo";
372
389
  }>;
373
- export type TestGroupSource = "groups" | "implicit" | "services";
390
+ export type TestGroupSource = "groups" | "implicit";
374
391
  export interface DiscoverySummary {
375
392
  activeFiles: number;
376
393
  byGroup: Record<string, number>;
@@ -608,7 +625,6 @@ export interface WorkspaceInspection {
608
625
  export interface InspectWorkspaceOptions {
609
626
  dir?: string;
610
627
  group?: null | string;
611
- notice?: (message: string) => void;
612
628
  status?: boolean;
613
629
  targetLimit?: number;
614
630
  }
@@ -45,10 +45,10 @@ Two overlapping refund requests for one order both pay out.
45
45
  ## Reproduce
46
46
 
47
47
  ```sh
48
- npx testkit run --file src/checkout/__testkit__/refund.contract.testkit.ts
48
+ npx testkit run --file src/checkout/refund.test.ts
49
49
  ```
50
50
 
51
- Test: `src/checkout/__testkit__/refund.contract.testkit.ts`, "a refund pays out once".
51
+ Test: `src/checkout/refund.test.ts`, "a refund pays out once".
52
52
  Found at `4f0c2d1e9b7a4c3d8e6f5a4b3c2d1e0f9a8b7c6d`.
53
53
  Fault: `src/checkout/refunds.ts`, lines 41 to 58.
54
54
 
@@ -66,9 +66,8 @@ Fault: `src/checkout/refunds.ts`, lines 41 to 58.
66
66
  "escape": "no-test",
67
67
  "caughtBy": "campaign",
68
68
  "campaign": "refunds-2026-10",
69
- "testType": "contract",
70
69
  "test": {
71
- "file": "src/checkout/__testkit__/refund.contract.testkit.ts",
70
+ "file": "src/checkout/refund.test.ts",
72
71
  "title": "a refund pays out once"
73
72
  },
74
73
  "foundAt": "4f0c2d1e9b7a4c3d8e6f5a4b3c2d1e0f9a8b7c6d",
@@ -90,10 +89,6 @@ When `testkit bug file` ran the test against [supplied values](../README.md#run-
90
89
 
91
90
  A fault on one line reads `line 41`.
92
91
 
93
- ```markdown
94
- Test: `src/health/__testkit__/health.contract.testkit.ts`, the whole script, recorded as "the health endpoint answers".
95
- ```
96
-
97
92
  Testkit redacts the secrets it recognises in the title, in every section, and in `test.title`. It does so when it records the bug and again when it files the issue. `testkit run` applies the same rules when it stores a run result. Testkit recognises these forms.
98
93
 
99
94
  - The value of a `KEY=value` assignment whose key names a secret.
package/docs/engines.md CHANGED
@@ -11,18 +11,17 @@ attachments, and installation.
11
11
  Each engine keeps its own test language. The root package declares a typed
12
12
  file's engine, and each engine's subpath exposes that engine's API.
13
13
 
14
- Node/Vitest runs plain Vitest test files, and data and contract suites:
14
+ Node/Vitest runs plain Vitest test files. A plain file records data-flow
15
+ evidence with `dataFlow(context)`:
15
16
 
16
17
  ```ts
17
- import { defineFile } from "@gfdelarue/testkit";
18
- import { dataScenario } from "@gfdelarue/testkit/node-vitest/data";
19
- import { expect } from "vitest";
20
-
21
- export const testkit = defineFile({ engine: "node-vitest" });
18
+ import { dataFlow } from "@gfdelarue/testkit/node-vitest/data";
19
+ import { expect, test } from "vitest";
22
20
 
23
- dataScenario("records checkout traffic", ({ count, record }) => {
24
- record("checkout", { count: 1 });
25
- count("orders", 1);
21
+ test("records checkout traffic", (context) => {
22
+ const flow = dataFlow(context);
23
+ flow.record("checkout", { count: 1 });
24
+ flow.count("orders", 1);
26
25
  expect(1).toBe(1);
27
26
  });
28
27
  ```
@@ -41,14 +40,34 @@ test("shows the account", async ({ page }) => {
41
40
  });
42
41
  ```
43
42
 
43
+ ### Browser launch options
44
+
45
+ A UI file can set Playwright's `launchOptions` with `test.use`. Testkit applies
46
+ them and sets `executablePath` last, so the file still runs on the Chromium
47
+ that Testkit manages, and a file's own `executablePath` has no effect. This
48
+ holds whether the file imports `test` from `@playwright/test`,
49
+ `playwright/test`, or `@gfdelarue/testkit/playwright`.
50
+
51
+ Playwright starts Chromium with `--disable-back-forward-cache`. To check that
52
+ Back restores a page from the back/forward cache, drop that flag in the file:
53
+
54
+ ```ts
55
+ test.use({ launchOptions: { ignoreDefaultArgs: ["--disable-back-forward-cache"] } });
56
+ ```
57
+
44
58
  ## Typechecking
45
59
 
46
60
  `testkit typecheck` groups the discovered test files by engine and by their
47
61
  nearest tsconfig, and checks each group with native `tsc --noEmit`. Plain Vitest
48
62
  test files written in TypeScript join the Node/Vitest program, and plain
49
- JavaScript files are skipped. Config and Node/Vitest use Node types and ES2022;
50
- Playwright adds DOM and DOM.Iterable. Each check has a deadline and can be
51
- cancelled. When a program fails, the report includes the programs that passed
63
+ JavaScript files are skipped. Every program uses Node types. The config program
64
+ uses ES2022, and Playwright programs use ES2022, DOM, and DOM.Iterable. A
65
+ Node/Vitest program uses the `lib` of the tsconfig it extends, as the
66
+ repository's own `tsc` does, so a test that runs in a jsdom or happy-dom
67
+ environment can use the DOM libraries that tsconfig lists. When that tsconfig
68
+ sets no `lib`, TypeScript's default for ES2022 applies, which includes DOM.
69
+ Without a tsconfig, a Node/Vitest program uses ES2022. Each check has a deadline
70
+ and can be cancelled. When a program fails, the report includes the programs that passed
52
71
  before it.
53
72
 
54
73
  Testkit supports consumer TypeScript 5.9.3 and 6.0.2. Each program uses the
@@ -66,6 +85,21 @@ typecheck in each engine's program. Testkit's generated configs don't set
66
85
  Aliases inherited from a config with `baseUrl` keep their target directory and
67
86
  fallback order.
68
87
 
88
+ A plain file's program also includes the TypeScript setup files of its Vitest
89
+ project, because Vitest loads them before the file and a setup file can declare
90
+ types, such as the matchers that `@testing-library/jest-dom/vitest` adds. Those
91
+ setup files are type-checked too. Files whose projects load different setup
92
+ files go to separate programs, so one project's setup types never reach another
93
+ project's files, and a file that two such projects include is checked in both.
94
+ The label of a program with setup files names them, as in
95
+ `node-vitest with tests/setup.ts`. A JavaScript setup file, or a package named
96
+ directly in `setupFiles`, adds no types. Import the package from a TypeScript
97
+ setup file instead.
98
+
99
+ `testkit typecheck --group <name>` checks the config and the files that group
100
+ owns, with the setup files of their Vitest projects. An unknown group fails and
101
+ lists the groups.
102
+
69
103
  ### Playwright support files
70
104
 
71
105
  A Playwright program always includes the discovered UI suites and the nearest
@@ -100,15 +134,15 @@ runtime string or function names. Include those files in the companion.
100
134
  The environment declared for a test is part of the test's input. Each engine
101
135
  exposes it through its own authoring surface:
102
136
 
103
- - Node/Vitest data and contract callbacks read it from immutable `context.env`.
137
+ - Node/Vitest tests read it from `process.env`, and named values from
138
+ `@gfdelarue/testkit/environment`.
104
139
  - Playwright files read immutable `context.env` from `readPlaywrightContext()`
105
140
  when Testkit runs them.
106
141
 
107
- Outside a Testkit run, a Node/Vitest authoring context has an empty `env`, and
108
- `readPlaywrightContext()` returns `null`.
142
+ Outside a Testkit run, `readPlaywrightContext()` returns `null`.
109
143
 
110
- Typed Node/Vitest files, and plain files under `--vitest-runner managed`, also
111
- see each value as an immutable, non-enumerable `process.env.KEY` property, so
144
+ Plain files under `--vitest-runner managed` see each value as an immutable,
145
+ non-enumerable `process.env.KEY` property, so
112
146
  libraries that read `process.env` see it. `process.env` isn't the enumerable
113
147
  list of the test's values, though. A Node child that inherits Testkit's
114
148
  bootstrap sees the values too. A non-Node child process receives only the
@@ -116,6 +150,18 @@ values the test passes it. Plain files under the repository's Vitest get the
116
150
  values as ordinary environment variables, which tests and child processes can
117
151
  read, enumerate, change, and delete like any other.
118
152
 
153
+ Vitest and Vite write some keys into each test process's environment
154
+ themselves. Under either runner, a test sees:
155
+
156
+ - the group's `NODE_ENV`, or `test` when the group sets none
157
+ - the group's `VITE_` values, ahead of the same keys in `.env` files
158
+ - Vitest's own `TEST`, `VITEST`, `VITEST_MODE`, `FORCE_TTY`, `MODE`, `DEV`,
159
+ `PROD`, and `SSR`, whatever the group sets
160
+
161
+ Under `--vitest-runner managed`, `NODE_ENV` and `VITE_` values are ordinary
162
+ variables rather than immutable ones, and they count toward the process
163
+ environment limit.
164
+
119
165
  Test files of every engine may import `@gfdelarue/testkit/environment` and read
120
166
  named endpoints, databases, and handles with `endpoint(name)`, `database(name)`,
121
167
  and `handle(name)`. See