Skip to content

Typings for xstate that support stately.ai json scheme

Notifications You must be signed in to change notification settings

cdek-it/xstate-json-types

Repository files navigation

@cdek/xstate-json-types

Types for xstate stately.ai json files

Usage

  1. Export your machine from stately.ai as json file

  2. Save it as typescript file

export default {
  // ...
} as const // make sure add this for properly typings
  1. Declare your machine as test model
const model = declareTestModel(toggleMachine, {
  // your events that change state
  events: {
    "SET OFF": async () => {
      toggle.set(false)
    },
    "SET ON": async () => {
      toggle.set(true)
    },
  },

  // your asserts that check state
  expectations: {
    OFF: async () => {
      expect(toggle.value).toBe(false)
    },
    ON: async () => {
      expect(toggle.value).toBe(true)
    },
  }
})
  1. Describe tests with preferred runner
describeWithJest(model) // only jest template for now

Examples

Look into tests folder

About

Typings for xstate that support stately.ai json scheme

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published