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

    calm-doctor-58650

    12/03/2021, 6:53 PM
    Access to Account
  • c

    calm-doctor-58650

    12/03/2021, 7:04 PM
    Cypress testFiles configuration
  • c

    calm-doctor-58650

    12/03/2021, 7:07 PM
    Hey Dante. First off, curious how you're testing React Native with Cypress. Are you running in a browser? Would love to know more about your setup. As for your question, it's important to ensure that the DOM will not reload between the cy.get() and whatever action is following. You'll need to make sure that whatever behavior is triggering the reload has completed before querying for the element to ensure it will not detach. If you can provide a reproducible example I may be able to help provide some more guidance, but in general that is the approach to take for detached from DOM issues.
  • a

    ancient-wire-34126

    12/03/2021, 7:24 PM
    In Component Testing, is there a way to assert an element is of a specific component type, like VTU's
    findComponent
    ?
  • w

    wonderful-match-15836

    12/04/2021, 4:13 PM
    You can use
    findComponent
    itself, since the vue test utils wrapper is available under
    Cypress.vueWrapper
    . Would that work for you?
  • a

    ancient-wire-34126

    12/04/2021, 10:17 PM
    Ahhh, excellent, thanks!
  • h

    high-salesmen-41114

    12/06/2021, 9:54 AM
    Hi Ceclia!, it turned out that the issue is just in the console - typing actually works with
    \\
    . See it here: https://www.loom.com/share/d3b96bce76e54dc3acfad09435d99227 All the backslashes are stripped out when logging or checking what happened.
    Copy code
    /// <reference types="Cypress" />
    
    describe('Backslash', function () {
    
      it('Can\'t type backslash', function () {
    
        // Login
        cy.visit('https://getbootstrap.com/docs/4.0/components/forms/', { onBeforeLoad: (win) => { win.sessionStorage.clear() } })
        cy.get('#exampleInputPassword1').type('F-tNzk^*%\\<{0qWs&MPc')
        cy.log('F-tNzk^*%\<{0qWs&MPc');
        cy.log('F-tNzk^*%\\<{0qWs&MPc');
        cy.log('F-tNzk^*%\\\<{0qWs&MPc');
    
      })
    
    });
  • p

    proud-room-838

    12/06/2021, 12:03 PM
    Hi, how on earth should I use helper functions placed in a common javascript file to use in multiple cypress test files? They're not really general Cypress command but rather helper functions to generate some uniqe values for some of my tests.
  • p

    proud-room-838

    12/06/2021, 12:03 PM
    I've imported a js file from support/index.js and tried to call the funtions listed in that js file but they aren't available in my spec files.
  • p

    proud-room-838

    12/06/2021, 12:19 PM
    Ok I solved it but I don't know why it works
    Copy code
    cy.myproject.addLeadingZeroIfNeeded = function(number) {
    Had to add cy.myproject in order to be able to use it. Why's that?
  • c

    creamy-train-56346

    12/06/2021, 1:11 PM
    hey! mistake on my end - the question was obviously about React JS app 😅 I'm assuming that your answer is applicable for this kind of software as well, so I will still refer to it. Said list is suppose to have any number of entires, so I wanted to make test dynamic - tried to grab a list all at once, iterate through it's elements and delete them. But since DOM is being rebuilt, Cypress loses his head in between iterations. I get that. I think I will solve it with
    data-test
    attributes for each entry in the list. It will let me stay dynamic in my approach. Thanks! And sorry for not satisfying your curiosity about react native app test setup 😉
  • c

    calm-doctor-58650

    12/06/2021, 6:25 PM
    Haha I was very intrigued! And yes, grabbing the head once and then iterating will cause issues because the head will detach. But yes using
    data-test
    attributes is what I'd suggest, because you know exactly which element you're getting each time.
  • c

    calm-doctor-58650

    12/06/2021, 6:31 PM
    Hey retrobear, you should just be able to import the functions into your spec files, like in the slides here. (https://slides.com/bahmutov/page-objects-in-cypress#/4) If that's not working, could you share your setup? Hard to understand based on the description.
  • c

    calm-doctor-58650

    12/06/2021, 6:41 PM
    Just as a heads up, I will be taking a break over the next week so if anyone pings me directly or tags me in a post and doesn't get a response it's because I'm AFK. 😎 Happy testing everyone!
  • w

    wooden-balloon-68677

    12/06/2021, 10:32 PM
    Hi is there any chance that in newest version cypress keeps localStorage between tests? Cause my tests started to fail and I tracked the issue to input which value is based on localStorage from previous test. When I run only this test so it don't have predecessor - it works.
  • w

    wooden-balloon-68677

    12/06/2021, 10:37 PM
    If I added
    window.localStorage.clear();
    in my
    beforeEach
    it works. But it suppose to work without it: https://docs.cypress.io/api/commands/clearlocalstorage as stated in docs
  • w

    wooden-balloon-68677

    12/06/2021, 11:13 PM
    So unfortunately I found what causes issue: https://github.com/cypress-io/cypress/issues/2695
  • w

    wooden-balloon-68677

    12/06/2021, 11:13 PM
    There is no fix for that
  • p

    proud-room-838

    12/07/2021, 8:03 AM
    Alright, it works as described in Gleb's slides but only if I import the helper.js from the spec.js file directly, not if I import it into index.js in order to avoid having to import it into every spec.js file. Any idea how to solve that? Hmm, maybe what I'm getting at is that I want to import functions in helper.js in one place (index.js) into global scope not having to prefix them in my spec.js. Is that possible?
  • p

    proud-room-838

    12/07/2021, 8:08 AM
    Not really a Cypress question, I know.
  • f

    flaky-television-87833

    12/07/2021, 8:57 PM
    Hi, I'm having an issue with cy.intercept not being overriden when called twice in the same test file and same url but different aliases. I tried the solution here: https://stackoverflow.com/questions/67870276/cypress-7-0-override-responses-in-intercept But it did not work for my case, it still the first cy.intercept that gets called. I am printing in this screenshot to the console directly the response of cypress. What can I do? Thanks in Advance!
  • f

    flaky-television-87833

    12/07/2021, 9:01 PM
    Cypress test code
    Copy code
    Given('I am on the "user-login" page', () => {
    
        cy.visit("http://localhost:8080/user-login")
        cy.title().should('eq',"User Login Page")
    })
    
    When('I enter "George312"', () => {
    
        cy.get('input[type="text"]').should("be.visible").type("George312")
    })
    
    And('I enter "hsj%2*sc5$"', () => {
    
        cy.get('input[type="password"]').should("be.visible").type("hsj%2*sc5$")   
    })
    
    And('I Click the "Submit" button', () => {
        cy.intercept("GET", "api/users", (req) => {
            
            req.reply(
                {
                    "body": { "isAuthenticated": true}
                }
            )}
        ).as("loginUser")
        
        cy.get('button[id="LoginBtn"]').should('be.visible').click()
        cy.wait(2000)
        cy.wait("@loginUser")
    
        
        
    })
    Then('I should see written in a window user "George312 is now logged in!"', () => {
    
        cy.get("p").contains('user "George312 is now logged in!"').should("be.visible")
    })
    
    
    
    // // // #############################################
    
    
    
    Given('I am on the "user-login" page', () => {
    
        cy.visit("http://localhost:8080/user-login")
        cy.title().should('eq',"User Login Page")
    })
    
    When('I enter "George312"', () => {
    
        cy.get('input[type="text"]').should("be.visible").type("George312")
    })
    
    And('I enter "hsj%2*sc5$3"', () => {
    
        cy.get('input[type="password"]').should("be.visible").type("hsj%2*sc5$3")   
    })
    
    And('I Click the "Submit" button', () => {
        cy.intercept("GET", "**/api/users/**", (req) => {
            
            req.reply(
                {
                    "body": { "isAuthenticated": false}
                }
            )}
        ).as("loginUserWrong")
        
        cy.get('button[id="LoginBtn"]').should('be.visible').click()
        cy.wait(2000)
        cy.wait("@loginUserWrong")
    
        
        
    })
    Then('I should see written in a window user "Login Failed! wrong password"', () => {
    
        cy.get("modal").contains("Login Failed! User is not registered")
    })
  • f

    flaky-television-87833

    12/07/2021, 9:12 PM
    I found a solution here too: https://glebbahmutov.com/blog/cypress-intercept-problems/#no-overwriting-interceptors but it is using normal cypress code and I am using cypress-cucumber-preprocessor which makes this solution not useful. Sorry for the long text. I still need help if possible.
  • a

    ancient-wire-34126

    12/07/2021, 9:20 PM
    Why does Cypress not support
    {space}
    as a keyboard command? It's a pretty widely-used key to trigger things like dropdowns (and really any other focussable DOM element)
  • a

    ancient-wire-34126

    12/07/2021, 9:43 PM
    I guess
    type(' ')
    will do lol
  • c

    calm-gpu-44530

    12/08/2021, 9:01 AM
    Hi, I'm having issues with cypress logs in github actions since version 7. Any advice on a fix?
  • u

    user

    12/08/2021, 4:57 PM
    Hi everyone hope you are doing well. for some reason I'm getting
    ECONNREFUSED
    with both firefox and chromium, I'm using
    cypress 9.1.1
    on popOs I though it was a misconfiguration in my project but I'm having the same issue with the cypress-example-recipes repo as well. I've used it on multiple projects but first time being blocked by that. here is an excerpt of the error:
  • c

    cuddly-winter-72122

    12/08/2021, 9:32 PM
    @User these logs are expected, you are seeing Cypress trying 3 times to connect to Chrome, then succeeding
  • c

    cuddly-winter-72122

    12/08/2021, 9:32 PM
    there is no error here
  • t

    tall-airplane-97209

    12/08/2021, 10:05 PM
    Can't say I've seen that and I use github actions extensively... might be best to upgrade to Cypress 9.x though and see if it's reproduceable.
1...404142...252Latest