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

    acoustic-ability-58956

    12/29/2022, 10:13 PM
    Hi! I’d love to be able to use the code coverage plugin, but my Cypress tests live in a different repo than the app. Is there a way to get code coverage metrics with this set-up?
  • f

    full-intern-54710

    12/29/2022, 11:14 PM
    Hello community, my name is Marcos, I'm from Brazil, thank you all in advance for your support and help, cypress is very popular here. I need help with a problem. I'm testing an application that has a lot of requests and is very slow to login, my goal is to send the first click as soon as this page is all loaded, I tried using cy.intercept, but it's very complicated to intercept request by request since there are so many. With that in mind, I found a possible solution to wait for loading by waiting for the loading screen to load with a cypress-wait-until command. I used the following code cy.waitUntil(() => cy.get('.OctaPlaceholder_loading__bubbles_s91PS').invoke('attr', 'aria-busy), and it works halfway through and throws the following attached errors Do you know any better solution to this problem, or another way I can go to solve it?
  • m

    magnificent-finland-58048

    12/30/2022, 1:56 PM
    so you're recursing until the UI settles? That's not the best approach try https://github.com/bahmutov/cypress-network-idle The worst, offensive application I have seen was a 3rd party one For 30 seconds the network would not stop... loading ads, and all bad things you can imagine. cypress-network-idle was the solution, but sometimes in CI even that would time out because the network noise did not stop sometimes for 30 + seconds So we added a hard wait (buffer) + waitForNetworkIdle . It's been good since It's the only time I've used a hard wait.
  • m

    magnificent-finland-58048

    12/30/2022, 1:58 PM
    waitUntil was great back in the day, but I think cypress-recurse took over You shoudn't need either, but try recurse if the network solution doesn't tame the app
  • f

    famous-magician-10206

    12/30/2022, 2:55 PM
    Hi all, I need to pass the url and other variable in multiple tests[it-function]. For 1st test code run successfully but for 2nd test it showing error. Is there any workaround or solution? My code is as follows `
    Copy code
    describe('Document Upload', function()
    {
        before(function () {
            cy.fixture('Credential').then(function (testdata) {
                this.testdata = testdata
            })
        })
        //1st test
        it('Login as manager',function()  
        {
        const login = new loginPage()
    
        cy.visit(this.testdata.baseUrl);
        login.getUserName().type(this.testdata.userDocumentM)
        login.getPassword().type(this.testdata.passwordDocumentM)
        login.getLoginButton().click()
        //Logout
        login.getUser().click()
        login.getLogout().click()
    
        })
        //2nd test
    
        it('Create Documents',function()  
        {
        const login = new loginPage()
    
        cy.visit(this.testdata.baseUrl);
        login.getUserName().type(this.testdata.userDocumentM)
    
        })
     
    })
    `
  • f

    famous-magician-10206

    12/30/2022, 2:56 PM
    error is
  • g

    gray-kilobyte-89541

    12/30/2022, 6:49 PM
    it is inconvenient, https://glebbahmutov.com/blog/code-coverage-for-nextjs-app/#tests-in-a-separate-repo
  • d

    dazzling-yak-59200

    12/30/2022, 7:42 PM
    Hi, I'm testing an extensive workflow in an application that starts with opening a form in a new tab from the main screen, filling out the form and submitting it. Part of the Javascript submit logic is closing the new tab and going back to the main screen in the previous tab. Then I have to check if the submitted form data is part of a task list in the main screen and if the task list prevents me from completing the specific task because I'm the submitter. The essence of the test is checking if the business logic on the server in the last step is correct, so I can't mock data in the task list and have to complete the whole process in one test from the client (imo). Basically I'm testing the application like I'm an user without any shortcuts. I've managed to stub window.open so that the form url is opened in the primary Cypress tab, but I can't seem to stub window.close (which is part of the submit javascript logic) in the same fashion. I've a couple of questions: - is stubbing window.close even possible (because there are plenty of window.open examples but I could not find any window.close examples) and how do I get back to the baseUrl (cy.visit and cy.go seem to generate an error when used in a stub)? - in certain situations it appears like the window.close Javascript call (without stubbing) 'closes' the primary Cypress tab after submitting the form, and the baseUrl is displayed again (which could solve my problem because the baseUrl is the main screen), but this could also be some side effect. Is redisplaying the baseUrl when window.close is called from Javacript default Cypress behavior?
  • f

    full-intern-54710

    12/30/2022, 8:17 PM
    Thank you very much !
  • g

    gray-kilobyte-89541

    12/30/2022, 8:49 PM
    yes, you should be able to stub
    window.close
  • s

    some-lifeguard-48779

    12/31/2022, 4:30 PM
    Happy new year! My gitlab CI pipeline can´t visit localhost:3000. How can i fix this?
    Copy code
    ui-chrome-tests:
      image: cypress/base:latest
      stage: test
      script:
        - npm install
        - npm install -g wait-on 
        - npm install -g cypress
        - npm install -g serve 
        - npm run generate
        - serve .output/public/ & 
        - wait-on http://localhost:3000 
        - npm ci
        - cypress run
    #gitlab #localhost
  • c

    curved-pager-86474

    01/01/2023, 11:28 AM
    Hi everybody. Happy New Year. Could anybody help me to resolve this error? Thank you in advance
  • h

    handsome-lion-1748

    01/01/2023, 11:58 AM
    Hi, I'm setting a cookie (login using api) but it's not being set (as I can see in the application tab in dev tools chrome) although I enabled cookie debug and it showed a cookie set message, what can I do?
  • h

    handsome-lion-1748

    01/01/2023, 11:59 AM
    This was working on localhost but I tweaked my code to work on online testing server and it is not setting the cookie
  • h

    handsome-lion-1748

    01/01/2023, 12:03 PM
    I commented out the
    domain
    part of the setCookie command and the cookie now is being set
  • h

    handsome-lion-1748

    01/01/2023, 12:03 PM
    however my test is till having problems because I need to set local storage to the correct domain and I can't figure how yet
  • h

    handsome-lion-1748

    01/01/2023, 12:05 PM
    I think I have something similar to this https://github.com/cypress-io/cypress/issues/3177 I'm checking
  • h

    handsome-lion-1748

    01/01/2023, 12:27 PM
    It's setting local storage and cookie now but it's also keeping the baseUrl in the localStorage and cookie (not like the manual test behavior) even after cy.clearCookies so my test is still failing and I'm getting errors from server because I'm not authenticated correctly
  • h

    handsome-lion-1748

    01/01/2023, 12:35 PM
    I tried closing cypress and starting it all again and the test is working fine now :/ this is the second time this happens since I change the code a lot while cypress is running it fails the test!
  • h

    handsome-lion-1748

    01/01/2023, 12:36 PM
    Actually I tried again now and the test failed, I guess it's flaky 😑
  • h

    handsome-lion-1748

    01/01/2023, 12:41 PM
    I closed cypress and ran it again and the test passed, this is really confusing, the authentication worked fine, can this be from our app? Anybody has any feedback?
  • h

    handsome-lion-1748

    01/01/2023, 1:46 PM
    I worked through the issue with the dev and after looking on the network requests it turned out the first time cypress is run the test is logging in but when I rerun the test there's no login call and this may be the issue! I don't understand why the test is not running from the start! I'm using cucumber pre-processor I'll try to add all code in the same step
  • b

    bored-kitchen-98972

    01/01/2023, 2:19 PM
    Hello everyone. I was using cypress for some time few versions ago. Now I want to get back to this and want to create a template that is using Cucumber with predefined step definitions that are reusable. As far as I can see latest version of cucumber preprocessor is not supporting reusable step definitions. I wasn’t able to find any other solution. Does anyone solved this issue or not?
  • f

    freezing-piano-2792

    01/01/2023, 4:04 PM
    > As far as I can see latest version of cucumber preprocessor is not supporting reusable step definitions. Are you referring to shared / common step definitions?
  • b

    bored-kitchen-98972

    01/01/2023, 5:00 PM
    @freezing-piano-2792 exactly, this is what I meant.
  • f

    freezing-piano-2792

    01/01/2023, 5:11 PM
    It does support that and it’s explained in the docs
  • b

    bored-kitchen-98972

    01/01/2023, 5:15 PM
    After answering you I started checking it again and it looks that I misunderstood the concept.
  • b

    bored-kitchen-98972

    01/01/2023, 5:16 PM
    So, as I understand I should follow the structure mentioned here: https://github.com/badeball/cypress-cucumber-preprocessor/blob/master/docs/step-definitions.md#example-2-directory-with-common-step-definitions
  • b

    bored-kitchen-98972

    01/01/2023, 5:16 PM
    Am I correct?
  • f

    freezing-piano-2792

    01/01/2023, 5:21 PM
    Yeah
1...177178179...192Latest