TommyD
TommyD

Reputation: 1043

Stubbing a computed function in vue with Cypress

I am trying to stub this out in Cypress. I have a computed that returns true or false. I just want it to return true.

  computed: {

      isAdmin() {
          return this.$store.state.User.isRegistered &&
           this.$store.state.User.isAdmin
        }
}

There is a great article on using the vuex store

https://www.cypress.io/blog/2017/11/28/testing-vue-web-application-with-vuex-data-store-and-rest-backend/

but I don't even want to touch the store. Is this possible?

Upvotes: 1

Views: 1004

Answers (1)

Hexodus
Hexodus

Reputation: 12945

Havent tested this but it should go like this:

        cy.stub(YourComponent.computed, 'isAdmin').callsFake(() => { return true })

Upvotes: 1

Related Questions