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

    gray-dawn-16972

    01/16/2023, 9:39 AM
    Hello Everyone, I have a challenge at work, we interact with a 3rd party API and it seems this API fails randomly, manually and also in the pipeline where we run our Cypress tests. I have contacted the API provider and he requested for logs of the execution. my question is, how can I collect the logs for the pipeline run? or even a local run?
  • b

    broad-analyst-94821

    01/16/2023, 10:23 AM
    I'm upgrading to Cypress 12^ and each it block is trying to navigate to about:blank. * I added { testIsolation: false } to the top-level describe block in a single test, and that works * Question - is there a way to set this globally to avoid navigating to about:blank ( to avoid having to add { testIsolation: false} to each file? I'm not doing any cross-origin testing
  • b

    broad-analyst-94821

    01/16/2023, 10:27 AM
    Do you have an example of this? Is it in e2e.ts?
  • s

    some-cartoon-73108

    01/16/2023, 12:21 PM
    @broad-analyst-94821 - You need to add it to you config. And set it to false of course
  • d

    dry-portugal-25841

    01/16/2023, 1:56 PM
    first idea, maybe try to save logs in file
  • g

    gray-dawn-16972

    01/16/2023, 1:58 PM
    I thought about this but I am not sure I know how to achieve that
  • g

    gray-dawn-16972

    01/16/2023, 2:06 PM
    I saw plugins online but I am not confident about the efficiency
  • d

    dry-portugal-25841

    01/16/2023, 2:07 PM
    not sure for cypress log, but plain javascript should be possible to do something like: https://stackoverflow.com/questions/11849562/how-to-save-the-output-of-a-console-logobject-to-a-file, or if locally maybe just manually 🤔
  • c

    careful-tent-30457

    01/16/2023, 3:10 PM
    Hello, I'm experience quite a lot of flakyness with my Cypress tests between
    cypress open
    and
    cypress run
    on my local machine, webGL error in headless. But more frustrating is that I have additional flakyness with different tests failing in CI (Azure pipelines) using
    cypress run
    . the error in CI environment started occurring after upgrading from 11.3 to 12.3. the offending code is:
    Copy code
    afterEach(() => {
      cy.dataCy("clear-button").each((btn) => {
        cy.wrap(btn).click();
      });
    });
    which is the latest attempt going around the error. it works for one IT but not for the next one. I've used
    { testIsolation: false },
    in my describe as running with indivudual visit and setup for each test is soo slow in CI environment that we opted for test depending on eachother.. not ideal but saving several minutes per PR is worth it. Looking for any suggestions on how to make tests be less random depending on environment.
  • g

    gray-kilobyte-89541

    01/16/2023, 3:51 PM
    but that is the error?
  • c

    careful-tent-30457

    01/16/2023, 3:52 PM
    actually just looked at the error, I get 2 errors in CI that I don't get on my local machine.
  • c

    careful-tent-30457

    01/16/2023, 3:53 PM
    both errors related to that afterEach not doing the job of clearing the items as it should
  • c

    careful-tent-30457

    01/16/2023, 3:53 PM
    only one of two items are cleared in a list
  • g

    gray-kilobyte-89541

    01/16/2023, 3:56 PM
    I'm sorry, but I still don't understand what the error is. Is it clicking every button, but not really?
  • c

    careful-tent-30457

    01/16/2023, 3:59 PM
    so, on my machine (mac m1) that afterEach is clicking each button and hence subsequent ITs are passing, where as in CI env the AfterEach leaves one element hanging and thereby subsequent ITs are failing, in 11.3 we had afterEach with click({multiple: true}) but did not work in 12.3
  • g

    gray-kilobyte-89541

    01/16/2023, 4:00 PM
    ok, so each "clear" button removes something from the page. But sometimes it fails to remove a button, even after a click? And probably the last one?
  • c

    careful-tent-30457

    01/16/2023, 4:01 PM
    yes, that's my suspicion, I would add an expectation about the list being empty in the afterEach but ATM yarn of all things fail in our CI, so I'm having one of those days where I just wanna chuck the computer in a lake and quit 😂
  • g

    gray-kilobyte-89541

    01/16/2023, 4:02 PM
    Ok, I know how to help, I will write a blog post about it
  • c

    careful-tent-30457

    01/16/2023, 4:04 PM
    so this is a long chain of issues really all starting with our CI being 400% slower than our local machines running our test suite, making us writing tests that rely on eachoter
  • g

    gray-kilobyte-89541

    01/16/2023, 4:05 PM
    parallel run?
  • c

    careful-tent-30457

    01/16/2023, 4:09 PM
    yes, we will eventually go parallell but we "only" have 115 tests and I still would like to understand why one test is 400% slower on a linux Azure pipeline VM vs a m1 Mac laptop and 200% slower than a fairly old Windows 11 laptop.. we tried moving to our own VMs with more ram rather than the 7GB ram machines offered up by default azure, but we got more benefit from upgrading from cypress 11.3 -> 12.3 than we did our own more powerful CI agent
  • f

    future-glass-89764

    01/16/2023, 4:13 PM
    Hi Team
  • f

    future-glass-89764

    01/16/2023, 4:14 PM
    This is Rakesh H N here, i have one doubt in Cypress.. Is there any possibility to isebthe script without using after block ?
  • f

    future-glass-89764

    01/16/2023, 4:14 PM
    2 nd question i want to navigate failed step directly how ?
  • f

    future-glass-89764

    01/16/2023, 4:15 PM
    @gray-kilobyte-89541
  • w

    wooden-shampoo-53816

    01/16/2023, 4:16 PM
    ## Hello, I want to log every request/response into a file that is made into application using cypress. I created task in
    cypress.config.js
    which writes given data into a file. The I tried multiple different ways but two are worth mentioning. ### 1st approach I wrote the following code into
    support/e2e.js
    beforeEach
    function
    Copy code
    cy.intercept('/api/*', (req) => {
      return req.continue((response) => {
        let responseData = {
          status: response.status,
          headers: response.headers,
          body: response.body
        };
        console.log('1')
        return new Promise((resolve, rej) => {
          resolve(responseData)
        })
      });
    })
      .then(res => {
        console.log('2')
      })
    "2" is printed only once and it is printed earlier than any "1". Each "1" is printed as many times as many requests are made. So I can't get result after
    cy.intercept
    ### 2nd approach
    Copy code
    javascript
    cy.intercept('/api/*', (req) => {
      return req.continue((response) => {
        let responseData = {
          status: response.status,
          headers: response.headers,
          body: response.body
        };
        cy.task('appendFileSync', JSON.stringify(responseData))
      });
    })
    I get the following error
    Copy code
    Cypress detected that you returned a promise from a command while also invoking one or more cy commands in that promise.
    Do you have any idea, how I can collect my request/response data and log inside a file?
  • g

    gray-kilobyte-89541

    01/16/2023, 4:17 PM
    I don't understand the question, sorry
  • g

    gray-kilobyte-89541

    01/16/2023, 4:18 PM
    Ohh, it is a good topic for a lesson for my paid course https://cypress.tips/courses/network-testing For now search https://cypress.tips/search for "out of band" blog post. Ohhh, I have a similar lesson already there https://cypress.tips/courses/network-testing/lessons/bonus12 which saves a single response into a file
  • f

    future-glass-89764

    01/16/2023, 4:20 PM
    @gray-kilobyte-89541 we were developed framework in that if the Test cases are failed in it block automatically after block also failing so i want to removed all the steps in after block so i need to run the Test cases is that possible?
  • w

    wooden-shampoo-53816

    01/16/2023, 4:22 PM
    Do you already have that particular section in your paid course?
1...248249250251252Latest