-
Notifications
You must be signed in to change notification settings - Fork 3.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Explicit wait doesn't work with regular expression and glob #567
Comments
Hi @behlrattan, it's helpful when using globs to test your Globs in globtester or Regex in a regex checker like regex101. I was able to get the endpoint you specified to work with Also, I notice you are not defining a chainer in your final assertion: cy.wait('@submit').its('url').should('verify/complete') // incorrect You need to define a chainer. You'll notice that the assertion will usually sound like a sentence "its url should include 'verify/complete'" like so: cy.wait('@submit').its('url').should('include', 'verify/complete') // correct |
Thanks @jennifer-shehane for the quick response. But, i'm afraid i'm still having issues (Timeout after 5 seconds on requestResponse. As per the documentation https://docs.cypress.io/api/commands/wait.html#Timeouts
And that made me believe the request that i'm trying to build using glob is not working. |
Take a screenshot of your command log. Cypress will indicate when an XHR matches an alias. You can also click on the XHR request and get more details. Post that command log and a screenshot of the console output after clicking on the XHR. |
This is piece of code: cy.route('/api/v1/identity/**').as('identity') cy.get('Button').click() cy.wait(['@submit','@identity'])` |
If your application is making a POST, that's why it's not working. You need to tell
|
Thanks!, couple of things
OR
|
The XHR you are highlighting in the dev tools is not the one that matches what Cypress logged. I am 100% confident there is not a bug with Cypress's stubbing behavior - all I think the problem is that you're not correctly writing your You should use http://www.globtester.com/ to help you write a correct glob pattern. |
I'm going to close this issue as I don't believe there is anything wrong on our end. If you believe something needs to be changed please create a reproducible repo with the incorrect behavior. |
The screenshot of XHR in the dev tools does match with what Cypress has logged. Its api/v1/identity/application id |
Hi @behlrattan. cy.server();
cy.fixture("myData.json").then( myData => {
const myDataArray = [ myData ];
cy.route("GET", "/alerts**", myDataArray)
.as("getDataArray");
});
cy.visit("/");
cy.wait("@getDataArray").its("responseBody")
.should("have.property", "type"); Thanks in advance. |
I'm assuming its timing out because your assertion is failing. Your assertion is failing because you're wrapping your The assertion is failing because it should be failing :-P |
Hi Brian. While you are right and I had to modify what you pointed out, I couldn't make the test work yet...
Just for the sake of seeing what happen I tried "*" as my url and that way cy.wait() passes and I can see in the network info?t=1509676709990 containing the expected response, but the data doesn't appear to be available in my application. Honestly, I'm a little bit at lost, so any suggestion is appreciated. |
@brian-mann Just a side-mention that the failure to match POST should probably be included in the intro-level documentation as a note/gotcha. As a Cypress newbie I got bitten by the same problem--my XHR was using POST--and only after stumbling upon this GitHub issue did I learn the default was GET. (Better, perhaps, would be that if you don't specify, it would match either). Thank you |
@cosmocracy I opened an issue in our docs for your suggestion here cypress-io/cypress-documentation#217. Our docs are open source, so feel free to contribute. :) |
@julian69 I suggest playing around with Globtester if you are trying to match globs using minimatch. I was unable to get a match with the url and glob you posted, but the glob |
Thanks @jennifer-shehane for your answer. I've been playing around with Cypress for a few days now and I apologise beforehand if what I'm asking is not relevant for this issue. I though at first that the error I was getting was due the URL, but I tried again with a couple of matching options and still the same. Roughly, what I'm trying to do is to mock the data I'm consuming in my components using fetch. I'm working on a test environment and, otherwise, I should load data to the db every time in order to be able to run the test. As to make sure there was nothing wrong with my environment, I downloaded the "cypress-tutorial-build-todo-starter" and created a similar but simpler scenario but got stuck in the same place (Timed out retrying: cy.wait() timed out ...). This is kind of how I get the data (not my real service, but same idea):
and this is how I'm trying to mock it:
Thanks heaps! |
Here's the open issue including a simple workaround: #95 (comment) It will be supported once #687 has landed. |
Thanks again for your time. |
Is this a Feature or Bug?
Bug
Current behavior:
CypressError: Timed out retrying: cy.wait() timed out waiting 5000ms for the 1st request to the route: 'submit'. No request ever occured.
Desired behavior:
Explict wait should work
How to reproduce:
Test code:
The endpoint on which I want to apply explicit wait is
api/v1/account/a5f35b5f-bc8f-4c7b-a79d-68950dc2fcb7/submit
api/v1/account/<unique application id for every request>/submit
cy.server()
//Tried Regex and Glob one at a time and not all together
cy.route(//api/v1/account/./submit/).as('submit')
cy.route('/api/v1/account/**').as('submit')
cy.route('/api/v1/account//submit').as('submit')
cy.get('button').click()
cy.wait('@submit').its('url').should('verify/complete')
Additional Info (images, stack traces, etc)
The text was updated successfully, but these errors were encountered: