@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
|
@@ -2,6 +2,11 @@
|
|
|
2
2
|
|
|
3
3
|
# Mobile Capacitor
|
|
4
4
|
|
|
5
|
+
When someone wants the app on their phone, propose
|
|
6
|
+
[an app people install from its website](/guide/recipes/installable-app)
|
|
7
|
+
first: no store, push notifications and sharing in, from the same app. This
|
|
8
|
+
page is that recipe's other option, a native app in the stores.
|
|
9
|
+
|
|
5
10
|
Use `@jskit-ai/mobile-capacitor` when the web application should run inside a
|
|
6
11
|
Capacitor Android shell.
|
|
7
12
|
|
|
@@ -1052,14 +1052,16 @@ too, keeping the name.
|
|
|
1052
1052
|
|
|
1053
1053
|
A sign-in lands on the page its `returnTo` names. Without one, or with one
|
|
1054
1054
|
refused as on another origin or as a sign-in or sign-out page, it lands on
|
|
1055
|
-
`DefaultLoginView`'s `fallbackReturnTo` prop,
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1055
|
+
`DefaultLoginView`'s `fallbackReturnTo` prop, by default the root of the app's
|
|
1056
|
+
default surface (`config.surfaceDefaultId`: `/home` in the foundations), so an
|
|
1057
|
+
app whose `/` is a website, such as a static one its server serves, lands on
|
|
1058
|
+
its own screens. An app names another landing there (`<DefaultLoginView
|
|
1059
|
+
fallbackReturnTo="/account">`, in its `LoginView.vue` wrapper); an app without
|
|
1060
|
+
surfaces lands on `/`. Sign-out passes its own `returnTo` on to sign-in, and
|
|
1061
|
+
without one opens sign-in without one, so that landing applies after it too. A
|
|
1062
|
+
browser the shell found signed in at boot is shown no form: the page checks the
|
|
1063
|
+
session again and sends it on, and shows the form only if the session has
|
|
1064
|
+
ended. A confirmation link or a provider's callback still shows its own state.
|
|
1063
1065
|
|
|
1064
1066
|
A sign-in link may name the address to sign in with (`/auth/login?email=...`,
|
|
1065
1067
|
as an invitation's link names the invited one). That address fills the form
|
|
@@ -395,38 +395,52 @@ the application's `knexfile.js`:
|
|
|
395
395
|
those two replaced, is set.
|
|
396
396
|
Every file starts from the snapshot, rows included: a copy an earlier file of
|
|
397
397
|
the run used is restored before the next file takes it, so no file sees what
|
|
398
|
-
another wrote. On MySQL and MariaDB the restore replaces only the tables
|
|
399
|
-
differ from the snapshot, found exactly: a table's definition and its
|
|
398
|
+
another wrote. On MySQL and MariaDB the restore replaces only the tables
|
|
399
|
+
that differ from the snapshot, found exactly: a table's definition and its
|
|
400
400
|
`AUTO_INCREMENT` counter (`SHOW CREATE TABLE`, so a row written and deleted,
|
|
401
|
-
or a write rolled back, counts), a trigger on it,
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
401
|
+
or a write rolled back, counts), a trigger on it, rows whose `CHECKSUM
|
|
402
|
+
TABLE` is not the snapshot's, and tables missing or added; each replaced
|
|
403
|
+
table is made on the server, its definition and then its rows copied from
|
|
404
|
+
the snapshot database (`INSERT ... SELECT`), so no row passes through Node;
|
|
405
|
+
a preparation fills up to eight tables at once, each on a connection of its
|
|
406
|
+
own, shared between the databases it restores at once, and a test file's
|
|
407
|
+
restore fills on its share of the eight by the run's files at once, so a
|
|
408
|
+
run never fills on more than eight connections, plus one for each database
|
|
409
|
+
being restored. No table waits in a connection pool's queue, where Knex gives
|
|
410
|
+
up after its `acquireConnectionTimeout`.
|
|
411
|
+
The tables it fills are then sampled for the planner in one `ANALYZE TABLE`:
|
|
412
|
+
InnoDB keeps the statistics it took of the empty table until it samples it
|
|
413
|
+
again, and the planner would read a filled table as empty.
|
|
414
|
+
A file that wrote three tables costs three tables, not the whole schema. On
|
|
415
|
+
PostgreSQL the copy is made again from the snapshot database, which costs
|
|
416
|
+
less than finding the tables; the snapshot database is analyzed once when
|
|
417
|
+
it is built (`ANALYZE`), so each copy has its statistics.
|
|
418
|
+
- `TEST_DB_NAME` and its copies stay on the server when the run ends,
|
|
419
|
+
whether its test files passed, failed or were stopped (Ctrl-C, `SIGTERM`),
|
|
420
|
+
or its foreign key check failed before the first file, and so do the copies
|
|
421
|
+
a run of fewer files does not take: the next run restores each one it takes
|
|
422
|
+
instead of making it again. On MySQL and MariaDB a run after one whose files
|
|
423
|
+
wrote three tables copies those three, not the schema; its summary says how
|
|
424
|
+
many tables its restores copied (`restore 412ms of 3 table(s)`). A run that
|
|
425
|
+
never reached its end (killed with `SIGKILL`, stopped at a command's time
|
|
426
|
+
limit, or on a machine that went down) leaves nothing the next run does not
|
|
427
|
+
restore, a table it was copying included. Each copy takes the disk space of
|
|
428
|
+
the snapshot's rows, and there are as many as the most files a run took at
|
|
429
|
+
once; they last until the project's test databases are dropped. Two runs at
|
|
430
|
+
once on one database name still are not supported.
|
|
423
431
|
- The snapshot holds the schema as the engine reports it and the rows the
|
|
424
|
-
migrations wrote, including the migration ledger
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
`<TEST_DB_NAME>
|
|
428
|
-
|
|
429
|
-
|
|
432
|
+
migrations wrote, including the migration ledger, in a database of its own
|
|
433
|
+
on the database server, where `npm ci`, which empties `node_modules`, cannot
|
|
434
|
+
remove it: one for each test database, replaced when its key changes. On
|
|
435
|
+
MySQL and MariaDB it is `<TEST_DB_NAME>_0`, two characters as each copy's,
|
|
436
|
+
so a host that grants each database by name grants it within the same length
|
|
437
|
+
(the user needs all privileges on it, as on `TEST_DB_NAME` and its copies;
|
|
438
|
+
without them the run takes one file at a time and names the grant); its
|
|
439
|
+
label, a table of its own, holds its key, the server's version, each table's
|
|
440
|
+
definition and the `CHECKSUM TABLE` a copy is compared with. On PostgreSQL
|
|
441
|
+
it is the database `<TEST_DB_NAME>_snapshot`, which `CREATE DATABASE <name>
|
|
442
|
+
TEMPLATE <snapshot>` copies while nothing is connected to it (the user needs
|
|
443
|
+
`CREATEDB`), file by file (`STRATEGY FILE_COPY`) from PostgreSQL 15. Its key
|
|
430
444
|
is a digest of the dialect, of the name and contents of every migration file
|
|
431
445
|
that the application's `migrations/` and its installed packages supply, and
|
|
432
446
|
of `package-lock.json`, since an upgraded package can change a helper its
|
|
@@ -479,7 +493,8 @@ the application's `knexfile.js`:
|
|
|
479
493
|
snapshot's. The harness restores the snapshot before another test file uses
|
|
480
494
|
that database, instead of running `migrate.latest()` over the whole history.
|
|
481
495
|
- A browser run's seed is not part of the snapshot: it runs in each restored
|
|
482
|
-
database, in one transaction
|
|
496
|
+
database, in one transaction, and its tables are then sampled for the
|
|
497
|
+
planner (`ANALYZE`) ([Browser test preparation](#browser-test-preparation)).
|
|
483
498
|
- Only `jskit migration-history`, the full-history check in
|
|
484
499
|
[Verification](#verification), replays the whole history, as its own step:
|
|
485
500
|
the migrations, or the knexfile's `testDatabaseSchema` build, from empty
|
|
@@ -531,19 +546,16 @@ transaction each, so stale rows never survive a run and the migrations are
|
|
|
531
546
|
replayed only when one changes. It refuses the application's database,
|
|
532
547
|
`STAGING_DB_NAME`, `PRODUCTION_DB_NAME`, `TEST_DB_NAME` and their copies.
|
|
533
548
|
When the run stops (Playwright's `SIGTERM`, Ctrl-C, or a start that failed), the
|
|
534
|
-
launcher stops its servers
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
the 10 s Playwright gives its webServer; `BROWSER_TEST_DB_NAME` and the snapshot
|
|
538
|
-
stay. `prepareTestDatabases()` itself drops the copies it made when it throws,
|
|
539
|
-
for a Node or a browser run alike.
|
|
549
|
+
launcher stops its servers within the 10 s Playwright gives its webServer;
|
|
550
|
+
`BROWSER_TEST_DB_NAME`, its copies and the snapshot stay for the next run, which
|
|
551
|
+
restores them.
|
|
540
552
|
|
|
541
553
|
Give disposable integration and migration tests their own `TEST_DB_NAME`;
|
|
542
554
|
the two names, and their copies, must differ, and the application account
|
|
543
555
|
needs grants for each (a `<app>_%` grant covers the copies). Each preparation
|
|
544
556
|
reports how many databases it made, whether it replayed the migrations for a
|
|
545
|
-
new snapshot,
|
|
546
|
-
to the caller.
|
|
557
|
+
new snapshot, its restore and seed durations and how many tables its restores
|
|
558
|
+
copied, so a cold rebuild is visible to the caller.
|
|
547
559
|
|
|
548
560
|
Run related checks in one suite invocation and prepare only their required
|
|
549
561
|
fixtures. A local browser run serves the production build, never the
|
|
@@ -93,7 +93,9 @@ still have callers and tests.
|
|
|
93
93
|
Audit application `AGENTS.md` files, ordinary documentation, npm scripts, CI,
|
|
94
94
|
and package metadata as well as executable source. There is no supported
|
|
95
95
|
`jskit doctor` command or general JSKIT source-authoring CLI. The supported
|
|
96
|
-
`jskit update` and `jskit check` commands own only the installed package graph
|
|
96
|
+
`jskit update` and `jskit check` commands own only the installed package graph
|
|
97
|
+
and the JSKIT block of `AGENTS.md`
|
|
98
|
+
([Agent instructions](/guide/framework/typed-features#agent-instructions));
|
|
97
99
|
they do not author, regenerate, or certify application source. Replace stale
|
|
98
100
|
doctor or authoring instructions with current-state checks owned by runtime
|
|
99
101
|
startup, the client build, migration status and disposable rebuilds, the
|
|
@@ -83,6 +83,11 @@ installation, or validation fails, it restores the previous manifests,
|
|
|
83
83
|
lockfile, and installed tree before reporting the failure. Resolve the reported
|
|
84
84
|
registry or real peer problem and rerun `npm run jskit:update`.
|
|
85
85
|
|
|
86
|
+
The updater then writes the catalog's JSKIT block in `AGENTS.md`, as
|
|
87
|
+
`npx jskit agents` does ([Agent instructions](/guide/framework/typed-features#agent-instructions)):
|
|
88
|
+
commit it with the manifests. Delete any JSKIT guidance the app copied into
|
|
89
|
+
`AGENTS.md` from a foundation or starter, which the block now carries.
|
|
90
|
+
|
|
86
91
|
When the install brings package migrations the application has not had, the
|
|
87
92
|
updater lists each one (`<package>: <file>`) and says to run
|
|
88
93
|
`npm run db:migrate`. Run it, on every database the application uses, before
|
|
@@ -288,9 +293,14 @@ application:
|
|
|
288
293
|
5. Proves it with a timed full run: `npm test` and the whole Playwright suite,
|
|
289
294
|
every test passing, the time of each before and after recorded, and the
|
|
290
295
|
slowest tests the run lists read. Where the host provides a managed browser
|
|
291
|
-
runner, every Playwright suite runs through it from the
|
|
292
|
-
|
|
293
|
-
|
|
296
|
+
runner, such as Vibe64's, every Playwright suite runs through it from the
|
|
297
|
+
first run, on a declared test target: give the runner the package script (on
|
|
298
|
+
Vibe64, `vibe64-helper playwright --target test-app npm-run test:e2e`), and
|
|
299
|
+
never start `npx playwright test`, `playwright test` or `npm run test:e2e`
|
|
300
|
+
yourself. Specs that write run only on a test target with its own database,
|
|
301
|
+
never on the person's development target or database.
|
|
302
|
+
[Browser verification](/guide/framework/ui-operations#browser-verification)
|
|
303
|
+
shows the target. Elsewhere the suite is `npm run test:e2e`.
|
|
294
304
|
|
|
295
305
|
## Cache built assets for good
|
|
296
306
|
|
|
@@ -118,6 +118,15 @@ ids, environment, and configuration. Builds own client imports; migration
|
|
|
118
118
|
status and disposable rebuilds own schema state. App lint, tests, audit,
|
|
119
119
|
browser checks, and CI own security, runtimes, and behavior.
|
|
120
120
|
|
|
121
|
+
Keep verification output small: save each run's complete output to a local
|
|
122
|
+
file and keep its exit status, then report counts, duration, failed case names
|
|
123
|
+
and the file's path, and read only actionable failure excerpts. Never feed full
|
|
124
|
+
JSON or TAP reports, passing assertions, request logs or traces into an agent's
|
|
125
|
+
context, restart a run to recover its logs, or print unchanged output again;
|
|
126
|
+
wait on the running one. Keep startup and cleanup errors visible. Browser
|
|
127
|
+
evidence comes from automated cases, targeted locators and meaningful visual
|
|
128
|
+
checkpoints, never a DOM snapshot or screenshot after every action.
|
|
129
|
+
|
|
121
130
|
There is no supported `jskit doctor` command. Old CLI authoring-history
|
|
122
131
|
warnings do not describe AI-first apps. Diagnose current contracts; never add
|
|
123
132
|
metadata to satisfy an old tool.
|
|
@@ -549,6 +549,27 @@ row past that page.
|
|
|
549
549
|
const visible = computed(() => list.items.filter((service) => service.name.includes(search.value)));
|
|
550
550
|
```
|
|
551
551
|
|
|
552
|
+
### Screen read failures
|
|
553
|
+
|
|
554
|
+
**A list's, record's or form's read (`useList`, `useView`, `useAddEdit` and
|
|
555
|
+
the CRUD composables built on them) shows its failure on its own screen as
|
|
556
|
+
`loadError`, so shell-web's request recovery banner leaves it out. Only a read
|
|
557
|
+
whose screen shows no `loadError`, such as a lookup's options, asks for the
|
|
558
|
+
banner with `requestRecovery: true`, and only that read names it with
|
|
559
|
+
`requestRecoveryLabel`.**
|
|
560
|
+
|
|
561
|
+
Why: the banner would report the same failure a second time, and a label
|
|
562
|
+
without the banner names nothing: the call refuses it with a TypeError when
|
|
563
|
+
the screen loads, so lint names it first.
|
|
564
|
+
|
|
565
|
+
```js
|
|
566
|
+
// good: a lookup's options, whose failure no screen shows, ask for the banner
|
|
567
|
+
const sites = useList({ resource: sitesResource, requestRecovery: true, requestRecoveryLabel: "Sites" });
|
|
568
|
+
|
|
569
|
+
// bad: a CRUD screen shows loadError, and its label names nothing
|
|
570
|
+
const contacts = useCrudListScreen({ resource: contactsResource, requestRecoveryLabel: "Contacts" });
|
|
571
|
+
```
|
|
572
|
+
|
|
552
573
|
## Helpers and sizes
|
|
553
574
|
|
|
554
575
|
### One helper per package
|
|
@@ -618,6 +639,7 @@ client-only rules below. The server's action and error rules do not apply.
|
|
|
618
639
|
| `jskit/no-module-state` | a module-level `let`, `ref()` or `reactive()` | [Module state](#module-state) |
|
|
619
640
|
| `jskit/selection-field` | a `v-select`, `v-autocomplete` or `v-combobox` whose items are not fixed, and a `SelectField` whose items are not fixed that binds no `loading` | [Selection fields](#selection-fields) |
|
|
620
641
|
| `jskit/search-on-server` | a `computed()` that filters a list composable's items by a search ref; an autocomplete over a list's items or a lookup's options without `no-filter` or an `update:search` handler | [Search on the server](#search-on-the-server) |
|
|
642
|
+
| `jskit/request-recovery-label` | `requestRecoveryLabel` given to a screen read (`useList`, `useView`, `useAddEdit`, the CRUD composables) without `requestRecovery: true` | [Screen read failures](#screen-read-failures) |
|
|
621
643
|
| `vue/require-prop-types`, `vue/require-default-prop`, `vue/require-valid-default-prop`, `vue/no-required-prop-with-default` | a prop without a type, optional without a default, or both | [Collaborator props](#collaborator-props) |
|
|
622
644
|
| `vue/require-explicit-emits` | an emitted event the component does not declare | [Declared emits](#declared-emits) |
|
|
623
645
|
|
|
@@ -2,12 +2,12 @@
|
|
|
2
2
|
|
|
3
3
|
---
|
|
4
4
|
title: Speed pass
|
|
5
|
-
description: Where a JSKIT app's
|
|
5
|
+
description: Where a JSKIT app's screens and server spend their time, the JSKIT tools that measure each wait, and the fixes each one takes.
|
|
6
6
|
---
|
|
7
7
|
|
|
8
8
|
# Speed pass
|
|
9
9
|
|
|
10
|
-
A speed pass makes an app
|
|
10
|
+
A speed pass makes an app take the time its work needs.
|
|
11
11
|
Genesis's speed pass skill (`genesis-speed-pass`) holds the method: measure
|
|
12
12
|
each wait first on a realistic build at realistic sizes, fix its cause, measure
|
|
13
13
|
again the same way, and never raise a time limit, add retries, or shrink
|
|
@@ -18,97 +18,8 @@ are already in [Typed features](/guide/framework/typed-features),
|
|
|
18
18
|
[Data access](/guide/framework/data-access) and the
|
|
19
19
|
[sanity checks](/guide/framework/sanity-checks). Query counts, narrowing and
|
|
20
20
|
indexes belong to the [data pass](/guide/framework/data-pass): when a wait is
|
|
21
|
-
database time, apply that page to the path.
|
|
22
|
-
|
|
23
|
-
## Test speed
|
|
24
|
-
|
|
25
|
-
### Measure
|
|
26
|
-
|
|
27
|
-
- `jskit test` starts by saying how many test files it runs at a time and
|
|
28
|
-
where that number came from (`V64_TEST_CONCURRENCY`, or half of the
|
|
29
|
-
machine), and ends with its 10 slowest test files and tests; each file's time
|
|
30
|
-
is kept in `node_modules/.cache/jskit-test/file-times.json`. Time the whole
|
|
31
|
-
command too (`time npm test`): a wall time close to the sum of the files'
|
|
32
|
-
times means they ran one after another
|
|
33
|
-
([Test files run in parallel](/guide/framework/typed-features#test-files-run-in-parallel)).
|
|
34
|
-
- Test database preparation reports each phase and its duration
|
|
35
|
-
([Test databases are prepared once](/guide/framework/typed-features#test-databases-are-prepared-once)).
|
|
36
|
-
Read them: slow preparation otherwise hides inside the first test that waits
|
|
37
|
-
for it.
|
|
38
|
-
- Every Playwright run through `browserTestConfig()` ends with its 10 slowest
|
|
39
|
-
tests. Compare a slow spec's time with the time of the app's requests it
|
|
40
|
-
makes, so you know whether the test or the app is slow.
|
|
41
|
-
- Take the baseline from one whole run of each part (the database tests, the
|
|
42
|
-
browser tests), its files in parallel at the real `V64_TEST_CONCURRENCY`:
|
|
43
|
-
its per-file times are the baseline table. After a batch of fixes, run the
|
|
44
|
-
part again for the times after, and compare per file and in total. A
|
|
45
|
-
single-file run (`npm test -- <file>`) is for one change's red and green,
|
|
46
|
-
never the way to take a baseline or a before-and-after table, and never one
|
|
47
|
-
of serial runs queued one after another. Run where the project's test
|
|
48
|
-
machine runs (inside Vibe64, `vibe64-helper check`), not on a shared
|
|
49
|
-
development host; a time taken while other work loads the machine is
|
|
50
|
-
reported as such and never used as a baseline.
|
|
51
|
-
|
|
52
|
-
### Fix
|
|
53
|
-
|
|
54
|
-
- Scripts run `jskit test` (`jskit test --databases` for database tests), and
|
|
55
|
-
Playwright and Vitest take their workers from `testConcurrency()`. `jskit
|
|
56
|
-
check` reports a script that runs `node --test` directly, passes a fixed
|
|
57
|
-
concurrency or pins `V64_TEST_CONCURRENCY`, and a Playwright or Vitest config
|
|
58
|
-
that runs files one at a time ([test-run rules](/guide/framework/typed-features#test-run-rules)).
|
|
59
|
-
- Files that collide are isolated, never run one at a time: a port from
|
|
60
|
-
`listen(0)`, a directory from `mkdtemp`, the database `jskit test --databases`
|
|
61
|
-
gives each file, a scratch database from
|
|
62
|
-
`createPackageTestKnex(t, { environment: process.env })` for a test that
|
|
63
|
-
needs an empty one (or several), another copy of the snapshot, rows
|
|
64
|
-
included, from `claimTestDatabaseCopy(t, { environment: process.env })` for
|
|
65
|
-
a test that needs a second one, and a Vite `cacheDir` of its own. On MySQL
|
|
66
|
-
and MariaDB, `resetTestDatabase({ environment: process.env })` gives a test
|
|
67
|
-
its file's copy afresh mid-file, replacing only the tables written since;
|
|
68
|
-
never build global-setup slots of your own. The
|
|
69
|
-
`// jskit-test: alone - <reason>` marker is only for a file that holds a
|
|
70
|
-
resource of the whole machine.
|
|
71
|
-
- A `jskit test --databases` run whose databases let fewer files run at once
|
|
72
|
-
than the budget (no `TEST_DB_NAME`, or copies the database user may not
|
|
73
|
-
create) says why at its start and end and fails: give the user its copies
|
|
74
|
-
([Integration test databases](/guide/app-setup/database-layer#integration-test-databases)).
|
|
75
|
-
- `jskit test --databases` restores each file's database from a snapshot
|
|
76
|
-
rebuilt only when the migrations' digest changes. A file that runs
|
|
77
|
-
`knex.migrate.latest()` itself replays the whole history for every file:
|
|
78
|
-
remove it, and let the full history run once in its own check,
|
|
79
|
-
`jskit migration-history`.
|
|
80
|
-
- A fixture every file only reads (a built app, a composed project, a
|
|
81
|
-
generated tree) is made once, before any file starts, by a global setup
|
|
82
|
-
module: `jskit test --test-global-setup=tests/helpers/globalSetup.js`
|
|
83
|
-
(`jskit test` passes its arguments to `node --test`). Its `globalSetup()`
|
|
84
|
-
makes the fixture and puts its location in an environment variable the test
|
|
85
|
-
processes inherit; its `globalTeardown()` removes it. A file run on its own
|
|
86
|
-
makes the fixture itself when the variable is absent, and a test that writes
|
|
87
|
-
into the fixture makes its own copy.
|
|
88
|
-
- `browserTestConfig()` builds the production frontend once and gives each
|
|
89
|
-
worker its own server, port and seeded database; with a `signIn` module
|
|
90
|
-
each worker signs in once. A check of what a component shows belongs in a
|
|
91
|
-
Vitest component test, and a new browser check is an assertion in the spec
|
|
92
|
-
that already reaches that screen.
|
|
93
|
-
- Wait for the condition, never for time: Playwright's web-first assertions
|
|
94
|
-
(`await expect(locator).toBeVisible()`, `await expect(page).toHaveURL(...)`)
|
|
95
|
-
instead of `page.waitForTimeout()`. The app's own delays (retry backoff,
|
|
96
|
-
debounce, polling) run on a fake clock: `mock.timers` in `node:test`,
|
|
97
|
-
`vi.useFakeTimers()` in Vitest and `page.clock` in Playwright.
|
|
98
|
-
- A file imports what it needs at its top level, so loading counts against the
|
|
99
|
-
file, not against a test's time limit. `jskit test` keeps Node's compile
|
|
100
|
-
cache in `node_modules/.cache/jskit-node-compile-cache`, so each file's
|
|
101
|
-
process loads the modules the files before it compiled.
|
|
102
|
-
- The bounds stay: `jskit test`'s 10 minutes a file and 45 a run,
|
|
103
|
-
`browserTestConfig()`'s `actionTimeout` (15 s), `navigationTimeout` (30 s)
|
|
104
|
-
and `globalTimeout`. A bound in `test-time-bounds.json` rises only with a
|
|
105
|
-
measurement of the work's real need; a file that got slow is fixed instead.
|
|
106
|
-
|
|
107
|
-
### Prove
|
|
108
|
-
|
|
109
|
-
Run the whole suite before and after on the project's test machine with the
|
|
110
|
-
same `V64_TEST_CONCURRENCY`, and report the wall time, each preparation phase, the
|
|
111
|
-
slowest files and the test counts, which stay the same.
|
|
21
|
+
database time, apply that page to the path. The test suite's time belongs to
|
|
22
|
+
the [test pass](/guide/framework/test-pass).
|
|
112
23
|
|
|
113
24
|
## Client speed
|
|
114
25
|
|
|
@@ -213,4 +124,5 @@ Report each main route's time before and after, with its statement count, at
|
|
|
213
124
|
the realistic size, the first after boot and later ones. Keep an
|
|
214
125
|
`expectFlatQueries()` test for each path whose count you changed.
|
|
215
126
|
|
|
216
|
-
Then run `npx jskit check
|
|
127
|
+
Then run `npx jskit check`. `npm run verify`, the whole run, runs once, at the
|
|
128
|
+
end, only with the person's OK.
|
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
<!-- Generated by `npm run agent-docs:build` from `packages/agent-docs/site/guide/framework/test-pass.md`. Do not edit manually. -->
|
|
2
|
+
|
|
3
|
+
---
|
|
4
|
+
title: Test pass
|
|
5
|
+
description: The command, file or check that proves each item of a test pass in a JSKIT app, from its test rules and its runs to its databases, its browser tests and what a JSKIT update breaks.
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
# Test pass
|
|
9
|
+
|
|
10
|
+
A test pass makes the test suite prove what the app does, quickly. Genesis's
|
|
11
|
+
test pass skill (`genesis-test-pass`) holds the method: each behavior's test
|
|
12
|
+
fails without it, each file owns what it uses and reaches no outside service,
|
|
13
|
+
preparation happens once per run and files run in parallel, every run names
|
|
14
|
+
every failure, and the guidance says exactly how the suite runs. This page is
|
|
15
|
+
JSKIT's half: for each item, the command, file or check that proves it in a
|
|
16
|
+
JSKIT app. Work through it top to bottom and tick an item only with its proof.
|
|
17
|
+
The rules it applies are in [Typed features](/guide/framework/typed-features),
|
|
18
|
+
[Database layer](/guide/app-setup/database-layer) and
|
|
19
|
+
[UI operations](/guide/framework/ui-operations); query counts belong to the
|
|
20
|
+
[data pass](/guide/framework/data-pass).
|
|
21
|
+
|
|
22
|
+
## Run the checks first
|
|
23
|
+
|
|
24
|
+
- `npx jskit check` reads the test scripts, test files, Playwright and Vitest
|
|
25
|
+
configs, CI workflows and the root Vite config, and names what makes a run
|
|
26
|
+
slow, fragile or unsafe, each finding with the change to make
|
|
27
|
+
([Test-run rules](/guide/framework/typed-features#test-run-rules)). Its
|
|
28
|
+
findings are the pass's first items, and every one passes at its end.
|
|
29
|
+
- `npm run lint` passes too.
|
|
30
|
+
|
|
31
|
+
## Map and measure the suite
|
|
32
|
+
|
|
33
|
+
- The parts of a JSKIT app's suite, each one command: the Node tests
|
|
34
|
+
(`npm test`, which is `jskit test --databases` once the app has a database),
|
|
35
|
+
the client tests (`npm run test:client`, Vitest), the browser tests
|
|
36
|
+
(`npm run test:e2e`, Playwright through `browserTestConfig()`) and the
|
|
37
|
+
migration history (`jskit migration-history`). `npm run verify` runs them
|
|
38
|
+
after `jskit check` and lint, as
|
|
39
|
+
[Running the checks](/guide/framework/typed-features#running-the-checks)
|
|
40
|
+
states once.
|
|
41
|
+
- `jskit test --list` prints the files a run takes and their total, and runs
|
|
42
|
+
nothing: the total matches the test files under `tests/`, or a file is named
|
|
43
|
+
so that node's default pattern leaves it out.
|
|
44
|
+
- `jskit test` starts by saying how many files it runs at a time and where that
|
|
45
|
+
number came from (the host's `V64_TEST_CONCURRENCY`, else half the CPUs), and
|
|
46
|
+
ends with its 10 slowest files and tests; each file's time is kept in
|
|
47
|
+
`node_modules/.cache/jskit-test/file-times.json`. A run through
|
|
48
|
+
`browserTestConfig()` ends with its 10 slowest tests, and test database
|
|
49
|
+
preparation reports each phase and its duration.
|
|
50
|
+
- Take the baseline from one whole run of each part, its files in parallel at
|
|
51
|
+
the real `V64_TEST_CONCURRENCY`: its per-file times are the baseline table.
|
|
52
|
+
After a batch of fixes, run the part again for the times after, and compare
|
|
53
|
+
per file and in total. A wall time near the sum of the files' times divided by
|
|
54
|
+
the budget is right; near the plain sum, the files ran one after another. A
|
|
55
|
+
single-file run (`npm test -- <file>`) is for one change's red and green,
|
|
56
|
+
never the way to take a baseline or a before-and-after table, and never one
|
|
57
|
+
of serial runs queued one after another. Run on the host's test machine, when the host offers one, not on a
|
|
58
|
+
shared development host; a time taken while other work loads the machine is
|
|
59
|
+
reported as such and never used as a baseline.
|
|
60
|
+
- The pass's own measurement, one run of each part before the work and one
|
|
61
|
+
after, is part of the pass the person asked for. `npm run verify`, the whole
|
|
62
|
+
run, runs once, at the end, only with the person's OK.
|
|
63
|
+
|
|
64
|
+
## Each test proves a behavior
|
|
65
|
+
|
|
66
|
+
- Break the behavior and see its test fail: revert the line or return the
|
|
67
|
+
wrong value, several at once in one run (`npm test -- <files>` runs exactly
|
|
68
|
+
those files), then restore it. A behavior no test catches gets one, seen to fail first.
|
|
69
|
+
- Nothing is weakened: no `test.skip`, `test.only`, `{ skip: true }`,
|
|
70
|
+
`test.fixme`, `retries` or raised `timeout` in a test or config without its
|
|
71
|
+
stated reason and the run that covers the skipped behavior.
|
|
72
|
+
- A rule or calculation is a Node unit test; data, access and refusals a server
|
|
73
|
+
test over `app.inject` on the file's own database
|
|
74
|
+
([Tests](/guide/framework/data-access#tests)); what a component shows a
|
|
75
|
+
Vitest component test; a browser test only for a flow across screens,
|
|
76
|
+
navigation, layout at the standard widths, focus or the real sign-in. A new
|
|
77
|
+
browser check is an assertion in the spec that already reaches the screen.
|
|
78
|
+
- A browser test finds what a person finds: `getByRole`, `getByLabel` and
|
|
79
|
+
`getByText` with the app's own words, never a Vuetify class (`.v-btn`,
|
|
80
|
+
`.v-list-item`), a generated class or text Vuetify supplies.
|
|
81
|
+
- A list, batch or write path has a count test at a few rows and at a
|
|
82
|
+
realistic number: `expectFlatQueries()`
|
|
83
|
+
([data pass](/guide/framework/data-pass)). A count that grows with the rows
|
|
84
|
+
is a product defect, fixed as the data pass says.
|
|
85
|
+
|
|
86
|
+
## Each file owns what it uses
|
|
87
|
+
|
|
88
|
+
- `jskit test --databases` gives each file running at once its own copy of
|
|
89
|
+
`TEST_DB_NAME`, restored from the snapshot, and fails a run whose databases
|
|
90
|
+
allow fewer files than the budget
|
|
91
|
+
([Integration test databases](/guide/app-setup/database-layer#integration-test-databases)).
|
|
92
|
+
A test that needs more takes it from JSKIT: an empty scratch database from
|
|
93
|
+
`createPackageTestKnex(t, { environment: process.env })`, a second copy of
|
|
94
|
+
the snapshot from `claimTestDatabaseCopy(t, { environment: process.env })`,
|
|
95
|
+
and its own copy afresh mid-file from
|
|
96
|
+
`resetTestDatabase({ environment: process.env })`. A port comes from
|
|
97
|
+
`listen(0)`, a directory from `mkdtemp`, a Vite `cacheDir` of its own.
|
|
98
|
+
- No name is written into a test, script, config or CI workflow:
|
|
99
|
+
`jskit check` names a fixed database name and a CI `TEST_DB_NAME` equal to
|
|
100
|
+
`DB_NAME`, and JSKIT refuses to run tests on `DB_NAME` at all.
|
|
101
|
+
- Under `jskit test`, the test processes and the app servers the browser tests
|
|
102
|
+
start reach only loopback, unix sockets and the configured database hosts;
|
|
103
|
+
any other connection fails with `JSKIT_TEST_NETWORK_REFUSED`, naming the host
|
|
104
|
+
and the fix. That is the run with outbound network refused, on every run: a
|
|
105
|
+
test that fails with it reached an outside service, so stub what it reached
|
|
106
|
+
at the seam the app already uses. A file that must reach one says why on its
|
|
107
|
+
first line, `// jskit-test: network - <reason>`, and runs without the guard.
|
|
108
|
+
- Every process `jskit test` starts runs as `APP_ENV=test`
|
|
109
|
+
([Environments](/guide/framework/environments)): only production sends for
|
|
110
|
+
real.
|
|
111
|
+
- A file that holds a resource of the whole machine says so on its first line,
|
|
112
|
+
`// jskit-test: alone - <reason>`, and runs after the others; no other file
|
|
113
|
+
does.
|
|
114
|
+
|
|
115
|
+
## Each run takes the time its work needs
|
|
116
|
+
|
|
117
|
+
- Databases come from a snapshot taken once per change of the migrations'
|
|
118
|
+
digest and kept on the database server, where `npm ci` cannot empty it: on
|
|
119
|
+
MySQL and MariaDB the database `<TEST_DB_NAME>_0`, whose tables each copy's
|
|
120
|
+
are made from, and a restore replaces only the tables a file changed; on
|
|
121
|
+
PostgreSQL the database `<TEST_DB_NAME>_snapshot`, which each copy is created
|
|
122
|
+
from ([Test databases are prepared once](/guide/framework/typed-features#test-databases-are-prepared-once)).
|
|
123
|
+
A file that runs `knex.migrate.latest()` itself replays the whole history:
|
|
124
|
+
remove it.
|
|
125
|
+
- `jskit migration-history` is the one check that replays the full history,
|
|
126
|
+
from empty, as `APP_ENV=test`, and compares it with the snapshot. Rows a
|
|
127
|
+
migration fills from the clock match: on MySQL and MariaDB both builds run
|
|
128
|
+
with the clock stopped (`SET TIMESTAMP` and JavaScript's `Date`), and on
|
|
129
|
+
PostgreSQL a value taken from the clock compares as the clock's. A seed
|
|
130
|
+
stamped from a random value fails it; a migration that has run is never
|
|
131
|
+
edited to fix it, a new one corrects the rows.
|
|
132
|
+
- A fixture every file only reads is made once, before any file starts:
|
|
133
|
+
`jskit test --test-global-setup=tests/helpers/globalSetup.js`. Its
|
|
134
|
+
`globalSetup()` puts the fixture's location in an environment variable the
|
|
135
|
+
files inherit; a file run on its own makes the fixture itself, and a test
|
|
136
|
+
that writes into it makes its own copy.
|
|
137
|
+
- `browserTestConfig()` builds the production frontend once and reuses it
|
|
138
|
+
while its inputs are unchanged, and gives each of `browserTestWorkers()`
|
|
139
|
+
workers (half the budget, at least one) its own server, port and seeded copy
|
|
140
|
+
of `BROWSER_TEST_DB_NAME`; with a `signIn` module each worker signs in once.
|
|
141
|
+
A build that writes into its own inputs is never reused (`not kept for
|
|
142
|
+
reuse, as src changed while it ran`): vue-router's generated types go to
|
|
143
|
+
`types/typed-router.d.ts`, outside `src`.
|
|
144
|
+
- No fixed sleep: a web-first assertion (`await expect(locator).toBeVisible()`),
|
|
145
|
+
`expect.poll()`, the event itself, or a fake clock (`mock.timers`,
|
|
146
|
+
`vi.useFakeTimers()`, `page.clock`) for the app's own delays. The one fixed
|
|
147
|
+
wait that stays proves nothing happens in a window and says so on the line
|
|
148
|
+
before, `// jskit-test: fixed-wait - <reason>`.
|
|
149
|
+
- A file imports what it needs at its top level, so loading counts against the
|
|
150
|
+
file, not a test's time limit.
|
|
151
|
+
- The bounds stay: `jskit test`'s 10 minutes a file and 45 a run, and
|
|
152
|
+
`browserTestConfig()`'s `actionTimeout`, `navigationTimeout` and
|
|
153
|
+
`globalTimeout`. A bound in `test-time-bounds.json` rises only with a
|
|
154
|
+
measurement of the work's real need.
|
|
155
|
+
- A passing run prints what a person reads: test servers log at
|
|
156
|
+
`LOG_LEVEL=warn` unless the shell asks for more.
|
|
157
|
+
|
|
158
|
+
## Every run reports every failure
|
|
159
|
+
|
|
160
|
+
- Each part is one command that runs all its files in one parallel run:
|
|
161
|
+
`jskit check` names a script that runs `node --test` itself, a fixed
|
|
162
|
+
concurrency or worker count, and files or globs given to `jskit test`.
|
|
163
|
+
- `npm run verify` chains its parts with `&&`: it stops at the first part that
|
|
164
|
+
fails, exits non-zero and npm names that script. Prove it once without a
|
|
165
|
+
whole run: put a lint error in a file, see `npm run verify` stop at
|
|
166
|
+
`lint` with a non-zero exit, and remove it. CI runs the same parts and fails
|
|
167
|
+
on any of them.
|
|
168
|
+
- A failed, cancelled or timed-out test, and a file that fails to load, fail
|
|
169
|
+
`jskit test`; `jskit test --list` shows the files the run takes.
|
|
170
|
+
|
|
171
|
+
## The guidance says how the suite runs
|
|
172
|
+
|
|
173
|
+
- The app's `AGENTS.md` keeps only what is specific to the app, and links
|
|
174
|
+
these guides for the rest. `genesis/stack.md`'s Verification declares each
|
|
175
|
+
part of `npm run verify`, in the same order, the browser suite on the
|
|
176
|
+
production build included.
|
|
177
|
+
- A managed host runs the browser suite on its declared test target,
|
|
178
|
+
`jskit browser-test-server {host} {port} {workers}`, which names
|
|
179
|
+
`PLAYWRIGHT_PORT` so each worker opens its own server's database, never on
|
|
180
|
+
the development server
|
|
181
|
+
([Browser verification](/guide/framework/ui-operations#browser-verification)).
|
|
182
|
+
- No rotten instruction stays: a development server for checks, the whole suite
|
|
183
|
+
after each change, single files timed in turn, retrying or loosening a
|
|
184
|
+
failing test, fixed sleeps, shared database names or ports, a hard-coded
|
|
185
|
+
worker count, migrations replayed per test.
|
|
186
|
+
- The committed Agent Skill copies match the Genesis that serves the project:
|
|
187
|
+
`genesis check` passes, and `genesis skills sync` refreshes them.
|
|
188
|
+
|
|
189
|
+
## After a JSKIT update
|
|
190
|
+
|
|
191
|
+
Update with `npm run jskit:update`, then fix what the update reports, these
|
|
192
|
+
first:
|
|
193
|
+
|
|
194
|
+
- `jskit check`'s test rules report patterns earlier releases let pass: a
|
|
195
|
+
fixed sleep, a fixed database name, a CI test database equal to `DB_NAME`, a
|
|
196
|
+
generated file written into `src`, files given to `jskit test`. Each finding
|
|
197
|
+
names its change.
|
|
198
|
+
- The foundation patterns write vue-router's types to
|
|
199
|
+
`types/typed-router.d.ts`: move the file and its `.gitignore` line, and point
|
|
200
|
+
`dts` there.
|
|
201
|
+
- A test that reached an outside service now fails with
|
|
202
|
+
`JSKIT_TEST_NETWORK_REFUSED`: stub it, or give the file its
|
|
203
|
+
`// jskit-test: network - <reason>` line.
|
|
204
|
+
- Test servers log at `LOG_LEVEL=warn`: a test that reads info logs sets
|
|
205
|
+
`LOG_LEVEL` itself.
|
|
206
|
+
- On MySQL and MariaDB the test database snapshot moved from
|
|
207
|
+
`node_modules/.cache` to the database server: the first run takes a new one,
|
|
208
|
+
and the old cache folder can go.
|
|
209
|
+
- `jskit migration-history` runs as `APP_ENV=test` by itself: an `APP_ENV=test`
|
|
210
|
+
in front of it in a script can go.
|