xstate
xstate copied to clipboard
Bug: @xstate/test pathGenerator is not a function
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
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
Can you try this with @xstate/test@beta?
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)
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
using getShortestPaths the problem no longer appears