Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug: @xstate/test pathGenerator is not a function #4214

Open
Osky772 opened this issue Aug 29, 2023 · 5 comments
Open

Bug: @xstate/test pathGenerator is not a function #4214

Osky772 opened this issue Aug 29, 2023 · 5 comments
Assignees
Labels

Comments

@Osky772
Copy link

Osky772 commented Aug 29, 2023

Description

.getPaths() doesn't work.
https://stately.ai/docs/xstate/model-based-testing/quickstart

My package.json dependencies

"dependencies": {
    "@xstate/test": "^1.0.0-alpha.0",
    "xstate": "^4.38.2"
  },
  "devDependencies": {
    "@babel/core": "7.2.0",
    "parcel-bundler": "^1.6.1"
  }

script.js

import { createTestModel, createTestMachine } from "@xstate/test";

const machine = createTestMachine({
  id: "HUD",
  predictableActionArguments: true,

  initial: "one",

  states: {
    one: {
      on: {
        TWO: "two",
        THREE: "three"
      }
    },

    two: {
      on: {
        ONE: "one",
        THREE: "three"
      }
    },

    three: {
      on: {
        ONE: "one",
        TWO: "two"
      }
    }
  }
});

const model = createTestModel(machine);


console.log(".getPaths()");
console.log(model.getPaths().map((p) => p.description));

Expected result

.getPaths to work

Actual result

It does not work

Reproduction

https://github.com/Osky772/xstate-test-bug

Additional context

No response

@Osky772 Osky772 added the bug label Aug 29, 2023
@Osky772
Copy link
Author

Osky772 commented Aug 29, 2023

It doesn't work for any @Alpha version of @xstate/test. But somehow in Codesandbox it works https://codesandbox.io/s/xstate-test-path-filtering-forked-fnmqtw?file=/src/index.js

@davidkpiano
Copy link
Member

Can you try this with @xstate/test@beta?

@gnuyent
Copy link

gnuyent commented Sep 27, 2023

Hi @davidkpiano, we are running into the same issue on @xstate/[email protected]. Also, using the same example repo from above, we see the following TS errors (rename index.js to index.ts):

Type '{ on: { TWO: string; THREE: string; }; }' is missing the following properties from type 'TestStateNodeConfig<MachineContext, AnyEventObject>': type, history, onDone, entry, and 7 more.ts(2740)

@Osky772
Copy link
Author

Osky772 commented Sep 28, 2023

I've discovered a bug in the documentation. You should use getShortestPaths and not getPaths. I've read in the Changelog that getPath is an alias of the getShortestPaths so it works the same

@Osky772
Copy link
Author

Osky772 commented Sep 28, 2023

using getShortestPaths the problem no longer appears

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants