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

    square-fountain-93217

    07/27/2021, 3:58 PM
    Hey everyone, I'm having an issue with a test. I have a button that when clicked displays a list with more info, and I want to click an element within that list. My problem is that my button has elements inside it, so I get an error about using
    {multiple: true}
    . The problem with that is that when I pass that option, as it clicks sequentially the first click shows the list and the subsequent ones close it, so I can never
    get()
    the element I want inside the list.
  • b

    bulky-sundown-74498

    07/27/2021, 4:00 PM
    can you get your button with the supperpowers of cy.contains?
  • b

    bulky-sundown-74498

    07/27/2021, 4:01 PM
    cy.contains('button', 'text of your button').click()
    so that it does not bubble up?
  • s

    square-fountain-93217

    07/27/2021, 4:17 PM
    Thanks!
  • s

    square-fountain-93217

    07/27/2021, 4:17 PM
    Would you mind explaining a little bit why that worked or what was I doing wrong? 😬
  • b

    bulky-sundown-74498

    07/27/2021, 4:19 PM
    It really depends on how your apps code is structured. My guess was that when you click on an item inside the button, the button gets a reaction too.
  • b

    bulky-sundown-74498

    07/27/2021, 4:21 PM
    Cypress needs a unique element to click on so if you give it multiple icons/spans/ dom elements it will not find this unique element and trigger click on multiple elements🤪
  • b

    bulky-sundown-74498

    07/27/2021, 4:21 PM
    By using contains, you force it to click on the container, hence clicking only once
  • s

    square-fountain-93217

    07/27/2021, 4:30 PM
    Ok, makes sense. Thanks a lot!
  • u

    user

    07/27/2021, 4:51 PM
    I saw that, the body of the iframe changed and using that workaround Cypress doesn't seem to know that the content changed and will keep a reference to the old iframe data instead of the new one
  • a

    ancient-wire-34126

    07/28/2021, 8:33 PM
    Is there a reason why these two commands would not execute synchronously?
    Copy code
    ts
      before(() => {
        console.log('1. login')
        cy.loginByCognitoMock(utils.LOGIN_EMAIL_OWNER)
    
        console.log('2. profile')
        cy.visit('/account/profile')
      })
  • a

    ancient-wire-34126

    07/28/2021, 8:38 PM
    Hm, this might have a different cause
  • a

    ancient-wire-34126

    07/28/2021, 8:41 PM
    ah, Cypress isn't intercepting anything for some reason... well that clears it up
  • r

    rhythmic-army-81251

    08/02/2021, 7:48 PM
    it looks like I have multiple instances of dayjs when running cypress, is there any way to combat this?
  • r

    rhythmic-army-81251

    08/02/2021, 7:48 PM
    e.g. in my support/index.ts I have
  • r

    rhythmic-army-81251

    08/02/2021, 7:49 PM
    Copy code
    ts
    import dayjs from 'dayjs';
    import 'dayjs/locale/en-gb.js';
    
    beforeEach(() => {
      dayjs.locale('en-gb');
    });
  • r

    rhythmic-army-81251

    08/02/2021, 7:49 PM
    in my spec I have
  • r

    rhythmic-army-81251

    08/02/2021, 7:50 PM
    Copy code
    ts
    describe('x', () => {
      it('should', () => {
        cy.log(dayjs.locale()); // prints en
      });
    });
  • w

    wooden-refrigerator-71139

    08/03/2021, 11:28 AM
    Hi 👋 I'm trying to run Cypress e2e and Cypress component tests on the same project. I've set up instrumentation and coverage reports but my component tests report is overwriting the e2e report I tried changing the report-dir in nyc, but this changes it for both reports so they're still being overwritten. Is there a way to change the report-dir for just component tests? Any help appreciated, thanks in advance!
  • a

    ancient-wire-34126

    08/03/2021, 2:23 PM
    Is there a way for Cypress to pick up TS paths in the bundler? I never use webpack and not really looking forward to have to configure that in two places?
  • a

    ancient-wire-34126

    08/03/2021, 3:05 PM
    No matter what I do, webpack never seems to be able to resolve aliases 😦
  • a

    ancient-wire-34126

    08/03/2021, 3:08 PM
    oh it has a Vite one as well, let me check that
  • a

    ancient-wire-34126

    08/03/2021, 3:09 PM
    oh that's for component testing 😐
  • r

    rhythmic-army-81251

    08/03/2021, 5:17 PM
    Is it resolving the dir correctly? Usually we've had to use path.resolve(__dirname, '../utils')
  • r

    rhythmic-army-81251

    08/03/2021, 5:18 PM
    We also have switched to running vite though for the e2e tests
  • a

    ancient-wire-34126

    08/03/2021, 5:25 PM
    Cypress is a bit of a black box at this point for me. The lob Vite under component testing, but I'm unsure how to use it internally for e2e tests?
  • a

    ancient-wire-34126

    08/03/2021, 5:25 PM
    I just run my dev server and cypress separately, since it uses a different script
  • u

    user

    08/04/2021, 5:19 PM
    Hi. Can someone hep me with Cypress and Github actions? I'm using pnpm as package manager and I cant configure pipeline: Error:
    Copy code
    sh
    Error: ENOENT: no such file or directory, open '/home/runner/work/myapp/package-lock.json'
    Action:
    Copy code
    yml
          - name: E2E tests
            uses: cypress-io/github-action@v2
            with:
              install-command: pnpm install
              start: |
                pnpm start:server &
                sleep 10 &&
                pnpm start &
                sleep 10
              wait-on: 'http://localhost:4200'
    How can I switch to the
    pnpm-lock.yaml
    instead of
    package-lock.json
    ?
  • b

    bitter-london-76358

    08/04/2021, 11:09 PM
    Hey All. Can someone help me understand how to test for the existence of values in localStorage in an e2e test? I have a use case similar to: https://stackoverflow.com/questions/58847002/how-to-assert-localstorage-in-cypress Where I want to check that a value exists in local storage after we have been logged in. I can see the value in localStorage in dev tools while the test is running. The problem is that the test passes every time regardless of whether or not I'm checking if
    getItem
    is returning
    null
    or not, leading me to believe this is not working since it should in theory fail on a null check. Here is a snippet:
  • b

    bitter-london-76358

    08/05/2021, 4:05 PM
    update: this helped me resolve my issues for anyone experiencing something similar https://www.npmjs.com/package/cypress-localstorage-commands
1...293031...252Latest