I'm trying to stub with Cypress both the frontend and backend calls to useSession()
and getSession()
respectively.
The stubbed functions don't seem to replace the functions or get called:
I'm trying to do it this way:
const client = require("next-auth/react")
....
....
cy.stub(client, "getSession").returns({
user: {
name: "xxx",
email: "xxx",
image: "xxx",
},
expires: "2022-07-08T09:49:47.602Z",
})
cy.stub(client, "useSession").returns({
user: {
name: "xxx",
email: "xxx",
image: "xxx",
},
expires: "2022-07-08T09:49:47.602Z",
})
cy.visit(`/draft/cl45ip2d600379as17epvu6ti`)
I've tried googling it but most people seem to use jest for this and not cypress and there doesn't seem to be a lot of documentation and I'm not sure how to continue.
I'm not sure if this is relevant or not, but the call to getSession is being triggered by a client http request to the api.