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

    magnificent-finland-58048

    05/26/2022, 4:50 PM
    before e.trigger(click)
  • r

    red-toddler-79937

    05/26/2022, 4:52 PM
    ```ts specify('Unit test add items to shopping basket.', () => { cy.findAllByTestId('add-item-to-cart').each((e) => { let i = 0; e.trigger('click'); cy.get('.cart-size').first().should('have.text', "-->" + i++); // eslint-disable-next-line no-console console.log(i); }) }) ```Actually this makes less sense to me because now let i will be reasigned to 0 on each iteration.
  • m

    magnificent-finland-58048

    05/26/2022, 4:57 PM
    you're right, too much multi tasking here
  • r

    red-toddler-79937

    05/26/2022, 4:58 PM
    no worries πŸ˜„
  • r

    red-toddler-79937

    05/26/2022, 5:02 PM
    Also I forgot to share this screenshot, might give some more context to the issue.
  • m

    magnificent-finland-58048

    05/26/2022, 5:14 PM
    is it possible to share some code?
  • r

    red-toddler-79937

    05/26/2022, 5:31 PM
    ```ts specify('Unit test add items to shopping basket.', () => { new Cypress.Promise((resolve) => { let i = 0; cy.findAllByTestId('add-item-to-cart').each((e) => { e.trigger('click'); i++; }) .then(() => { cy.get('.cart-size').first().should('have.text',
    ${i}
    ); return resolve(i); }) }) }) ```I fixed it like this, I'm not sure if this is wack.
  • r

    red-toddler-79937

    05/26/2022, 5:31 PM
    also thx for the help, I dont think i would've been able to figure it out without you
  • r

    red-toddler-79937

    05/26/2022, 5:31 PM
    that actually was the whole code, unless u meant something else
  • m

    magnificent-finland-58048

    05/26/2022, 5:48 PM
    working repo
  • m

    magnificent-finland-58048

    05/26/2022, 5:49 PM
    I'm happy you figured out, couldn't do too much to help Filip has a Cypress vs Playwright showndown, and I'm trolling the chat
  • m

    magnificent-finland-58048

    05/26/2022, 5:49 PM
    it's burning my afternoon πŸ˜‚
  • r

    red-toddler-79937

    05/26/2022, 5:58 PM
    😨
  • r

    red-toddler-79937

    05/26/2022, 5:58 PM
    dont worry about it, thx again! πŸ˜„
  • r

    red-toddler-79937

    05/27/2022, 12:37 AM
    ```ts describe("Restaurants' categories", () => { specify('Unit test if restaurant is closed.', () => { cy.findByTestId('closed-widget').then(($e) => { if ($e.text().includes('Restaurant Closed')) { return; } }); }); .... more tests here.... }); ```Hi, does anyone know how I can skip all tests of the
    describe()
    if
    $e.text().includes('Restaurant Closed')
    is
    true
    ?
  • r

    red-toddler-79937

    05/27/2022, 12:38 AM
    Because I have unit tests that checks adding products and checking cart info etc. But if the restaurant is closed then those checks shouldn't happen else it will crash. Also please @ping me so I can reply faster if you can help.
  • r

    rapid-airport-48908

    05/27/2022, 2:14 AM
    look at the accepted reply here (#3) https://stackoverflow.com/questions/54530318/skipping-a-test-in-cypress-conditionally
  • g

    gray-kilobyte-89541

    05/27/2022, 5:35 AM
    remove the Promise, you don't need the promise there at all
  • r

    red-toddler-79937

    05/27/2022, 11:55 AM
    Without the promise 'i' stays 0 when I need it.
  • r

    red-toddler-79937

    05/27/2022, 11:56 AM
    see thisβˆ†
  • r

    red-toddler-79937

    05/27/2022, 12:00 PM
    I will take a look, thank you!
  • b

    bitter-apple-86316

    05/27/2022, 4:20 PM
    @magnificent-finland-58048
  • b

    bitter-apple-86316

    05/27/2022, 4:20 PM
    Onclick button redirected to new tab.
  • b

    bitter-apple-86316

    05/27/2022, 4:20 PM
    How to handle it
  • b

    bitter-apple-86316

    05/27/2022, 4:21 PM
    Note: there is no target attributes found
  • b

    bitter-apple-86316

    05/27/2022, 4:26 PM
    Please respond for above one
  • b

    bitter-apple-86316

    05/27/2022, 4:26 PM
    @gray-kilobyte-89541
  • s

    salmon-magazine-24441

    05/27/2022, 5:30 PM
    Hi , We have been using cypress for our end to end testing on our web applications using AWS Cloudfront. In the process of restricting access to our cloudfront URL's, we were able to protect access by using cloudflare Access (zero trust security) to only few people of our team. But we were not able to bypass /authorize access to cypress to access our application. Is there any way to make this happen? using a service auth token that we have generated in cloudflare access dashboard ?
  • m

    magnificent-finland-58048

    05/27/2022, 5:39 PM
    https://glebbahmutov.com/blog/cypress-second-tab/ https://filiphric.com/opening-a-new-tab-in-cypress you can search for it on the upper right most questions have been answered
  • r

    red-toddler-79937

    05/27/2022, 10:32 PM
    Hey, does someone know how I can check if an element "might" exist? I mean, without throwing an error, but instead returning 'null' or
    true
    or
    false
    or something? I tried
    queryBy
    but it isn't supported by
    cypress testing library
    .
1...444546...192Latest