@jskit-ai/agent-docs 0.1.364 → 0.1.366
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.
- package/guide/agent/app-extras/mobile-capacitor.md +5 -0
- package/guide/agent/app-setup/authentication.md +10 -8
- package/guide/agent/app-setup/database-layer.md +51 -39
- package/guide/agent/app-setup/existing-application-migration.md +3 -1
- package/guide/agent/app-setup/upgrading-jskit.md +13 -3
- package/guide/agent/framework/application-operations.md +9 -0
- package/guide/agent/framework/client-features.md +22 -0
- package/guide/agent/framework/speed-pass.md +6 -94
- package/guide/agent/framework/test-pass.md +210 -0
- package/guide/agent/framework/typed-features.md +64 -1
- package/guide/agent/framework/ui-operations.md +43 -8
- package/guide/agent/index.md +40 -4
- package/guide/agent/recipes/another-language.md +129 -0
- package/guide/agent/recipes/file-uploads-and-images.md +125 -0
- package/guide/agent/recipes/installable-app.md +383 -0
- package/guide/agent/recipes/invite-people-with-roles.md +142 -0
- package/guide/agent/recipes/offline-study.md +163 -0
- package/guide/agent/recipes/payments-and-subscriptions.md +156 -0
- package/guide/agent/recipes/reminders-and-digests.md +153 -0
- package/guide/agent/recipes/usefulness-study.md +137 -0
- package/package.json +1 -1
- package/patterns/minimal-foundation/PATTERN.md +2 -0
- package/patterns/minimal-foundation/example/AGENTS.md +54 -101
- package/patterns/minimal-foundation/example/gitignore +1 -1
- package/patterns/minimal-foundation/example/package.json +3 -3
- package/patterns/minimal-foundation/example/server/lib/loggerOptions.js +6 -3
- package/patterns/minimal-foundation/example/server.js +1 -1
- package/patterns/minimal-foundation/example/vite.config.mjs +3 -2
- package/patterns/shell-foundation/PATTERN.md +2 -0
- package/patterns/shell-foundation/example/AGENTS.md +54 -101
- package/patterns/shell-foundation/example/gitignore +1 -1
- package/patterns/shell-foundation/example/package.json +4 -4
- package/patterns/shell-foundation/example/server/lib/loggerOptions.js +6 -3
- package/patterns/shell-foundation/example/server.js +1 -1
- package/patterns/shell-foundation/example/vite.config.mjs +3 -2
- package/reference/autogen/PATTERN_INDEX.md +36 -36
- package/reference/autogen/packages/agent-docs.md +2 -2
- package/reference/autogen/packages/assistant-runtime.md +4 -0
- package/reference/autogen/packages/auth-provider-local-core.md +1 -0
- package/reference/autogen/packages/auth-web.md +3 -2
- package/reference/autogen/packages/database-runtime.md +5 -17
- package/reference/autogen/packages/material-web.md +4 -0
- package/reference/autogen/tooling/config-eslint.md +8 -0
- package/reference/autogen/tooling/jskit-catalog.md +58 -5
- package/skills/jskit/SKILL.md +8 -4
- package/skills/jskit/references/app-operations.md +9 -0
- package/skills/jskit/references/client-features.md +22 -0
- package/skills/jskit/references/database-layer.md +51 -39
- package/skills/jskit/references/existing-application-migration.md +3 -1
- package/skills/jskit/references/heuristics/INDEX.md +2 -2
- package/skills/jskit/references/heuristics/client-requests.md +3 -1
- package/skills/jskit/references/heuristics/crud-authoring.md +10 -0
- package/skills/jskit/references/heuristics/placements.md +1 -0
- package/skills/jskit/references/heuristics/ui-testing.md +10 -7
- package/skills/jskit/references/pattern-index.md +36 -36
- package/skills/jskit/references/patterns/app/minimal-foundation/PATTERN.md +2 -0
- package/skills/jskit/references/patterns/app/minimal-foundation/example/AGENTS.md +54 -101
- package/skills/jskit/references/patterns/app/minimal-foundation/example/gitignore +1 -1
- package/skills/jskit/references/patterns/app/minimal-foundation/example/package.json +3 -3
- package/skills/jskit/references/patterns/app/minimal-foundation/example/server/lib/loggerOptions.js +6 -3
- package/skills/jskit/references/patterns/app/minimal-foundation/example/server.js +1 -1
- package/skills/jskit/references/patterns/app/minimal-foundation/example/vite.config.mjs +3 -2
- package/skills/jskit/references/patterns/app/shell-foundation/PATTERN.md +2 -0
- package/skills/jskit/references/patterns/app/shell-foundation/example/AGENTS.md +54 -101
- package/skills/jskit/references/patterns/app/shell-foundation/example/gitignore +1 -1
- package/skills/jskit/references/patterns/app/shell-foundation/example/package.json +4 -4
- package/skills/jskit/references/patterns/app/shell-foundation/example/server/lib/loggerOptions.js +6 -3
- package/skills/jskit/references/patterns/app/shell-foundation/example/server.js +1 -1
- package/skills/jskit/references/patterns/app/shell-foundation/example/vite.config.mjs +3 -2
- package/skills/jskit/references/patterns/auth/accounts-hub/example/package.json +3 -3
- package/skills/jskit/references/patterns/auth/oidc-sign-in/example/package.json +2 -2
- package/skills/jskit/references/patterns/connectors/calendar-cli/example/package.json +4 -4
- package/skills/jskit/references/patterns/crud/crud-feature-package/example/packages/books/package.json +1 -1
- package/skills/jskit/references/patterns/database/mysql-application/PATTERN.md +6 -5
- package/skills/jskit/references/patterns/database/mysql-application/example/package.json +2 -2
- package/skills/jskit/references/patterns/database/postgres-application/example/package.json +2 -2
- package/skills/jskit/references/patterns/realtime/realtime-application/example/package.json +2 -2
- package/skills/jskit/references/patterns/users/user-administration-server/example/packages/users/package.json +2 -2
- package/skills/jskit/references/patterns/users/user-administration-server/example/packages/users-workspace/package.json +4 -4
- package/skills/jskit/references/speed-pass.md +5 -93
- package/skills/jskit/references/test-pass.md +205 -0
- package/skills/jskit/references/typed-features.md +64 -1
- package/skills/jskit/references/ui-operations.md +43 -8
|
@@ -10,14 +10,14 @@
|
|
|
10
10
|
"./shared": "./src/shared/index.js"
|
|
11
11
|
},
|
|
12
12
|
"dependencies": {
|
|
13
|
-
"@jskit-ai/crud-core": "0.2.
|
|
13
|
+
"@jskit-ai/crud-core": "0.2.61",
|
|
14
14
|
"@jskit-ai/resource-crud-core": "0.1.228",
|
|
15
|
-
"@jskit-ai/users-core": "0.2.
|
|
16
|
-
"@jskit-ai/workspaces-core": "0.2.
|
|
15
|
+
"@jskit-ai/users-core": "0.2.72",
|
|
16
|
+
"@jskit-ai/workspaces-core": "0.2.72"
|
|
17
17
|
},
|
|
18
18
|
"peerDependencies": {
|
|
19
19
|
"@jskit-ai/kernel": "0.2.35",
|
|
20
|
-
"@jskit-ai/resource-runtime": "0.2.
|
|
20
|
+
"@jskit-ai/resource-runtime": "0.2.57"
|
|
21
21
|
},
|
|
22
22
|
"jskit": {
|
|
23
23
|
"kind": "runtime",
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
# Speed pass
|
|
4
4
|
|
|
5
|
-
A speed pass makes an app
|
|
5
|
+
A speed pass makes an app take the time its work needs.
|
|
6
6
|
Genesis's speed pass skill (`genesis-speed-pass`) holds the method: measure
|
|
7
7
|
each wait first on a realistic build at realistic sizes, fix its cause, measure
|
|
8
8
|
again the same way, and never raise a time limit, add retries, or shrink
|
|
@@ -13,97 +13,8 @@ are already in [Typed features](typed-features.md),
|
|
|
13
13
|
[Data access](data-access.md) and the
|
|
14
14
|
[sanity checks](sanity-checks.md). Query counts, narrowing and
|
|
15
15
|
indexes belong to the [data pass](data-pass.md): when a wait is
|
|
16
|
-
database time, apply that page to the path.
|
|
17
|
-
|
|
18
|
-
## Test speed
|
|
19
|
-
|
|
20
|
-
### Measure
|
|
21
|
-
|
|
22
|
-
- `jskit test` starts by saying how many test files it runs at a time and
|
|
23
|
-
where that number came from (`V64_TEST_CONCURRENCY`, or half of the
|
|
24
|
-
machine), and ends with its 10 slowest test files and tests; each file's time
|
|
25
|
-
is kept in `node_modules/.cache/jskit-test/file-times.json`. Time the whole
|
|
26
|
-
command too (`time npm test`): a wall time close to the sum of the files'
|
|
27
|
-
times means they ran one after another
|
|
28
|
-
([Test files run in parallel](typed-features.md#test-files-run-in-parallel)).
|
|
29
|
-
- Test database preparation reports each phase and its duration
|
|
30
|
-
([Test databases are prepared once](typed-features.md#test-databases-are-prepared-once)).
|
|
31
|
-
Read them: slow preparation otherwise hides inside the first test that waits
|
|
32
|
-
for it.
|
|
33
|
-
- Every Playwright run through `browserTestConfig()` ends with its 10 slowest
|
|
34
|
-
tests. Compare a slow spec's time with the time of the app's requests it
|
|
35
|
-
makes, so you know whether the test or the app is slow.
|
|
36
|
-
- Take the baseline from one whole run of each part (the database tests, the
|
|
37
|
-
browser tests), its files in parallel at the real `V64_TEST_CONCURRENCY`:
|
|
38
|
-
its per-file times are the baseline table. After a batch of fixes, run the
|
|
39
|
-
part again for the times after, and compare per file and in total. A
|
|
40
|
-
single-file run (`npm test -- <file>`) is for one change's red and green,
|
|
41
|
-
never the way to take a baseline or a before-and-after table, and never one
|
|
42
|
-
of serial runs queued one after another. Run where the project's test
|
|
43
|
-
machine runs (inside Vibe64, `vibe64-helper check`), not on a shared
|
|
44
|
-
development host; a time taken while other work loads the machine is
|
|
45
|
-
reported as such and never used as a baseline.
|
|
46
|
-
|
|
47
|
-
### Fix
|
|
48
|
-
|
|
49
|
-
- Scripts run `jskit test` (`jskit test --databases` for database tests), and
|
|
50
|
-
Playwright and Vitest take their workers from `testConcurrency()`. `jskit
|
|
51
|
-
check` reports a script that runs `node --test` directly, passes a fixed
|
|
52
|
-
concurrency or pins `V64_TEST_CONCURRENCY`, and a Playwright or Vitest config
|
|
53
|
-
that runs files one at a time ([test-run rules](typed-features.md#test-run-rules)).
|
|
54
|
-
- Files that collide are isolated, never run one at a time: a port from
|
|
55
|
-
`listen(0)`, a directory from `mkdtemp`, the database `jskit test --databases`
|
|
56
|
-
gives each file, a scratch database from
|
|
57
|
-
`createPackageTestKnex(t, { environment: process.env })` for a test that
|
|
58
|
-
needs an empty one (or several), another copy of the snapshot, rows
|
|
59
|
-
included, from `claimTestDatabaseCopy(t, { environment: process.env })` for
|
|
60
|
-
a test that needs a second one, and a Vite `cacheDir` of its own. On MySQL
|
|
61
|
-
and MariaDB, `resetTestDatabase({ environment: process.env })` gives a test
|
|
62
|
-
its file's copy afresh mid-file, replacing only the tables written since;
|
|
63
|
-
never build global-setup slots of your own. The
|
|
64
|
-
`// jskit-test: alone - <reason>` marker is only for a file that holds a
|
|
65
|
-
resource of the whole machine.
|
|
66
|
-
- A `jskit test --databases` run whose databases let fewer files run at once
|
|
67
|
-
than the budget (no `TEST_DB_NAME`, or copies the database user may not
|
|
68
|
-
create) says why at its start and end and fails: give the user its copies
|
|
69
|
-
([Integration test databases](database-layer.md#integration-test-databases)).
|
|
70
|
-
- `jskit test --databases` restores each file's database from a snapshot
|
|
71
|
-
rebuilt only when the migrations' digest changes. A file that runs
|
|
72
|
-
`knex.migrate.latest()` itself replays the whole history for every file:
|
|
73
|
-
remove it, and let the full history run once in its own check,
|
|
74
|
-
`jskit migration-history`.
|
|
75
|
-
- A fixture every file only reads (a built app, a composed project, a
|
|
76
|
-
generated tree) is made once, before any file starts, by a global setup
|
|
77
|
-
module: `jskit test --test-global-setup=tests/helpers/globalSetup.js`
|
|
78
|
-
(`jskit test` passes its arguments to `node --test`). Its `globalSetup()`
|
|
79
|
-
makes the fixture and puts its location in an environment variable the test
|
|
80
|
-
processes inherit; its `globalTeardown()` removes it. A file run on its own
|
|
81
|
-
makes the fixture itself when the variable is absent, and a test that writes
|
|
82
|
-
into the fixture makes its own copy.
|
|
83
|
-
- `browserTestConfig()` builds the production frontend once and gives each
|
|
84
|
-
worker its own server, port and seeded database; with a `signIn` module
|
|
85
|
-
each worker signs in once. A check of what a component shows belongs in a
|
|
86
|
-
Vitest component test, and a new browser check is an assertion in the spec
|
|
87
|
-
that already reaches that screen.
|
|
88
|
-
- Wait for the condition, never for time: Playwright's web-first assertions
|
|
89
|
-
(`await expect(locator).toBeVisible()`, `await expect(page).toHaveURL(...)`)
|
|
90
|
-
instead of `page.waitForTimeout()`. The app's own delays (retry backoff,
|
|
91
|
-
debounce, polling) run on a fake clock: `mock.timers` in `node:test`,
|
|
92
|
-
`vi.useFakeTimers()` in Vitest and `page.clock` in Playwright.
|
|
93
|
-
- A file imports what it needs at its top level, so loading counts against the
|
|
94
|
-
file, not against a test's time limit. `jskit test` keeps Node's compile
|
|
95
|
-
cache in `node_modules/.cache/jskit-node-compile-cache`, so each file's
|
|
96
|
-
process loads the modules the files before it compiled.
|
|
97
|
-
- The bounds stay: `jskit test`'s 10 minutes a file and 45 a run,
|
|
98
|
-
`browserTestConfig()`'s `actionTimeout` (15 s), `navigationTimeout` (30 s)
|
|
99
|
-
and `globalTimeout`. A bound in `test-time-bounds.json` rises only with a
|
|
100
|
-
measurement of the work's real need; a file that got slow is fixed instead.
|
|
101
|
-
|
|
102
|
-
### Prove
|
|
103
|
-
|
|
104
|
-
Run the whole suite before and after on the project's test machine with the
|
|
105
|
-
same `V64_TEST_CONCURRENCY`, and report the wall time, each preparation phase, the
|
|
106
|
-
slowest files and the test counts, which stay the same.
|
|
16
|
+
database time, apply that page to the path. The test suite's time belongs to
|
|
17
|
+
the [test pass](test-pass.md).
|
|
107
18
|
|
|
108
19
|
## Client speed
|
|
109
20
|
|
|
@@ -208,4 +119,5 @@ Report each main route's time before and after, with its statement count, at
|
|
|
208
119
|
the realistic size, the first after boot and later ones. Keep an
|
|
209
120
|
`expectFlatQueries()` test for each path whose count you changed.
|
|
210
121
|
|
|
211
|
-
Then run `npx jskit check
|
|
122
|
+
Then run `npx jskit check`. `npm run verify`, the whole run, runs once, at the
|
|
123
|
+
end, only with the person's OK.
|
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
<!-- Generated from `packages/agent-docs/site/guide/framework/test-pass.md`. -->
|
|
2
|
+
|
|
3
|
+
# Test pass
|
|
4
|
+
|
|
5
|
+
A test pass makes the test suite prove what the app does, quickly. Genesis's
|
|
6
|
+
test pass skill (`genesis-test-pass`) holds the method: each behavior's test
|
|
7
|
+
fails without it, each file owns what it uses and reaches no outside service,
|
|
8
|
+
preparation happens once per run and files run in parallel, every run names
|
|
9
|
+
every failure, and the guidance says exactly how the suite runs. This page is
|
|
10
|
+
JSKIT's half: for each item, the command, file or check that proves it in a
|
|
11
|
+
JSKIT app. Work through it top to bottom and tick an item only with its proof.
|
|
12
|
+
The rules it applies are in [Typed features](typed-features.md),
|
|
13
|
+
[Database layer](database-layer.md) and
|
|
14
|
+
[UI operations](ui-operations.md); query counts belong to the
|
|
15
|
+
[data pass](data-pass.md).
|
|
16
|
+
|
|
17
|
+
## Run the checks first
|
|
18
|
+
|
|
19
|
+
- `npx jskit check` reads the test scripts, test files, Playwright and Vitest
|
|
20
|
+
configs, CI workflows and the root Vite config, and names what makes a run
|
|
21
|
+
slow, fragile or unsafe, each finding with the change to make
|
|
22
|
+
([Test-run rules](typed-features.md#test-run-rules)). Its
|
|
23
|
+
findings are the pass's first items, and every one passes at its end.
|
|
24
|
+
- `npm run lint` passes too.
|
|
25
|
+
|
|
26
|
+
## Map and measure the suite
|
|
27
|
+
|
|
28
|
+
- The parts of a JSKIT app's suite, each one command: the Node tests
|
|
29
|
+
(`npm test`, which is `jskit test --databases` once the app has a database),
|
|
30
|
+
the client tests (`npm run test:client`, Vitest), the browser tests
|
|
31
|
+
(`npm run test:e2e`, Playwright through `browserTestConfig()`) and the
|
|
32
|
+
migration history (`jskit migration-history`). `npm run verify` runs them
|
|
33
|
+
after `jskit check` and lint, as
|
|
34
|
+
[Running the checks](typed-features.md#running-the-checks)
|
|
35
|
+
states once.
|
|
36
|
+
- `jskit test --list` prints the files a run takes and their total, and runs
|
|
37
|
+
nothing: the total matches the test files under `tests/`, or a file is named
|
|
38
|
+
so that node's default pattern leaves it out.
|
|
39
|
+
- `jskit test` starts by saying how many files it runs at a time and where that
|
|
40
|
+
number came from (the host's `V64_TEST_CONCURRENCY`, else half the CPUs), and
|
|
41
|
+
ends with its 10 slowest files and tests; each file's time is kept in
|
|
42
|
+
`node_modules/.cache/jskit-test/file-times.json`. A run through
|
|
43
|
+
`browserTestConfig()` ends with its 10 slowest tests, and test database
|
|
44
|
+
preparation reports each phase and its duration.
|
|
45
|
+
- Take the baseline from one whole run of each part, its files in parallel at
|
|
46
|
+
the real `V64_TEST_CONCURRENCY`: its per-file times are the baseline table.
|
|
47
|
+
After a batch of fixes, run the part again for the times after, and compare
|
|
48
|
+
per file and in total. A wall time near the sum of the files' times divided by
|
|
49
|
+
the budget is right; near the plain sum, the files ran one after another. A
|
|
50
|
+
single-file run (`npm test -- <file>`) is for one change's red and green,
|
|
51
|
+
never the way to take a baseline or a before-and-after table, and never one
|
|
52
|
+
of serial runs queued one after another. Run on the host's test machine, when the host offers one, not on a
|
|
53
|
+
shared development host; a time taken while other work loads the machine is
|
|
54
|
+
reported as such and never used as a baseline.
|
|
55
|
+
- The pass's own measurement, one run of each part before the work and one
|
|
56
|
+
after, is part of the pass the person asked for. `npm run verify`, the whole
|
|
57
|
+
run, runs once, at the end, only with the person's OK.
|
|
58
|
+
|
|
59
|
+
## Each test proves a behavior
|
|
60
|
+
|
|
61
|
+
- Break the behavior and see its test fail: revert the line or return the
|
|
62
|
+
wrong value, several at once in one run (`npm test -- <files>` runs exactly
|
|
63
|
+
those files), then restore it. A behavior no test catches gets one, seen to fail first.
|
|
64
|
+
- Nothing is weakened: no `test.skip`, `test.only`, `{ skip: true }`,
|
|
65
|
+
`test.fixme`, `retries` or raised `timeout` in a test or config without its
|
|
66
|
+
stated reason and the run that covers the skipped behavior.
|
|
67
|
+
- A rule or calculation is a Node unit test; data, access and refusals a server
|
|
68
|
+
test over `app.inject` on the file's own database
|
|
69
|
+
([Tests](data-access.md#tests)); what a component shows a
|
|
70
|
+
Vitest component test; a browser test only for a flow across screens,
|
|
71
|
+
navigation, layout at the standard widths, focus or the real sign-in. A new
|
|
72
|
+
browser check is an assertion in the spec that already reaches the screen.
|
|
73
|
+
- A browser test finds what a person finds: `getByRole`, `getByLabel` and
|
|
74
|
+
`getByText` with the app's own words, never a Vuetify class (`.v-btn`,
|
|
75
|
+
`.v-list-item`), a generated class or text Vuetify supplies.
|
|
76
|
+
- A list, batch or write path has a count test at a few rows and at a
|
|
77
|
+
realistic number: `expectFlatQueries()`
|
|
78
|
+
([data pass](data-pass.md)). A count that grows with the rows
|
|
79
|
+
is a product defect, fixed as the data pass says.
|
|
80
|
+
|
|
81
|
+
## Each file owns what it uses
|
|
82
|
+
|
|
83
|
+
- `jskit test --databases` gives each file running at once its own copy of
|
|
84
|
+
`TEST_DB_NAME`, restored from the snapshot, and fails a run whose databases
|
|
85
|
+
allow fewer files than the budget
|
|
86
|
+
([Integration test databases](database-layer.md#integration-test-databases)).
|
|
87
|
+
A test that needs more takes it from JSKIT: an empty scratch database from
|
|
88
|
+
`createPackageTestKnex(t, { environment: process.env })`, a second copy of
|
|
89
|
+
the snapshot from `claimTestDatabaseCopy(t, { environment: process.env })`,
|
|
90
|
+
and its own copy afresh mid-file from
|
|
91
|
+
`resetTestDatabase({ environment: process.env })`. A port comes from
|
|
92
|
+
`listen(0)`, a directory from `mkdtemp`, a Vite `cacheDir` of its own.
|
|
93
|
+
- No name is written into a test, script, config or CI workflow:
|
|
94
|
+
`jskit check` names a fixed database name and a CI `TEST_DB_NAME` equal to
|
|
95
|
+
`DB_NAME`, and JSKIT refuses to run tests on `DB_NAME` at all.
|
|
96
|
+
- Under `jskit test`, the test processes and the app servers the browser tests
|
|
97
|
+
start reach only loopback, unix sockets and the configured database hosts;
|
|
98
|
+
any other connection fails with `JSKIT_TEST_NETWORK_REFUSED`, naming the host
|
|
99
|
+
and the fix. That is the run with outbound network refused, on every run: a
|
|
100
|
+
test that fails with it reached an outside service, so stub what it reached
|
|
101
|
+
at the seam the app already uses. A file that must reach one says why on its
|
|
102
|
+
first line, `// jskit-test: network - <reason>`, and runs without the guard.
|
|
103
|
+
- Every process `jskit test` starts runs as `APP_ENV=test`
|
|
104
|
+
([Environments](environments.md)): only production sends for
|
|
105
|
+
real.
|
|
106
|
+
- A file that holds a resource of the whole machine says so on its first line,
|
|
107
|
+
`// jskit-test: alone - <reason>`, and runs after the others; no other file
|
|
108
|
+
does.
|
|
109
|
+
|
|
110
|
+
## Each run takes the time its work needs
|
|
111
|
+
|
|
112
|
+
- Databases come from a snapshot taken once per change of the migrations'
|
|
113
|
+
digest and kept on the database server, where `npm ci` cannot empty it: on
|
|
114
|
+
MySQL and MariaDB the database `<TEST_DB_NAME>_0`, whose tables each copy's
|
|
115
|
+
are made from, and a restore replaces only the tables a file changed; on
|
|
116
|
+
PostgreSQL the database `<TEST_DB_NAME>_snapshot`, which each copy is created
|
|
117
|
+
from ([Test databases are prepared once](typed-features.md#test-databases-are-prepared-once)).
|
|
118
|
+
A file that runs `knex.migrate.latest()` itself replays the whole history:
|
|
119
|
+
remove it.
|
|
120
|
+
- `jskit migration-history` is the one check that replays the full history,
|
|
121
|
+
from empty, as `APP_ENV=test`, and compares it with the snapshot. Rows a
|
|
122
|
+
migration fills from the clock match: on MySQL and MariaDB both builds run
|
|
123
|
+
with the clock stopped (`SET TIMESTAMP` and JavaScript's `Date`), and on
|
|
124
|
+
PostgreSQL a value taken from the clock compares as the clock's. A seed
|
|
125
|
+
stamped from a random value fails it; a migration that has run is never
|
|
126
|
+
edited to fix it, a new one corrects the rows.
|
|
127
|
+
- A fixture every file only reads is made once, before any file starts:
|
|
128
|
+
`jskit test --test-global-setup=tests/helpers/globalSetup.js`. Its
|
|
129
|
+
`globalSetup()` puts the fixture's location in an environment variable the
|
|
130
|
+
files inherit; a file run on its own makes the fixture itself, and a test
|
|
131
|
+
that writes into it makes its own copy.
|
|
132
|
+
- `browserTestConfig()` builds the production frontend once and reuses it
|
|
133
|
+
while its inputs are unchanged, and gives each of `browserTestWorkers()`
|
|
134
|
+
workers (half the budget, at least one) its own server, port and seeded copy
|
|
135
|
+
of `BROWSER_TEST_DB_NAME`; with a `signIn` module each worker signs in once.
|
|
136
|
+
A build that writes into its own inputs is never reused (`not kept for
|
|
137
|
+
reuse, as src changed while it ran`): vue-router's generated types go to
|
|
138
|
+
`types/typed-router.d.ts`, outside `src`.
|
|
139
|
+
- No fixed sleep: a web-first assertion (`await expect(locator).toBeVisible()`),
|
|
140
|
+
`expect.poll()`, the event itself, or a fake clock (`mock.timers`,
|
|
141
|
+
`vi.useFakeTimers()`, `page.clock`) for the app's own delays. The one fixed
|
|
142
|
+
wait that stays proves nothing happens in a window and says so on the line
|
|
143
|
+
before, `// jskit-test: fixed-wait - <reason>`.
|
|
144
|
+
- A file imports what it needs at its top level, so loading counts against the
|
|
145
|
+
file, not a test's time limit.
|
|
146
|
+
- The bounds stay: `jskit test`'s 10 minutes a file and 45 a run, and
|
|
147
|
+
`browserTestConfig()`'s `actionTimeout`, `navigationTimeout` and
|
|
148
|
+
`globalTimeout`. A bound in `test-time-bounds.json` rises only with a
|
|
149
|
+
measurement of the work's real need.
|
|
150
|
+
- A passing run prints what a person reads: test servers log at
|
|
151
|
+
`LOG_LEVEL=warn` unless the shell asks for more.
|
|
152
|
+
|
|
153
|
+
## Every run reports every failure
|
|
154
|
+
|
|
155
|
+
- Each part is one command that runs all its files in one parallel run:
|
|
156
|
+
`jskit check` names a script that runs `node --test` itself, a fixed
|
|
157
|
+
concurrency or worker count, and files or globs given to `jskit test`.
|
|
158
|
+
- `npm run verify` chains its parts with `&&`: it stops at the first part that
|
|
159
|
+
fails, exits non-zero and npm names that script. Prove it once without a
|
|
160
|
+
whole run: put a lint error in a file, see `npm run verify` stop at
|
|
161
|
+
`lint` with a non-zero exit, and remove it. CI runs the same parts and fails
|
|
162
|
+
on any of them.
|
|
163
|
+
- A failed, cancelled or timed-out test, and a file that fails to load, fail
|
|
164
|
+
`jskit test`; `jskit test --list` shows the files the run takes.
|
|
165
|
+
|
|
166
|
+
## The guidance says how the suite runs
|
|
167
|
+
|
|
168
|
+
- The app's `AGENTS.md` keeps only what is specific to the app, and links
|
|
169
|
+
these guides for the rest. `genesis/stack.md`'s Verification declares each
|
|
170
|
+
part of `npm run verify`, in the same order, the browser suite on the
|
|
171
|
+
production build included.
|
|
172
|
+
- A managed host runs the browser suite on its declared test target,
|
|
173
|
+
`jskit browser-test-server {host} {port} {workers}`, which names
|
|
174
|
+
`PLAYWRIGHT_PORT` so each worker opens its own server's database, never on
|
|
175
|
+
the development server
|
|
176
|
+
([Browser verification](ui-operations.md#browser-verification)).
|
|
177
|
+
- No rotten instruction stays: a development server for checks, the whole suite
|
|
178
|
+
after each change, single files timed in turn, retrying or loosening a
|
|
179
|
+
failing test, fixed sleeps, shared database names or ports, a hard-coded
|
|
180
|
+
worker count, migrations replayed per test.
|
|
181
|
+
- The committed Agent Skill copies match the Genesis that serves the project:
|
|
182
|
+
`genesis check` passes, and `genesis skills sync` refreshes them.
|
|
183
|
+
|
|
184
|
+
## After a JSKIT update
|
|
185
|
+
|
|
186
|
+
Update with `npm run jskit:update`, then fix what the update reports, these
|
|
187
|
+
first:
|
|
188
|
+
|
|
189
|
+
- `jskit check`'s test rules report patterns earlier releases let pass: a
|
|
190
|
+
fixed sleep, a fixed database name, a CI test database equal to `DB_NAME`, a
|
|
191
|
+
generated file written into `src`, files given to `jskit test`. Each finding
|
|
192
|
+
names its change.
|
|
193
|
+
- The foundation patterns write vue-router's types to
|
|
194
|
+
`types/typed-router.d.ts`: move the file and its `.gitignore` line, and point
|
|
195
|
+
`dts` there.
|
|
196
|
+
- A test that reached an outside service now fails with
|
|
197
|
+
`JSKIT_TEST_NETWORK_REFUSED`: stub it, or give the file its
|
|
198
|
+
`// jskit-test: network - <reason>` line.
|
|
199
|
+
- Test servers log at `LOG_LEVEL=warn`: a test that reads info logs sets
|
|
200
|
+
`LOG_LEVEL` itself.
|
|
201
|
+
- On MySQL and MariaDB the test database snapshot moved from
|
|
202
|
+
`node_modules/.cache` to the database server: the first run takes a new one,
|
|
203
|
+
and the old cache folder can go.
|
|
204
|
+
- `jskit migration-history` runs as `APP_ENV=test` by itself: an `APP_ENV=test`
|
|
205
|
+
in front of it in a script can go.
|
|
@@ -1064,7 +1064,8 @@ its own app server, and no more than the memory available holds at the peak
|
|
|
1064
1064
|
the last run's largest app server reached.**
|
|
1065
1065
|
|
|
1066
1066
|
- The budget is `V64_TEST_CONCURRENCY` when it is a positive whole number (a
|
|
1067
|
-
|
|
1067
|
+
host's variable, not JSKIT's: the budget a host or test runner sets for the
|
|
1068
|
+
machine's test slots, read when set), otherwise half of
|
|
1068
1069
|
the CPUs the process may use, rounded down and at least 1: a 2-vCPU VPS runs
|
|
1069
1070
|
one file at a time, an 8-thread machine four, and a container or slice whose
|
|
1070
1071
|
cgroup `cpu.max` quota gives it 3 CPUs of a 16-thread machine one
|
|
@@ -1129,6 +1130,17 @@ the last run's largest app server reached.**
|
|
|
1129
1130
|
`// jskit-test: alone - <reason>`. `jskit test` runs it after the others,
|
|
1130
1131
|
one such file at a time, and fails on a marker without a reason or below the
|
|
1131
1132
|
first line.
|
|
1133
|
+
- Tests never reach an outside service, even when a developer's real keys sit
|
|
1134
|
+
in the environment they inherit. Every Node process `jskit test` and the
|
|
1135
|
+
browser test servers start, and every one those start, connects only to
|
|
1136
|
+
loopback, `localhost`, unix sockets and the database host the environment
|
|
1137
|
+
names (`DB_HOST`, `DATABASE_URL`); any other connection fails before its
|
|
1138
|
+
name is looked up, with `JSKIT_TEST_NETWORK_REFUSED` naming the host. Stub
|
|
1139
|
+
the service at the seam the app already uses: an injected client or provider
|
|
1140
|
+
double, or a test-only env value pointing at a local fake. A test file that
|
|
1141
|
+
must reach one says why on its first line,
|
|
1142
|
+
`// jskit-test: network - <reason>`, and `jskit test` runs it without the
|
|
1143
|
+
guard, after the others; a marker without a reason fails the run.
|
|
1132
1144
|
- `jskit test` ends with its 10 slowest test files and tests, records each
|
|
1133
1145
|
file's time in `node_modules/.cache/jskit-test/file-times.json`, and fails
|
|
1134
1146
|
when a file takes more than 10 minutes or the whole command more than 45:
|
|
@@ -1403,6 +1415,7 @@ that must run alone says so on its own first line instead.
|
|
|
1403
1415
|
| `test/playwright-isolation` | a Playwright webServer every worker shares, without `browserTestConfig()` | [Test files run in parallel](#test-files-run-in-parallel) |
|
|
1404
1416
|
| `test/playwright-global-timeout` | a Playwright config without a `globalTimeout` (or `browserTestConfig()`), or with `globalTimeout: 0` | [Test files run in parallel](#test-files-run-in-parallel) |
|
|
1405
1417
|
| `test/vitest-workers` | `--maxWorkers`, `--minWorkers` or `--no-file-parallelism` passed to Vitest, or its config without `maxWorkers: testConcurrency()` or with `fileParallelism: false` | [Test files run in parallel](#test-files-run-in-parallel) |
|
|
1418
|
+
| `test/script-files` | a script that gives `jskit test` files or globs (`jskit test --databases tests/*.test.js`), so `npm test -- <file>` runs every file and that one; drop them, as `jskit test` finds test files by node's default pattern | [Test files run in parallel](#test-files-run-in-parallel) |
|
|
1406
1419
|
|
|
1407
1420
|
The rules see shapes, not intent. Feature files, owned state beyond
|
|
1408
1421
|
registries, shutdown, loggers, shared action fields, strict inputs, the action
|
|
@@ -1410,6 +1423,56 @@ policy, request context, validated input, one reader per fact, routes,
|
|
|
1410
1423
|
internal failures, swallowed failures, test doubles, tests as callers, data
|
|
1411
1424
|
modules and names are checked by reading.
|
|
1412
1425
|
|
|
1426
|
+
### Test-source rules
|
|
1427
|
+
|
|
1428
|
+
`jskit check` also reads an application's test files (`*.test.*`,
|
|
1429
|
+
`*.spec.*` and every file under a `test` or `tests` folder), its test
|
|
1430
|
+
scripts, its Playwright and Vitest configs, its CI workflows and its root
|
|
1431
|
+
Vite config, and reports what makes a test run slow, fragile or unsafe.
|
|
1432
|
+
|
|
1433
|
+
| Rule | Reports | Fix |
|
|
1434
|
+
| --- | --- | --- |
|
|
1435
|
+
| `test/fixed-sleep` | in a test file, `page.waitForTimeout(…)`, a `new Promise` that resolves on `setTimeout(…, <ms>)`, or an awaited `setTimeout`, `sleep`, `delay`, `wait` or `pause` of a number of milliseconds | wait for the condition: a web-first assertion (`await expect(locator).toBeVisible()`), `expect.poll()`, the event itself, or a fake clock (`mock.timers`, `vi.useFakeTimers()`, `page.clock`) |
|
|
1436
|
+
| `test/fixed-database-name` | a test script that sets `TEST_DB_NAME`, `BROWSER_TEST_DB_NAME` or `DB_NAME`; a test file or runner config that falls back to or assigns a name for one (`process.env.TEST_DB_NAME \|\| "shop_test"`); a runner config that names one (`DB_NAME: "shop_e2e"`) | drop the name: the run's test-only env file or the host names the database, `jskit test --databases` gives each test file its own copy of `TEST_DB_NAME`, and `browserTestConfig()`'s `prepare` module derives each worker's from `BROWSER_TEST_DB_NAME` |
|
|
1437
|
+
| `test/test-database-is-app-database` | a CI workflow whose `TEST_DB_NAME` or `BROWSER_TEST_DB_NAME` is its `DB_NAME`, by value or as an `env.DB_NAME` expression | give it a name of its own, such as `<DB_NAME>_test`: a test run replaces its test databases from the snapshot, and JSKIT refuses to run one on `DB_NAME` |
|
|
1438
|
+
| `test/generated-into-src` | a `dts` path under `src/` in the root `vite.config.*`, such as vue-router's `src/typed-router.d.ts` or a components declaration file | write it outside `src`, such as `dts: "types/typed-router.d.ts"`, and move the file and its `.gitignore` line: a file written into `src` while the frontend builds keeps the browser tests from reusing that build (`not kept for reuse, as src changed while it ran`) |
|
|
1439
|
+
|
|
1440
|
+
A 0 ms timer yields a turn and is not reported. The one fixed wait a test
|
|
1441
|
+
needs is a window that proves nothing happens, such as no second read within
|
|
1442
|
+
it, and it says so on the line before, with its reason; a marker without a
|
|
1443
|
+
reason is a finding itself, and no other comment excuses these rules:
|
|
1444
|
+
|
|
1445
|
+
```js
|
|
1446
|
+
// jskit-test: fixed-wait - the window in which the list must make no second read
|
|
1447
|
+
await page.waitForTimeout(2000);
|
|
1448
|
+
```
|
|
1449
|
+
|
|
1450
|
+
Why: a fixed sleep makes every run as slow as its longest guess and fails on
|
|
1451
|
+
a loaded machine; a test database name in the project makes two runs wipe
|
|
1452
|
+
each other's rows; a test database that is the application's own is replaced
|
|
1453
|
+
from the snapshot; and a build that writes into its own sources is never
|
|
1454
|
+
reused.
|
|
1455
|
+
|
|
1456
|
+
### Agent instructions
|
|
1457
|
+
|
|
1458
|
+
`npx jskit agents` writes JSKIT's app guidance, the guide's links and the
|
|
1459
|
+
rules no check enforces, in the app's `AGENTS.md`, between these markers:
|
|
1460
|
+
|
|
1461
|
+
```md
|
|
1462
|
+
<!-- jskit:begin app guidance (written by npx jskit agents; edit outside this block) -->
|
|
1463
|
+
<!-- jskit:end app guidance -->
|
|
1464
|
+
```
|
|
1465
|
+
|
|
1466
|
+
It replaces what lies between them and leaves the text outside as it is; in a
|
|
1467
|
+
file without them it puts the block at the top, and it makes the file when
|
|
1468
|
+
there is none. `npm run jskit:update` writes it after updating the packages, so
|
|
1469
|
+
commit `AGENTS.md` with the manifests. Write the app's own rules outside the
|
|
1470
|
+
block.
|
|
1471
|
+
|
|
1472
|
+
| Rule | Reports | Section |
|
|
1473
|
+
| --- | --- | --- |
|
|
1474
|
+
| `agents/jskit-block` | an app whose `package.json` declares `@jskit-ai/jskit-catalog` without that catalog's block in `AGENTS.md`, or with the block changed | [Agent instructions](#agent-instructions) |
|
|
1475
|
+
|
|
1413
1476
|
### Exceptions
|
|
1414
1477
|
|
|
1415
1478
|
A justified exception carries a comment on the line before it, naming the
|
|
@@ -83,18 +83,53 @@ main-menu destinations show no arrow, a reload keeps the trail, and Save or
|
|
|
83
83
|
Cancel never leaves the form in it. Find a field by its exact label:
|
|
84
84
|
`page.getByLabel("Email", { exact: true })`.
|
|
85
85
|
|
|
86
|
-
Where the host provides a managed browser runner,
|
|
87
|
-
through it from the first run,
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
86
|
+
Where the host provides a managed browser runner, such as Vibe64's, every
|
|
87
|
+
Playwright suite runs through it from the first run, on a declared test target:
|
|
88
|
+
give the runner the package script (on Vibe64,
|
|
89
|
+
`vibe64-helper playwright --target test-app npm-run test:e2e`), and never start
|
|
90
|
+
`npx playwright test`, `playwright test` or `npm run test:e2e` yourself. Specs
|
|
91
|
+
that write run only on a test target with its own database, never on the
|
|
92
|
+
person's development target or database. The host owns its browser and may
|
|
93
|
+
provide `PLAYWRIGHT_STORAGE_STATE`; never print or commit that value, bypass
|
|
94
|
+
it, or install another browser. If tests run signed out despite that state,
|
|
95
|
+
report the host defect with evidence and stop; never rewrite its cookies or add
|
|
96
|
+
a login.
|
|
97
|
+
|
|
98
|
+
A test target runs `jskit browser-test-server` on the host's ports: `{workers}`
|
|
99
|
+
servers of the app's own `browserTestConfig()`, each with the production build,
|
|
100
|
+
the database its `prepare` module gives that worker and `APP_ENV=test`. Keep
|
|
101
|
+
`BROWSER_TEST_DB_NAME` distinct from `TEST_DB_NAME`, which the Node tests'
|
|
102
|
+
copies come from. A Vibe64 project declares it in `genesis/stack.md`'s
|
|
103
|
+
`## Outputs` (Genesis's `jskit` Stack piece writes it into a new project); one
|
|
104
|
+
without it adds:
|
|
105
|
+
|
|
106
|
+
```md
|
|
107
|
+
### Target `test-app`: Test Preview
|
|
108
|
+
|
|
109
|
+
- Mode: `interactive`
|
|
110
|
+
- Data: `test`
|
|
111
|
+
- Runtimes: `nodejs`
|
|
112
|
+
- Run `Serve on the test database`: `node_modules/.bin/jskit` `browser-test-server` `{host}` `{port}` `{workers}`
|
|
113
|
+
|
|
114
|
+
#### Presentation
|
|
115
|
+
|
|
116
|
+
- Kind: `web`
|
|
117
|
+
- URL path: `/`
|
|
118
|
+
- Ready when: `GET` `/api/health` returns `200`
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
The build and the snapshot are reused while their sources are unchanged, so a
|
|
122
|
+
focused check never rebuilds them. After a change to the browser-test setup,
|
|
123
|
+
run the suite twice: the second run says `Frontend build unchanged, reused` and
|
|
124
|
+
passes the same tests.
|
|
125
|
+
|
|
93
126
|
For explicitly enabled direct-local auth, use
|
|
94
127
|
`loginAsExistingUser()` from `@jskit-ai/auth-web/test/playwright`; never expose
|
|
95
128
|
the exchange secret to browser code, URLs, or client environment.
|
|
96
129
|
|
|
97
|
-
Without a managed runner, run the
|
|
130
|
+
Without a managed runner, `npm run test:e2e` runs the whole suite locally,
|
|
131
|
+
each worker on its own server, port and database; run the narrow test
|
|
132
|
+
directly:
|
|
98
133
|
|
|
99
134
|
```bash
|
|
100
135
|
npx playwright test <test-file> -g "<changed behavior>"
|