Cypress w/graphql - having issues getting AUTH with testing via UI. Better way to stub mutation?

前端 未结 2 760
旧时难觅i
旧时难觅i 2021-01-22 13:50

So, if I am testing pages in a vacuum without much interaction with the backend, it works great. I am having issues with actually interacting with my UI if it hits any type of s

2条回答
  •  挽巷
    挽巷 (楼主)
    2021-01-22 14:39

    Here's a simpler way of handling a mutation with cy.request

     const mutation = `
       mutation {
         updateUser(id: 1, firstName: "test") {
           firstName
           lastName
           id
           role
         }
       }`
    
     cy.request({
        url: url,
        method: 'POST',
        body: { query: mutation },
        headers: {
          Authorization: `Bearer ${token}`,
        },
      })
    

提交回复
热议问题