Skip to content

test(repo): move xstate's test files runtimeValidation to waitFor onto the guard API - #56

Closed
systemfsoftware-maker wants to merge 5 commits into
xs/guard-xstate-core-bfrom
xs/guard-xstate-core-c
Closed

systemfsoftware-maker wants to merge 5 commits into
xs/guard-xstate-core-bfrom
xs/guard-xstate-core-c

Conversation

@systemfsoftware-maker

@systemfsoftware-maker systemfsoftware-maker commented Oct 8, 2026 •

Copy link
Copy Markdown
Collaborator

Moves 34 test files under packages/xstate/test, runtimeValidation.test.ts through waitFor.test.ts, onto the @systemfsoftware/vitest guard API (generator bodies, yielded expect). The layer removes exactly those 34 entries from packages/unguarded-tests.json. No file under src changes. systemTransition.test.ts and v5ConfigDiagnostics.test.ts stay on the list (see Held).

Stacked on #55.

Shape

  • Checks on one state merge into one check over that state; no artificial yields.
  • Refused matchers strengthened (count across the 34 files, base → head): toHaveBeenCalled* 77 → 0, toBeDefined 35 → 0, toHaveLength 21 → 0, not.toThrow 12 → 0, toBeTruthy 10 → 0, toMatchInlineSnapshot 9 → 0, .resolves/.rejects 7 → 0, toBeFalsy 4 → 0, toBeInstanceOf 2 → 0. Inline snapshots became literals from their committed values. Call-count matchers became exact recorded call lists.
  • No vi (111 → 0). vi.fn became per-test recorder arrays, and fake timers became the injected clock.
  • Type assertions stay at the call site: 405 @ts-expect-error directives on both sides, each on the expression it guards.
  • Two it.todo cases became real tests.
    • toPromise.test.ts › "should immediately reject for an actor that had an error": an actor whose entry action throws has status error, and toPromise rejects with that same error (Error: oh noes).
    • transition.test.ts › "delayed raise actions should be returned": initialTransition returns the delayed raise as its first action. Main's todo expected params: [{ type: 'NEXT' }, { delay: 10 }], a shape this fork's raise action does not have. The test asserts the fork's fields, event: { type: 'NEXT' } and delay: 10.

Parity

Case names and statuses from vitest JSON runs, against main's baseline. Columns: base cases, head cases, missing, added, changed status.

File Base Head Missing Added Changed
test/runtimeValidation.test.ts 26 26 0 0 0
test/runtimeValidation.types.test.ts 6 6 0 0 0
test/select.test.ts 6 6 0 0 0
test/serialization.conformance.v6.test.ts 10 10 0 0 0
test/setup.test.ts 6 6 0 0 0
test/setupStateContracts.test.ts 27 27 0 0 0
test/sourceTyping.types.test.ts 12 12 0 0 0
test/spawn.test.ts 1 1 0 0 0
test/spawn.types.test.ts 4 4 0 0 0
test/spawnChild.test.ts 6 6 0 0 0
test/state.test.ts 25 25 0 0 0
test/stateIn.test.ts 9 9 0 0 0
test/stateInput.persistence.test.ts 3 3 0 0 0
test/stateInput.test.ts 49 49 0 0 0
test/strictTargets.types.test.ts 15 15 0 0 0
test/system.test.ts 26 26 0 0 0
test/systemOnRejectedEvent.test.ts 5 5 0 0 0
test/tags.test.ts 6 6 0 0 0
test/timeout.test.ts 20 20 0 0 0
test/timers.persistence.test.ts 10 10 0 0 0
test/toPromise.test.ts 6 6 0 0 1
test/transient.test.ts 24 24 0 0 0
test/transition.test.ts 108 108 0 0 1
test/transitionFunctions.test.ts 4 4 0 0 0
test/trigger.test.ts 4 4 0 0 0
test/typeHelpers.test.ts 11 11 0 0 0
test/types.test.ts 250 250 0 0 0
test/typeSchemas.test.ts 11 11 0 0 0
test/typeStates.test.ts 1 1 0 0 0
test/unhandledEvents.test.ts 6 6 0 0 0
test/v6.test.ts 4 4 0 0 0
test/versioning.test.ts 9 9 0 0 0
test/vizTypeFriction.types.test.ts 2 2 0 0 0
test/waitFor.test.ts 16 16 0 0 0
Total 728 728 0 0 2

The two changed rows are the todo → passed cases above. Main already has one duplicate full name in types.test.ts ("events should not allow a transition using an event type matching the possible prefix..."), so both sides run 729 cases under 728 distinct names.

Evidence

  • Oracles. Expected values are the base's literals or committed inline snapshots, or derived by hand from each case's inputs and the src it exercises; none is read off a run.
  • Sabotage (scratch worktree on this head): src/toPromise.ts:33 resolves undefined instead of the actor's output, giving 4 failed in toPromise.test.ts. Restored: git diff --quiet exit 0.
  • The whole packages/xstate json run (2442 passed, 29 skipped, 0 failed), seeds 1-3 on the 34 files (--sequence.seed), tsc -b, turbo lint:tsgo (--force) and dprint check: all exit 0.

Held

  • systemTransition.test.ts › "does not consult wall time, native timers or live actor instances" makes Date.now and setTimeout throw for the duration of a pure system transition, to prove the transition reads neither. Both are global patches that the file's concurrently running cases would observe, and the pure functions take no clock to inject. The file stays unguarded until that observation has a form that patches no global.
  • v5ConfigDiagnostics.test.ts captures construction-time warnings by replacing console.warn (the StateNode diagnostics have no actor and no sink), and its "reports nothing in production builds" case stubs NODE_ENV and module-mocks #is-development. Both stay until those diagnostics have a sink and the production branch can be reached without a module mock.

Remaining

13 files on packages/unguarded-tests.json: xstate 3 (inspect, systemTransition, v5ConfigDiagnostics), xstate-react 8, xstate-store-react 2.

No local mutation runs.

…o the guard API

Thirty-four test files under packages/xstate/test register through @systemfsoftware/vitest with generator bodies and yielded expects, and leave packages/unguarded-tests.json. Every case name and status matches main except two it.todo cases in toPromise and transition, which are now real passing tests. systemTransition and v5ConfigDiagnostics stay on the list
@systemfsoftware-maker
systemfsoftware-maker added this pull request to stack #49 October 8, 2026 01:41
@systemfsoftware-maker systemfsoftware-maker changed the title xs/guard xstate core c test(repo): move xstate's test files runtimeValidation to waitFor onto the guard API Oct 8, 2026
@systemfsoftware-maker
systemfsoftware-maker marked this pull request as ready for review October 8, 2026 01:41
@systemfsoftware-maker
systemfsoftware-maker removed this pull request from stack #49 October 8, 2026 02:07
@systemfsoftware-maker
systemfsoftware-maker added this pull request to stack #59 October 8, 2026 02:07
@kiro-systemf

kiro-systemf Bot commented Oct 8, 2026

Copy link
Copy Markdown
Contributor

Closed unmerged: these layers preserve upstream's example suite case-for-case, which violates CONST-T10 (call-graph asserts) and CONST-T14/T15. Replaced by per-capability contract tests with named mutation sets (conductor cycle 98).

@kiro-systemf kiro-systemf Bot closed this Oct 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant