Open NullVoxPopuli opened 4 years ago
This is a planned addition (re: adding types for meta
), and I might make it so that @xstate/test
version 1.0 would look more like:
const testModel = createModel({
// ... test machine definition goes directly in here
states: {
loading: {
// test is a direct property of the state
async test() {
// assertion
}
}
}
})
@sukima's project here: https://github.com/sukima/qunit-xstate-test is great in that it eliminates testing boilerplate from the most comment way of testing using statecharts.
However, it's framework-agnostic (which is great!), but that means that the type definitions don't quite match for what we need in an Ember context (things like assigning the correct 'this', etc).
I've made the following changes here to support Ember w/ TypeScript:
Only 2 notable changes for
testShortestPaths
(originally here):TestCallbackFn
has a 'this' type, which matches our ember test type.this
bound to it.So what does this change get us? Auto-completion of all our helpers:
For this to work well, what does the testModel look like?
Note, I think that maybe the args to
meta.test
are invalid (the reason why type inference doesn't work here). This'd be upstream in XState though.cc @davidkpiano re: meta.test types