Quantcast
Channel: How to expose/access a data store like Redux within a cypress test? - Stack Overflow
Viewing all articles
Browse latest Browse all 4

Answer by Richard Matsen for How to expose/access a data store like Redux within a cypress test?

$
0
0

I am not sure of the exact syntax for a React app, but see this blog Testing Vue web applications with Vuex data store & REST backend.

Vuex is the VueJs equivalent of Redux. In summary, you add a reference to the store at some point in the app startup (code snippet is modified from the blog to be a bit more generic)

if (window.Cypress) {  // only available during E2E tests  window.appStore = app.store  // Substitute an appropriate expression for React Redux}

and reference it in tests like so

const getStore = () => cy.window().its('appStore')it('has loading, newTodo and todos properties', () => {  getStore().its('state').should('have.keys', ['loading', 'newTodo', 'todos'])})

Viewing all articles
Browse latest Browse all 4

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>