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

    red-toddler-79937

    05/28/2022, 12:07 AM
    nvm I fixed it like this:
    Copy code
    ts
        function isClosed () {
            return new Cypress.Promise<boolean>((resolve) => {
                    cy.get('.landing-page').first().then(($e) => {
                            if ($e.text().includes('Restaurant Closed')) {
                                console.log("isClosed() <----", true);
                                return resolve(true);
                            } else {
                                return resolve(false);
                            }
                        });
                });
        }
    
        let isClosedTrue = false;
        specify('Unit test if restaurant is closed', async function() {
            isClosedTrue = await isClosed();
        });
    crazy
  • r

    rapid-airport-48908

    05/28/2022, 2:38 AM
    yeah that's the same solution i used for conditional testing
  • l

    little-tiger-22751

    05/28/2022, 3:42 AM
    Headless is fine
  • l

    little-tiger-22751

    05/28/2022, 3:42 AM
    Has anyone seen this before? Auto crashing when running cypress open
  • g

    gray-kilobyte-89541

    05/28/2022, 5:24 AM
    that is not going to work, and you should not do this. Instead look at the solutions here https://glebbahmutov.com/cypress-examples/recipes/conditional-testing.html
  • r

    red-toddler-79937

    05/28/2022, 9:15 AM
    Hey, thanks for the resource! I don't know what you mean by "that's not going to work, because it does work". And the resource you gave me doesn't show any solution to my problem. I cannot see anywhere where to "SKIP" tests "IF" a certain element exists on the page. Handy resource though.
  • a

    ancient-zoo-12002

    05/28/2022, 9:56 AM
    Hey guys, did anyone have ever worked before with synpress (by snyk) or with cypress-metamask (by CraftAcademyLabs) for e2e testing on dapp with metamask wallet?? Or have any ideas on how to create e2e testing on cypress that can work with metamask wallet
  • g

    gray-kilobyte-89541

    05/28/2022, 1:01 PM
    any time you use
    async
    or
    await
    in Cypress it probably does not do what you think it does. My examples don't include skipping the rest of the test if an element exists, because ... it is weird. But you can probably derive how to do it from the examples
    Copy code
    js
    cy.get('element selector').should(Cypress._.noop).then($el => {
       if ($el.length) {
          return
        }
        // other test Cypress commands
    })
  • r

    red-toddler-79937

    05/28/2022, 1:07 PM
    I don't know what "Cypress._noop." is. Couldn't find anything on Google about it either. I could not derive a solution to my question from the examples. In my eyes await just waits for the result of the promise before continuing code execution. Which is what I need to avoid an error. Either "await" or "then". I don't understand why it would be weird? If you could elaborate.
  • g

    gray-kilobyte-89541

    05/28/2022, 1:15 PM
    See https://github.com/bahmutov/cypress-examples/commit/18f743bdea31483935f419af896db84db775aab2 and read https://glebbahmutov.com/cypress-examples/9.7.0/recipes/conditional-testing.html and http://on.cypress.io/retry-ability
  • r

    red-toddler-79937

    05/28/2022, 8:41 PM
    thanks for the resource, i will take a look when i have the chance.
  • r

    red-toddler-79937

    05/28/2022, 8:42 PM
    Copy code
    ts
                let i = 0;
                cy.get('.add-item-to-cart').each((e) => {
                    e.trigger('click');
                    i++;
                })
                .then(() => {
                    cy.get('.cart-size').first().should('have.text', ` ${i} `); // [here].
                });
    I changed my code to this.
  • g

    gray-kilobyte-89541

    05/29/2022, 6:28 AM
    Maybe write it something like this
    Copy code
    js
    // the count starts at zero
    cy.contains('#count', 0)
    // click each button
    cy.get('ul button')
      .click({ multiple: true })
      // the displayed count should equal the number of buttons
      .its('length')
      .then((n) => {
        cy.contains('#count', n)
      })
    See https://github.com/bahmutov/cypress-examples/commit/4eeb2af1f9ac56e14e9c70416d1c3a3b0cf94e00
  • r

    red-toddler-79937

    05/29/2022, 11:30 AM
    I will take a look, thanks for the example!!
  • n

    nice-restaurant-99469

    05/30/2022, 11:25 AM
    I had a similar issue on my end. This was solved by bypassing a network protection setting in Sophos (antivirus we use, company policy).
  • a

    adventurous-branch-4501

    05/30/2022, 1:30 PM
    Hi, is there anyone can help me? I have a test case for clicking banners on the website, but I have to scroll first so that the elements are loaded and clickable. I'm having trouble getting my elements to be found by cypress. Anyone have a solution?
  • m

    mysterious-photographer-32876

    05/30/2022, 3:09 PM
    Hey people. I have an issue with running cypress in a docker container. It passes tests in --browser firefox --headless but fails in --browser chrome --headless. Anything comes to mind straightaway?
  • m

    mysterious-photographer-32876

    05/30/2022, 3:10 PM
    I serve app files in nginx that cypress then navigate to
  • m

    mysterious-photographer-32876

    05/30/2022, 3:14 PM
    Are the elements in the dom?
  • i

    important-park-97069

    05/30/2022, 3:20 PM
    What are you trying
  • i

    important-park-97069

    05/30/2022, 3:20 PM
    Becuase this sounds like one of the simpler cases in Cypress -- call cy.visit to load the page, cy.get().scrollIntoView(), and then cy.click()
  • c

    calm-nail-75610

    05/31/2022, 7:24 AM
    Hi there can anyone maybe assist me i have an issue where i am getting this error 429 - too many requests
  • e

    echoing-painting-40909

    05/31/2022, 7:55 AM
    Hi, your server is protecting itself from repetitive requests in a short timelapse ( useful to prevent DDOS attacks). Either you need to update such a setting for a stage environment if you are making a lot of requests through repetitive testing, either you need to test such error as it's the success of a feature.
  • r

    rhythmic-butcher-48923

    05/31/2022, 8:14 AM
    im unsure inside github actions yml if i should use github action or docker image to run the tests, because they seem to do same thing? so im not sure based on which criteria i should pick one or another?
  • c

    curved-apple-36824

    05/31/2022, 10:08 AM
    Hi When I run a cypress test an error message is shown from the website but I can do the test manually and there are no error messages only when I run the same test via cypress its showing the error message is there a solution
  • a

    adventurous-branch-4501

    05/31/2022, 3:44 PM
    I've try using scrollIntoView() but Cypress keep saying that my elements never found.. But if I try to manually scrolling my browser (when the test running), it will success find my element
  • e

    elegant-dress-62146

    05/31/2022, 3:45 PM
    try
    scrollIntoView({force: true})
    ?
  • a

    adventurous-branch-4501

    05/31/2022, 4:04 PM
    I tried to try this and still my element is not found by cypress. maybe because it hasn't been loaded yet. because I have to manually scroll down first..
  • v

    victorious-midnight-45836

    05/31/2022, 4:33 PM
    you could try this if your elements are lazy loaded (found some time ago in percy documentation):
    Copy code
    let scrollToBottom = require("scroll-to-bottomjs");
    
    describe("Lazy loading example", () => {
      it("captures lazy loading images", () => {
        cy.visit("https://sdk-test.percy.dev/lazy-loading");
        cy.window().then(cyWindow => scrollToBottom({ remoteWindow: cyWindow }));
        cy.percySnapshot("Lazy loading images");
      });
    });
  • b

    bitter-apple-86316

    06/01/2022, 5:51 AM
    Any promo code to Cypress network testing exercise
1...454647...192Latest