xstate icon indicating copy to clipboard operation
xstate copied to clipboard

[@xstate/graph][@xstate/test] Add support for `initialState`; add `testModel.getShortestPathsFrom()`

Open davidkpiano opened this issue 3 years ago • 5 comments

This PR adds support for generating paths from a specific initialState rather than the machine's default initial state.

The use-case for this is for custom path generation, where a dev might want to join paths. For example, if trying to generate a behavioral (given-when-then) test, they would want to:

  • Generate path(s) to the given state
  • Generate paths starting at the given state and then from the event(s) (the when part)
  • Join the first and second set of paths

Another use-case is for E2E test flows where a predefined initial state is not needed; e.g. navigating directly to some page instead of the home page, and running the test model from there.

See here for more info: https://discord.com/channels/795785288994652170/799416911259369472/989132676986437673

davidkpiano avatar Jul 05 '22 22:07 davidkpiano

⚠️ No Changeset found

Latest commit: 06459c31dd38baa69c25a28cee7f1f8b1c6490f1

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

changeset-bot[bot] avatar Jul 05 '22 22:07 changeset-bot[bot]

👇 Click on the image for a new way to code review
  • Make big changes easier — review code in small groups of related files

  • Know where to start — see the whole change at a glance

  • Take a code tour — explore the change with an interactive tour

  • Make comments and review — all fully sync’ed with github

    Try it now!

Review these changes using an interactive CodeSee Map

Legend

CodeSee Map Legend

ghost avatar Jul 05 '22 22:07 ghost

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit 06459c31dd38baa69c25a28cee7f1f8b1c6490f1:

Sandbox Source
XState Example Template Configuration
XState React Template Configuration

codesandbox-ci[bot] avatar Jul 05 '22 22:07 codesandbox-ci[bot]

@Andarist @farskid Ping on this review?

davidkpiano avatar Aug 17 '22 17:08 davidkpiano

@davidkpiano u have some unaddressed comments from the previous round of review

Andarist avatar Aug 17 '22 18:08 Andarist