docs(writing-specs): document setup export, flag noLogcatErrors as android-only

Mirrors pkg/spec/README.md so the manual covers the runner's setup-first
fall-through. Marks noLogcatErrors as Android-only so iOS/web spec
authors know it silently no-ops.
This commit is contained in:
pj committed 2026-05-15 16:59:37 +05:30
1 parent 2d6449be42
commit c0a2b0cd1e
1 file changed
+22 -1
+22 -1
View File
@@ -183,10 +183,12 @@ import { noUncaughtExceptions, noLogcatErrors } from "@sanderling/spec/defaults/
export const properties = {
noUncaughtExceptions, // fails if the app throws an uncaught exception
noLogcatErrors, // fails if logcat emits any error-level lines
noLogcatErrors, // android-only; reads logcat, no-ops on ios/web
};
```
`noLogcatErrors` reads from logcat and only applies on Android. Including it in a spec that targets iOS or web is harmless; it silently holds.
## Pattern: preconditions
sanderling has no setup phase. Preconditions are action generators with high weight that self-disable once the condition is satisfied.
@@ -221,6 +223,25 @@ export const actionsRoot = weighted(
Once `onLoginScreen.current` is false, `doLogin` returns `[]` and drops out of the eligible set automatically.
## Pattern: setup export
Preconditions that drive the app from a fresh state into the surface you actually want to fuzz (login, onboarding, permission grants, seed data) can be exported as `setup` instead of mixing into `actionsRoot`. The runner tries `setup` first; if it yields no action, it falls through to `actionsRoot`. State regressing back across the precondition (logout under fuzz) automatically re-engages setup.
```ts
const login = actions(() => {
if (loggedIn.current) return [];
const email = loginEmailField.current;
const submit = loginSubmit.current;
if (!email || !submit) return [];
return [InputText({ into: email, text: "[email protected]" }), Tap({ on: submit })];
});
export const setup = login;
export const actionsRoot = weighted([60, browse], [40, edit]);
```
`setup` is just an `ActionGenerator`; compose with `actions`, `weighted`, or `whenRoute` exactly like the main pool. Works identically across Android, iOS, and web.
## Pattern: conditional properties
Gate a property so it only applies when a precondition holds: