Repository navigation
@xstate/test@2.0.0-beta.5
Pre-releaseMinor Changes
-
d3da571: Coverage now reports which branch of a function transition ran. The new
transitionTargetsdimension records each transition with the target state nodes it resolved to, so a function transition that returns different targets gets one id per branch:const { coverage } = await testPaths(checkoutMachine, { fromEvents }); coverage.transitionTargets.covered; // ['["transitionTarget","checkout.review","PLACE_ORDER",0,["checkout.confirmed"]]', ...] assertTestCoverage(coverage, { transitionTargets: 1 });
Static transitions are declared up front with their config targets. Function transition branches appear once a run takes them.
State nodes and transitions that are reachable only through function transitions are no longer reported as
unknownafter a run visits them. A visited state node, the state nodes reachable from it through config targets, and the transitions out of them are reported asuncovereduntil a run covers them.Static reachability now treats the ancestors of a nested transition target as active, so their transitions are no longer reported as
unreachableorunknown. State nodes that astartsnapshot activates, and state nodes a run passes through within one step, also count as visited for reachability.
Patch Changes
-
b26ff57: Add
unknown: 'fail'to coverage assertions and coverage-based stop conditions. A gated dimension with unknown entries cannot pass.assertTestCoverage(coverage, { transitions: 1, stateNodes: 1, unknown: 'fail' });
Use
strictReplay: truewithfromEventsto reject unhandled events before the system under test starts. SupplystrictReplay.allowUnhandledfor intentional no-ops.Use
assertTestCoverage(coverage, { sutComparisons: 1 })to require at least one observation comparison. Playwright sessions release listeners and tracing when reset fails. -
001502b:
testPaths()from@xstate/test/pathsnow acceptsfailures: trueandfailures: { dir, replay, key }, the same astestPaths()from@xstate/test. Before, those values threwfailureStore.load is not a function.import { testPaths } from '@xstate/test/paths'; await testPaths(machine, { events, sut, failures: true });
-
71b6b6d:
testPaths()failure replay fixes:- A path that diverges from its planned states is no longer saved by
failures, and its error has nofixture. Replaying a fixture does not compare the run with the planned path, so a saved divergence replayed as a pass and was deleted as fixed. - With
failures: { replay: 'only', key }, saved failures replay even when path planning fails, for example when traversal exceedslimit. Without an explicitkey, a planning failure still throws, because the default key depends on the planned paths.
- A path that diverges from its planned states is no longer saved by