asserting the response of ajax requests
See original GitHub issueIs this a Feature or Bug?
bug, cant find docs on https://docs.cypress.io/guides/guides/network-requests.html#Testing-Strategies need to know how to assert on responses I get from the server.
Probably its me, but maybe others cant find how as well 😕
Test code:
cy.get('#contactID').type('email@gmail.com')
cy.contains('Login').click()
// I have an ajax call here, want to assert on the reponse
Issue Analytics
- State:
- Created 6 years ago
- Reactions:3
- Comments:7 (2 by maintainers)
Top Results From Across the Web
QUnit test ajax success function - javascript - Stack Overflow
ajax = function(request) { assert.equal( request.url, 'test_response.html', 'request url is correct' ); assert.
Read more >How to Write Unit Tests for Ajax Requests using Mocha
Handling the response includes pairing the received data within an object. Providing that you already prepared the data and dataJson variables ...
Read more >Asserting on payloads · GitBook - GitHub Pages
the AJAX call has the wrong request payload ... the response payload contains both the email and the username , the token is...
Read more >How to Handle AJAX Call in Selenium Webdriver - Guru99
AJAX sends HTTP requests from the client to server and then process the server's response, without reloading the entire page.
Read more >Mocking AJAX Requests | Testing Your JavaScript ... - InformIT
The answer should be obvious immediately: The @collection object isn't receiving a response from the server when the fetch function is called, ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Got it 😃
just needed to use regex in the url
instead of ‘contact.php’ used /contact.php/
In order to assert on the response of an XHR request, you’ll need to setup a route to listen to the request you want to assert on.
I like to alias the route so that I can do some things in between listening and waiting for the response to assert on.
Please note that there is limited support for ‘fetch’ - see this issue if you are using fetch.
I agree, the docs could have better actual examples with the testing strategies - or at least link to them. I suggest you open an issue in our docs