I am trying to fetch my store state in my Cypress test. As advised here: Cypress - programmatically manipulating Angular/NGRX app I am exposing my store in my angular component this way:
constructor(private store: Store<MigrationsState>) {
if (window.Cypress) {
window.store = this.store;
}
}
And I can get the store this way:
cy.window().its('store')
but when doing:
cy.window().its('store').invoke('getState')
as explained in the cypress docs (it is indeed aiming for Redux stores) - https://www.cypress.io/blog/2018/11/14/testing-redux-store/, I am failing to get the state:
Timed out retrying after 20000ms: cy.invoke() errored because the property: getState does not exist on your subject. cy.invoke() waited for the specified property getState to exist, but it never did. If you do not expect the property getState to exist, then add an assertion such as: cy.wrap({ foo: 'bar' }).its('quux').should('not.exist')
Any idea what should I do differently here?