https://cypress.io logo
Join Discord
Powered by
# help
  • u

    user

    03/25/2022, 1:06 AM
    only 1 request appears
  • a

    adorable-smartphone-87280

    03/25/2022, 1:42 AM
    It’s helpful to format code between two sections of ‘’’
  • u

    user

    03/25/2022, 3:14 AM
    done
  • a

    adorable-smartphone-87280

    03/25/2022, 3:26 AM
    Is this because you’ve set ‘failOnStatusCode: true’ and it’s reaching a ‘404’?
  • a

    adorable-smartphone-87280

    03/25/2022, 3:26 AM
    A ‘404’ and a ‘network failure’ might mean different things, I don’t know.
  • u

    user

    03/25/2022, 3:34 AM
    I've tryed both ways, but retryOnStatusCodeFailure needs failOnStatusCode to be true, otherwise the message 'failOnStatusCode must be true if retryOnStatusCodeFailure is true' is returned
  • a

    adorable-smartphone-87280

    03/25/2022, 3:37 AM
    Are you trying to repeat the request after a 404 and see if you get something different?
  • u

    user

    03/25/2022, 3:44 AM
    I haven't yet. But, cypress is supposed to be doing that for me, isn't it? https://docs.cypress.io/api/commands/request#Arguments
    Copy code
    Whether Cypress should automatically retry status code errors under the hood. Cypress will retry a request up to 4 times if this is set to true
  • a

    adorable-smartphone-87280

    03/25/2022, 3:48 AM
    I still think a status code error and a 404 aren’t the same thing. But I don’t know enough about this command to help further.
  • f

    fierce-stone-88794

    03/28/2022, 8:43 AM
    Hello everybody. I have a issue with a cypress project for a client. In the client's application, there's an iframe cypress can't display, so the tests are failing every time.The iframe is on the same domain as the application and generated in javascript, with a .jsp inside. It's the only iframe of the application that work like this, and the only iframe cypress can't display. The context of the project is kind of complicated. A lot of security, some tricky proxy settings, and the obligation to use Electron for security policy doesn't allow me to use Chrome nor Firefox (I think I can't do anything about it). Do you have any idea or solution for me in order ton understand why this iframe isn't displayed, and how to fix it ? Best regards
  • s

    shy-country-15366

    03/28/2022, 4:07 PM
    I hope this is the right channel to ask this, but cy.wait('@getData') will pass if I have already received a response from the 'getData' endpoint, even though I wanted to wait for the second response. But cy.wait('@getData').its('response.statusCode').should('eq', 200) will not pass until a new response is received. Is that actually the correct behavior?
  • s

    shy-country-15366

    03/28/2022, 4:10 PM
    To use example from the docs
  • s

    shy-country-15366

    03/28/2022, 4:11 PM
    Are these two blocks equal
  • s

    shy-country-15366

    03/28/2022, 4:11 PM
    Copy code
    // stub an empty response to requests for books
    cy.intercept('GET', '/books', []).as('getBooks')
    cy.get('#search').type('Peter Pan')
    
    // wait for the first response to finish
    cy.wait('@getBooks')
    
    // the results should be empty because we
    // responded with an empty array first
    cy.get('#book-results').should('be.empty')
    
    // now the request (aliased again as `getBooks`) will return one book
    cy.intercept('GET', '/books', [{ name: 'Peter Pan' }]).as('getBooks')
    
    cy.get('#search').type('Peter Pan')
    
    // when we wait for 'getBooks' again, Cypress will
    // automatically know to wait for the 2nd response
    cy.wait('@getBooks')
    
    // we responded with one book the second time
    cy.get('#book-results').should('have.length', 1)
  • s

    shy-country-15366

    03/28/2022, 4:16 PM
    Copy code
    // stub an empty response to requests for books
    cy.intercept('GET', '/books').as('getBooks')
    cy.get('#search').type('No book...')
    
    // API call is made, wait spinner or something to disappear (= api has responded)
    
    // the results should be empty because we
    // responded with an empty array first
    cy.get('#book-results').should('be.empty')
    
    cy.get('#search').type('Peter Pan')
    
    // when we wait for 'getBooks' again, 
    cy.wait('@getBooks').its('response.statusCode').should('eq', 200)
    
    // we responded with one book the second time
    cy.get('#book-results').should('have.length', 1)
  • s

    shy-country-15366

    03/28/2022, 4:19 PM
    e2e test obviously, but what I'm trying to understand, if I skip the
    Copy code
    .its('response.statusCode').should('eq', 200)
    Cypress isn't going to wait for the response because it has already received a response from 'getBooks', but if I add the
    Copy code
    .its('response.statusCode').should('eq', 200)
    it will wait for a new response before continuing. Am I getting it right?
  • t

    tall-airplane-97209

    03/28/2022, 9:13 PM
    Should there be any differences between running Cypress on Linux vs. Windows? I see the same tests error on Linux that never fail on Windows and I'm not sure why.
  • p

    powerful-orange-86819

    03/29/2022, 10:38 AM
    have {times: 1} in first interceptor, so it only catches the first time the request is made, second time is the other interceptor heres an example of test i'm currently writing
    Copy code
    js
     cy.intercept({
          method: "GET",
          pathname: "/api/v1/request-transaction",
          query: {
            paymentStatus: "PENDING",
          },
          times: 1,
        }).as("getRequest");
  • s

    shy-country-15366

    03/29/2022, 1:45 PM
    But if I don't care for the first intercept, or the second etc... In the example above, I may have just added a "book", RQ invalidates the "books" key and refetches "books", at that point I want to validate that "getBooks" is refetched.
  • s

    shy-country-15366

    03/29/2022, 1:46 PM
    Also, thanks for a fast reply 🙂
  • p

    powerful-orange-86819

    03/29/2022, 1:52 PM
    You are using the same alias for both "GET" requests - ('@getBooks') and the second time (reFetch) you are reading the data from the first one, either use unique aliases or add Times: 1 Try my advice, i've delt with this problem a lot and i've developed a practice for handling aliases and multiple intercepted requests
  • s

    shy-country-15366

    03/29/2022, 2:18 PM
    I'll give it a go
  • a

    adorable-smartphone-87280

    03/29/2022, 2:20 PM
    Do you use
    times: 1
    in the second
    intercept
    if using the same data? Do you re-use the same alias name in the second
    intercept
    ?
  • p

    powerful-orange-86819

    03/29/2022, 2:24 PM
    use times: 1 always in the first intercept if you are going to have the same interceptor later in the test or in any next tests of the same suite
  • a

    adorable-smartphone-87280

    03/29/2022, 3:06 PM
    But then in the second time you use it, you can call it without that param and it'll just pick up the second request? Like... it won't go back and find the first one as long as your code exectues at the right time?
  • c

    crooked-vase-82118

    03/30/2022, 1:02 PM
    Hi everyone, I 'm stuck on how to write e2e tests with Cypress for an Ionic project that uses Capacitor plugins. I thought I could use the Storage plugin to build a custom state for a test in which if the user has accepted the privacy policy, then the app redirects on the home page.
    Copy code
    ts
      describe('Already accepted', () => {
        it('When policy is already accepted, then skip ToS page', () => {
          cy.wrap(
            Storage.set({ key: 'tosTimestamp', value: new Date().toISOString() })
          );
          
          cy.visit('/');
          cy.url().should('include', '/tabs/home');
        });
      });
    However, the test fails with a generic error message: The following error originated from your test code, not from Cypress. > Unexpected token '<' Furthermore, I discovered that the Storage plugin from Capacitor and the the localStorage API are not aligned, in the sense that if I try setting a key/value entry using the localStorage, then Capacitor is not able to read it. Thank you for any suggestions!
  • b

    brief-agency-15720

    04/01/2022, 7:00 PM
    Hi all! I'm new to cypress and looking for advice.. I want to send the same POST requests using cypress with different variables for 'email' and 'check_in_date'. The request below is a command in the support file, postAPI() is called before each it() in the spec. I think I can create fixtures for each variable? But I'm not sure how to call those fixtures using postAPI() for each variable?
    p
    • 2
    • 2
  • p

    powerful-gigabyte-69168

    04/03/2022, 12:42 PM
    Parameterizing Commands for use with fixtures
  • a

    acoustic-finland-93241

    04/03/2022, 5:04 PM
    if an iframe is from another domain it wont show up, there is a general rule that in automation tests you test your application and noone eleses, i've been looking for a solution to this issue for a few months now, because at my job we have tons of iframes with third party integrations
  • g

    gray-agent-80430

    04/04/2022, 5:33 AM
    I am new to cypress. I am automating a login flow. My test is failing due to GOOGLE CAPTCHA. Please guide me how I bypass GOOGLE CAPTCHA so my tests stop failing. Help is appreciated.
1...535455...252Latest