-
Notifications
You must be signed in to change notification settings - Fork 0
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
Test machine has empty state history after tests finish #1
Comments
I kind of solved this, but I don't know why this works really - and the sequence of commands is wrong in the command log import { Machine } from 'xstate'
export const toggleMachine = Machine({
id: 'toggle',
initial: 'inactive',
states: {
inactive: {
on: {
TOGGLE: 'active'
},
meta: {
test: () => {
console.log('model meta test')
return new Promise(resolve => {
cy.contains('button', 'Off')
.should('be.visible')
.then(() => {
resolve()
return null
})
})
}
}
},
active: {
on: {
TOGGLE: 'inactive'
},
meta: {
test: () => {
console.log('model meta test')
return new Promise(resolve => {
cy.contains('button', 'On')
.should('be.visible')
.then(() => {
resolve()
return null
})
})
}
}
}
}
}) Notice how clicking on the button is in the "After" section - I could not get it to work from |
The tests (under Not sure how to do this manually with Cypress yet; it's different than how it normally works. |
@bahmutov looking forward to hear more on this. kudos to your efforts! I also stumbled upon this thread after reading @davidkpiano state machines article and faced same issue with cypress. |
The Cypress test seems to drive the app using test model correctly. I can see events going according to the path. But when the tests finish, the test model collects state history, which is empty
Here is the problem: we really have 2 state machines:
So while we drive along the test machine we don't know what states the application state machine set. I am thinking we could either
cy.visit
) with test state machineThe text was updated successfully, but these errors were encountered: