'GraphQL API request pass in postman but failed in cypress
When I try to send a request using postman it will pass with status code 200 but when I run the cypress test it will return an error.
This is a postman image
When I run my cypress test it will return the below error
Here is my cypress test.
it('Sign up', function () {
cy.readFile("cypress/fixtures/data.json").then((profile) => {
var OTPQuery = 'mutation { verifyEmailOtp(email: "' + profile.email + '", otp: ' + profile.OTP + '){ message } }'
cy.log(OTPQuery)
cy.wait(2000)
cy.request({
method: "POST",
url: "https://api.outsized.site/graphql",
// failOnStatusCode: false,
headers: {
'Content-Type': 'text/plain'
},
body: {
query: OTPQuery
}
}).as('rq')
cy.wait('@rq').then((res) => {
expect(res.status).to.eq(200)
});
})
})
Anyone helps me to find out what's the problem here?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|


