https://cypress.io logo
Join Discord
Powered by
# e2e-testing
  • n

    nutritious-megabyte-64190

    11/11/2022, 2:57 PM
    attempting to recurse an api call using cy.waitUntil() and we had the brilliant idea of using the property called `status `that gives us the go or no go however when i attempt to do something like so
    Copy code
    cy.waitUntil(
                () => {
                    cy
                        .request({
                            method: 'GET',
                            headers: {
                                'token': accessToken
                            },
                            url: `api/is-ready`,
                            failOnStatusCode: false
                        }).its('status').should('eq', 'READY');
    
                        assertexpected 200 to equal **READY**
    is there a way to access my 'status' and not the actual status code
  • g

    gray-kilobyte-89541

    11/11/2022, 3:33 PM
    check out http://github.com/bahmutov/cypress-recurse You can do anything you want with it
  • n

    nutritious-megabyte-64190

    11/11/2022, 3:34 PM
    haha yea that was my next option thanks my man!
  • n

    nutritious-megabyte-64190

    11/11/2022, 3:49 PM
    thanks that worked perfectly, shoulda used it the 1st time πŸ˜„
  • b

    boundless-egg-31682

    11/11/2022, 8:16 PM
    I have a test which makes a request to each of the links within a specific section of my page. I am trying to intercept the request and verify something, but I am getting this error.
  • e

    enough-truck-68085

    11/11/2022, 8:23 PM
    cy.wait('@request')
    will only resolve once an actual request occurs. The error you are receiving is suggesting that the request you are trying to spy on isn't actually getting called. You need to ensure that request actually occurs and can validate this in the runner here in the
    #
    of times the route was found. Right now it's 0. Additionally, the test runner will output all network calls and provide you information if your intercept matched any request calls.
  • b

    boundless-egg-31682

    11/11/2022, 8:26 PM
    Yeah the error makes sense but the requests definitely occur when I am not trying to intercept them. I can see them happening in the runner when I comment out that piece of code. Do you think it is a route matching problem? Any other ideas?
  • e

    enough-truck-68085

    11/11/2022, 8:28 PM
    It could either be a matching problem or you are defining your intercept too late. The intercept definition needs to always be defined before the request occurs or Cypress won't actually intercept it correctly. I typically define all my intercepts in a beforeEach or at the start of each test so I know there's no conflicts with timing. I would try defining your intercept once outside of the forEach, as this might fix the timing although I don't know exactly what triggers your request. Defining the intercept multiple times is unnecessary anyway. Additionally, I would try replacing the single wildcard char
    *
    with a double wildcard
    **
    in your url
  • b

    boundless-egg-31682

    11/11/2022, 8:51 PM
    I'm not seeing any change when I try those two things. Just in case it helps, this is what my requests look like when I run the tests without the intercept & wait. I am trying to avoid clicking on a bunch of things so just using cy.request(). Do you think that is a problem?
  • g

    gray-kilobyte-89541

    11/11/2022, 8:52 PM
    cy.intercept
    does not SEE
    cy.request
    calls https://on.cypress.io/intercept
  • b

    boundless-egg-31682

    11/11/2022, 8:53 PM
    Oh no 😒 thank you though!
  • a

    acceptable-fall-11897

    11/11/2022, 11:33 PM
    I am trying to delete data from MongoDB by plugin cypress-mongodb but unable to do. Please guide me how can I do delete.
  • b

    billions-tomato-88210

    11/12/2022, 2:07 AM
    Hello everyone! I'm currently working on a school project, one of the test is to test logout button by cypress, I've search on google and youtube , could not find something to help out.. if someone could help me out with it i will really appreciate it.. "The logout button logs the user out when clicked"
  • s

    stale-wire-41120

    11/12/2022, 5:38 AM
    i am trying to read data from Excel
  • k

    kind-artist-92362

    11/13/2022, 8:38 AM
    hi there! i am doing kind of listing to study Cypress , so i should find the answer what is going on in those lines of code . I got maybe partially it , but could someone explain every command there
  • k

    kind-artist-92362

    11/13/2022, 9:24 AM
    that is what my searches show
  • k

    kind-artist-92362

    11/13/2022, 9:24 AM
    The idea of ​​this block of code is to replace the open method before it is called (it's not entirely clear here) .window is a method(cy object command) that gives the object of the page that is currently active. .then - Enables you to work with the subject yielded from the previous command then((window) here we pass the resulting object (as I understand it, you can somehow shorten the name win , is that right?) (window) => { } here we put a new value in our received window object Next, we use the stub command to avoid the following problems. "If an application calls window.open during Cypress test it might lead to two problems: 1)the new URL might point at a different domain, rendering Cypress "blind" and unable to continue the test 2)the new URL might open in the second tab, invisible to Cypress" When we call cy.stub(win, 'open') it replaces win.open method with a Sinon stub function callsFake function dynamically withdraws url which has been placed into original window.open(url, "_blank") window.location = url - redirects us to a new url
  • k

    kind-artist-92362

    11/13/2022, 10:37 AM
    also need some help with it .its('0.contentDocument.body')
  • k

    kind-artist-92362

    11/13/2022, 10:37 AM
    what does mean 0.contentDocument.body'
  • k

    kind-artist-92362

    11/13/2022, 3:51 PM
    what is existing there ?
  • k

    kind-artist-92362

    11/13/2022, 3:55 PM
    @colossal-shoe-26040
  • g

    gray-kilobyte-89541

    11/13/2022, 10:42 PM
    https://glebbahmutov.com/blog/stub-window-open/
  • a

    aloof-psychiatrist-45078

    11/14/2022, 8:24 AM
    hi peeps, i was testing cy.intercept() when i console log on the response back to the browser, occasionally the body will have empty body. i want to assert some values in the body but unable to do so. Anyone have guidance on this?
  • f

    fresh-doctor-14925

    11/14/2022, 8:42 AM
    If you're doing
    cy.wait()
    , then cypress is responding when the endpoint returns something. So it looks like your application is occasionally returning an empty body. That's because the application is logging a 304 (not modified) error
  • a

    aloof-psychiatrist-45078

    11/14/2022, 8:49 AM
    i think im able to simulate something whenever i
    npx cypress open
    and run the test first time, able to get the body response with 200 Status code but when i re-run the test, this is the moment body responding empty response and with 304 Status Code
  • f

    fresh-doctor-14925

    11/14/2022, 9:06 AM
    What happens when you run it with
    npx cypress run
    ? I'm wondering if it's a shared context thing
  • a

    aloof-psychiatrist-45078

    11/14/2022, 9:07 AM
    let me try
  • b

    boundless-plastic-54849

    11/14/2022, 9:09 AM
    Hi all, In our project we're using snapshot testing. However, some devs are running Windows, some are running OSX and the CI is using linux. Rendering the snapshots could be different on either one of the environments. (fonts, shadow rendering) How do you solve this issue? What we're currently doing is running Docker with Linux locally to match the CI. But it feels a bit odd to be having to use Dockered Linux, a system which our user base don't use.
  • b

    boundless-plastic-54849

    11/14/2022, 9:15 AM
    In other words: How do you get consistent snapshot testing across environments?
  • a

    aloof-psychiatrist-45078

    11/14/2022, 9:29 AM
    i used
    cy.task('log', response)
    and this is the output
1...140141142...192Latest