Repository navigation
test(repo): move xstate's test files final to route onto the guard API - #55
Closed
systemfsoftware-maker wants to merge 10 commits into
Closed
systemfsoftware-maker wants to merge 10 commits into
systemfsoftware-maker wants to merge 10 commits into
Conversation
Fifty-four test files under packages/xstate/test, from final.test.ts to route.test.ts, register through @systemfsoftware/vitest with generator bodies and yielded expects, and leave packages/unguarded-tests.json. Every case name and status matches main. Mocks become per-test recorders or the actor's warn, reportUnhandledError and wallClock sinks final.test.ts keeps five console.warn spies on the construction-time final-state warning, and inspect.test.ts keeps its Web Crypto global stub; both wait on a ruling
… spy persistenceConformance.v6.test.ts used to wrap StateMachine.prototype.getPersistedSnapshot in a spy that checked every envelope against persistedSnapshot.schema.json. Its roundTrip helper now validates the JSON it produces with the same Ajv2020 validator, and each case asserts schemaErrors: null in its existing check. The four calls whose snapshots are not JSON (the non-JSON and circular rows, and the inline-actor case) stay unvalidated, as the spy skipped them on main
# Conflicts: # packages/unguarded-tests.json # packages/xstate/test/final.test.ts
inspect.test.ts's Web Crypto fallback case stubs globalThis.crypto and re-imports the package, a global patch that the file's concurrently running guarded cases would observe. The file goes back to its unguarded form and list entry until that case has a way to reach the fallback without patching a global
systemfsoftware-maker
added this pull request to stack #49
October 8, 2026 01:30
systemfsoftware-maker
marked this pull request as ready for review
October 8, 2026 01:33
systemfsoftware-maker
removed this pull request from stack #49
October 8, 2026 02:07
systemfsoftware-maker
changed the base branch from
xs/guard-xstate-core-a
to
xs/xstate-crypto-source
October 8, 2026 02:07
systemfsoftware-maker
added this pull request to stack #59
October 8, 2026 02:07
inspect.test.ts registers through @systemfsoftware/vitest and leaves packages/unguarded-tests.json. Its Web Crypto fallback case passes an unusable crypto source to createActor instead of stubbing globalThis.crypto and reloading the module, and every case name and status matches main
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). |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Moves 53 test files under
packages/xstate/test,final.test.tsthroughroute.test.ts, onto the@systemfsoftware/vitestguard API (generator bodies, yieldedexpect). The layer removes exactly those 53 entries frompackages/unguarded-tests.json. No file undersrcchanges.inspect.test.tsstays on the list (see Held).Stacked on #54. #52's per-actor final-state warning is what lets
final.test.tsdrop its console spies.Shape
toHaveBeenCalled*97 → 0,toHaveLength35 → 0,toBeTruthy35 → 0,toBeDefined34 → 0,not.toThrow21 → 0,toMatchInlineSnapshot11 → 0,toBeInstanceOf6 → 0,toBeFalsy4 → 0. Inline snapshots became literals from their committed values. Call-count matchers became exact recorded call lists.vi(122 → 0). Fake timers became the injectedclock.final.test.ts's five final-state warning cases passcreateActor(machine, { warn })a recorder and assert the exact list, including the runtime unhandled-event warning in the parallel-region case.persistenceConformance.v6.test.tsused to wrapStateMachine.prototype.getPersistedSnapshotin a spy that checked each envelope againstpersistedSnapshot.schema.json. ItsroundTriphelper now validates the JSON it produces with the same Ajv2020 validator, and 22 call sites assertschemaErrors: nullinside their existing check. The 4 calls whose snapshots are not JSON (the non-JSON and circular rows, and the inline-actor case) stay unvalidated, as the spy skipped them on main.@ts-ignoreininterpreter.test.tsbecame@ts-expect-error a string is not a sendable event(82 → 83 directives). Every other directive stays on the expression it guards.Parity
Case names and statuses from vitest JSON runs, against main's baseline. Columns: base cases, head cases, missing, added, changed status.
test/final.test.tstest/firstTenMinutes.v6.test.tstest/fsm-entrypoint.test.tstest/fsm.actor.test.tstest/fsm.differential.test.tstest/fsm.setup.test.tstest/fsm.test.tstest/fsm.types.test.tstest/guards.test.tstest/history.test.tstest/initial.test.tstest/input.test.tstest/inspection.conformance.v6.test.tstest/internalEvents.test.tstest/internalTransitions.test.tstest/interpreter.test.tstest/invalid.test.tstest/invoke.test.tstest/issue5454.test.tstest/issueRegressions.test.tstest/issueRegressions.types.test.tstest/json.test.tstest/listen.test.tstest/logger.test.tstest/logical-timers.test.tstest/machine.test.tstest/machineFromConfig.test.tstest/machineOutput.types.test.tstest/machineVersions.test.tstest/machineVersions.types.test.tstest/macrostepBound.test.tstest/mapState.test.tstest/match.test.tstest/memory.test.tstest/meta.test.tstest/microstep.test.tstest/microstep.v6.test.tstest/multiple.test.tstest/multiple.v6.test.tstest/order.test.tstest/parallel.test.tstest/parallelConformance.test.tstest/persistedSnapshot.types.test.tstest/persistenceConformance.v6.test.tstest/predictableExec.test.tstest/rehydration.test.tstest/rehydration.v6.test.tstest/resolve.test.tstest/resolve.v6.test.tstest/restored-effects.test.tstest/restoreEventless.test.tstest/restoreTerminal.test.tstest/route.test.tsEvidence
src/utils.ts:37matchesStatecompares with!==instead of===, giving 13 failed in 6 files (match5,interpreter4, and one each inpredictableExec,input,guards,firstTenMinutes.v6). Restored:git diff --quietexit 0.packages/xstatejson run, seeds 1-3 (--sequence.seed),tsc -b, turbolint:tsgoanddprint check: all exit 0.Held
inspect.test.ts› "falls back without failing when Web Crypto is unusable" stubsglobalThis.cryptowithvi.stubGlobal, resets modules and re-imports the package. That is a global patch, and the file's other cases run concurrently with it, so the file stays unguarded until the case can reach the fallback without patching a global.Remaining
47 files on
packages/unguarded-tests.json: xstate 37, xstate-react 8, xstate-store-react 2.No local mutation runs.