I have a Vue application that is using mongodb and flask for the back-end. I am trying to test the code as follows.
There is a form as you can see from the image above. When I enter the URL's, tokens, password, ssh, and project name, and click Create button, I add them to an object and send them to the database in a request.
I want to write these values in Cypress.js (this part is done), and click the create button. After clicking create button I want to test the data that is sent as request. How can I reach the body in the request in cypress?
You can use cy.intercept()
to look at outbound requests. Request object documentation here.
cy.intercept('/some/url', (req) => {
// whatever you need to do with the request object
// for example, validating the request body has a name field
expect(req.body.name).to.equal('My Body Object Name');
// req.continue() tells the request to continue!
req.continue()
});
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments