https://cypress.io logo
Join Discord
Powered by
# i-need-help
  • Cypress Map Function
    a

    aloof-minister-25561

    03/09/2023, 2:23 PM
    Hi, I am new to Cypress but not in JS. I was using the map function in cypress and found out that the map for Cypress takes 2 arguments which is same as JS, but the first argument in Cypress is index and 2nd one is Element. But it's the reverse in JS. Can someone please explain why is that so? -------------------------------------------------------------------------------------------------------------------------------------- Cypress(taken from the cypress docs):- map((index, element) => { cy.log(el) }) --------------------------------------------------------------------------------------------------------------------------------------- JS(take from MDN docs):- map((element, index) => { /* … */ })
    g
    d
    • 3
    • 8
  • Cypress-cucumber async steps are not working
    q

    quaint-battery-7856

    03/09/2023, 5:38 PM
    I have a strange problem with using async keyword with the cucumber steps in cypress-cucumber-preprocessor. I have tested cypress promises on clean browserify + typescript configuration and it's works ok. But when I do same thing with cypress - step are not starting and stucks in infinity loading.
  • React router useHistory.push
    b

    brave-doctor-62978

    03/09/2023, 10:04 PM
    Has anyone successfully found a way to support the router using history.push for navigation?
    h
    p
    • 3
    • 5
  • Cypress update a text input's value, whilst preserving react onChange events
    m

    many-holiday-68742

    03/10/2023, 4:20 AM
    I have a simple text input, where instead of using .type() to enter characters 1 at a time to get text into an input, i want to insert a bunch of characters all at once, essentially imitating what happens when a user pastes text into an input. i've tried doing this:
    Copy code
    ts
    import { mount } from 'cypress/react18';
    const onChange = cy
          .stub()
          .as('onChange')
          .callsFake(moo => {
            console.log('onChange called', moo);
          });
        mount(
          <input type="text" data-testid="moo" onChange={onChange} />,
        );
        cy.get('[data-testid="moo"]').invoke('val', 'how now brown cow');
    This test succeeds in updating the input's current value, but does not trigger React's onChange event. 😦 Is there a way to update the input's value, and also trigger React's onChange event at the same time?
    g
    • 2
    • 1
  • Intercept request and use statusCode in condition
    a

    adventurous-garden-6944

    03/10/2023, 9:09 AM
    this code is not working, i dont know how to use a condition for the status code
    m
    g
    • 3
    • 6
  • Cypress not scrolling
    f

    flaky-australia-20559

    03/10/2023, 11:11 AM
    Hello everyone! I'm new to Cypress and I walked into a mayor error that I cannot seem to solve. The problem is here that after a click Cypress automatically scrolls to the element, that's fine, however when I want to scroll to the top or to the covered element2 it simply does not do it like that. I've tried these things so far:
    Copy code
    TS
    .scrollIntoView() (after this it's still covered, however it does scroll, just not enough)
    cy.scrollTo('top');
    cy.scrollTo('center');
    cy.get('.sidebar').scrollTo('top');
    Does anyone know a different way of scrolling upwards?
    e
    b
    b
    • 4
    • 4
  • Assert text with random part in the middle of it.
    m

    mammoth-fall-22117

    03/10/2023, 1:04 PM
    Hello, Thanks for looking here 😄 I am using this command: cy.contains(some_string); Now the string I pass to assert looks this way "This is the text that I want to assert". I can't predict the content of but I want to assert if the sentence appeared. I can split it into two assertions steps but I don't like that. Any ideas how could I pass this "randomness" to my assertion?
    g
    • 2
    • 2
  • Testing vanilla JS web components
    m

    mysterious-tomato-62265

    03/10/2023, 1:39 PM
    Is it possible to setup cypress to test a bog standard web component? No Typescript (yet!), Webpack, or any framework! Just a web component as boring as:
    Copy code
    class Default extends HTMLElement {
        constructor() {
            super();
    
            this.attachShadow({ mode: "open" });
            this.shadowRoot.textContent = "Hello, World!";
        }
    }
    customElements.define('acme-default', Default); I've literally first installed Cypress this morning. I've gone through getting started. If I use the app (from
    npx cypress open
    ) and choose the component testing, it asks if I want to use one of the frameworks to do this. Then moves onto picking web pack. I've struggled to find what I need for this simple scenario. Thanks Paul
  • Cypress code coverage
    k

    kind-eve-72052

    03/10/2023, 2:49 PM
    Hello! Question when generating code coverage using
    @Cypress/code-coverage
    for multiple spec/test files run with
    cypress run
    does it generate code coverage for all these files or just the last one? I am seeing code coverage reset step at the beginning of each test file so I am worried it might not be collecting the data for all tests which is what I need in this situation.
    g
    • 2
    • 1
  • Cypress Component testing x NextJS x Stitches: css variables not accessible in testing environment
    m

    modern-flower-30680

    03/10/2023, 3:28 PM
    Hi ! Has anyone set up Cypress component testing in a** NextJS** app that uses Stitches? Me and my team followed these guidelines to set up Stitches in our NextJS app: https://stitches.dev/blog/using-nextjs-with-stitches The issue is that the variables defined in the stitches.config.ts are not accessible in Cypress' testing environment. Hence, the components are styled properly except for everything that uses a variable (colours etc) defined in the theme. Because the guidelines recommend inserting Stitches css into the Next app by doing this >
    <style id="stitches" dangerouslySetInnerHTML={{ __html: getCssText() }} />
    I can't think of a way to load the content of getCssText() properly into the testing environment, whether using the
    cypress/support/component.tsx
    file or the
    cypress/support/component-index.html file
    Has anyone ran into this situation before and successfuly solved it? Thank you in advance!
  • Using data from .csv files #need#help
    q

    quiet-answer-70986

    03/10/2023, 8:52 PM
    I have a test case scenario where I have more than a million data in .csv . I’m using those as a parameter and using it as a variable in my Api endpoint. The problem occurs, whenever there are more than 500 data in the .csv file. The webserver returns 502. However, when the data is less than 500, the test runs perfectly. What should be the best practice to cover all the data for the test scenario. @best-flower-17510
    b
    m
    • 3
    • 8
  • How Can I Disable Browser Alert Confirmation In Cypress?
    r

    red-toddler-79937

    03/11/2023, 4:51 AM
    Hi, sometimes my Cypress tests give this warning (see image). And then I have to manually press the blue button in order to continue the test. How can I disable this in Cypress?
    h
    • 2
    • 1
  • Issue with Send me a push duo factor push notification
    b

    best-stone-6612

    03/11/2023, 11:44 AM
    I am trying to automate the DUO factor authorisation. Step 1: Visit the login url - enter username and password then click sign in. - Pass Step 2: After the successful login, it redirects to the duo factor push notification screen where the cross domain duosecurity iframe will load with two buttons - 'Send me a push' , 'Enter the code'. - I am stuck with this step - Not able to get the iframe and it's child elements. If I try to get the iframe in cypress run view the iframe shows only source url. it is not loading the iframe dom. Can someone please help me on this ?
    h
    • 2
    • 3
  • parallel tests
    l

    lively-balloon-98986

    03/12/2023, 11:43 AM
    Hi, i want to run my specs in parallell locally so i run the following command: nx e2e web-app-e2e:parallel --verbose --ci-build-id 1 &> /tmp/cy.output.1 -s "apps/web-app-e2e/src/e2e/freeUser.spec.js,apps/web-app-e2e/src/e2e/library.spec.js,apps/web-app-e2e/src/e2e/sanity.spec.js" & echo "Cypress run process started. The output is in the file /tmp/cy.output.1" parameter are passing with project.json file after running i am getting the following error: Cannot find configuration for task web-app-e2e:parallel someone can tell me why? how to solve it?
    p
    • 2
    • 2
  • Cypress code coverage
    a

    acceptable-angle-31500

    03/12/2023, 2:11 PM
    Hello guys, I'm having this error with my Cypress code Coverage, I'm using Vue.js3 +VueCLI This is the error : "log⚠️ Code coverage tasks were not registered by the plugins file. See support issue for possible workarounds. [@cypress/code-coverage]" Can anyone help me pls ?
    e
    k
    m
    • 4
    • 33
  • Network Requests not detected in cypress UI, but show in network tab
    h

    happy-mouse-72265

    03/12/2023, 9:34 PM
    Hi everyone, I'm running into an issue in component testing in Angular where the network requests are being sent (XHR) and are displayed in the network tab when I inspect the cypress browser, but they don't display in the left hand column of the cypress UI. This is preventing me from intercepting the xhr requests. Environment: - Cypress 12.7.0 - Google Chrome Browser - Typescript Since its a company project I cant share much of the code here, but I can probably share the component test's cypress code on request. What could be the issue?
    w
    • 2
    • 6
  • Gitlab branch info missing on cypress cloud dashboard
    a

    able-magazine-50000

    03/12/2023, 11:51 PM
    Hi everyone, I am stuck with an issue when trying to integrate my project on gitlab with cypress cloud dashboard. In order to select a default branch, I need to select my repository from the available list. Although some of the repositories are visible in the list, I cannot see my own project. I am using a cypress Business plan and using SSO for signing in. Any clues what might be going wrong? Thank you in advance for helping.
    a
    • 2
    • 5
  • Reset password functionality using link on email
    r

    rhythmic-dress-36825

    03/13/2023, 8:44 AM
    I want to to test Reset Password scenario . there is reset password button which sends a mail for it. I want to click on the reset password link coming on email through cypress.we tried mailosaur cypress plugin and we are not able to fetch the api as well.Is there a workaround or hacky solution to get the reset password link from email?
    g
    • 2
    • 1
  • Native purchase for stripe when button is in iframe
    h

    happy-queen-3022

    03/13/2023, 9:06 AM
    When clicking the button "Pay with link" on checkout which is coming dynamically through stripe which is in iframe, it opens the link in a new window which makes it’s harder to test it out. If I try to stub the link and open it in our window, it just throws ‘something went wrong’ on the page. The button is for native purchase and it is coming from stripe itself having a different url each time and if I get the url and try to do cy.visit() on that url as well, it just throws ‘something went wrong’ error. Any workarounds or a hacky solution for it?
    m
    • 2
    • 2
  • Where to test?
    p

    polite-lunch-8069

    03/13/2023, 12:49 PM
    Recently I quit my last project where I was manager of Cypress. Even though I still want to progress in writing tests and learn Cypress with my friend. Do you guys know any good websites where we can test freely? Is it legal to maybe test websites like Amazon, Facebook etc.? I know we can write our own app but right now I don't really want to waste time on it. Maybe you guys already have solutions :)
    g
    m
    • 3
    • 6
  • Intercept
    b

    bland-oil-21931

    03/13/2023, 2:55 PM
    Did you know that you can call intercept function before visiting the page?
    g
    • 2
    • 1
  • MSSQL Connection using Cypress
    c

    colossal-table-38461

    03/13/2023, 6:58 PM
    Hello All, I am working on Microsoft SQL Server connection in Cypress, but I am getting the below error. Attaching the screenshot for understanding. Could you please share the work-around or solution for it ? After adding the port details in env.db (in config .js file) I am getting Socket hang up error. @gray-kilobyte-89541 , @powerful-orange-86819 , @nutritious-restaurant-91514 , @acceptable-hamburger-48790
    g
    • 2
    • 2
  • Integrating Cypress with IBM DB2
    m

    millions-soccer-91794

    03/13/2023, 8:54 PM
    I'm having a lot of test data build up in tables and I wanted to figure out a way to delete these tables in my tests, I use IBM DB for where my test data is being stored, was wondering if there is anyone who has connected their Cypress to IBM and can work with tables that could help me out.
  • Error from cy.visit
    c

    clever-night-39043

    03/14/2023, 4:33 AM
    Hi all I am capturing
    headers
    from api request by cy.wait. It was working before, and the code is basically copied from Cypress document:
    Copy code
    describe('test', function () {
        let headers;
        beforeEach(function () {
            cy.intercept(userApi).as('request');
            cy.visit('/')
            cy.wait('@request').its('request.headers').then((headers) => {
                headers = headers;
            })
        });
        it('test', function () {
            ...
        })
    But I get this error:
    Copy code
    > Cypress detected that you returned a promise from a command while also invoking one or more cy commands in that promise.
    The line it points to is
    cy.visit()
    Any idea why this would happen? Thanks
    m
    g
    • 3
    • 3
  • i am running parallel tests in the cloud but i am getting only 1 machine instead of 3
    l

    lively-balloon-98986

    03/14/2023, 11:44 AM
    what can be the reason?
    e
    a
    s
    • 4
    • 13
  • Any way to wait for Loading of last event of Web Page so that we can allow cypress perform..
    i

    incalculable-rainbow-43330

    03/14/2023, 12:48 PM
    Actually, we are getting timeout issues and the problem is our cypress is running faster than web application (angular) so is there any way we can wait for the last event in the web page to load so that all the html/css and event handlers are loaded before executing cypress... we tried to make cypress wait for certain elements by checking for visibility etc., but due to some reasons its not working any suggestion is highly appreciated
  • Cypress custom commands type script help
    r

    red-diamond-5625

    03/14/2023, 3:37 PM
    Hey All. I created this custom command for google recapture in the
    commands.ts
    file Cypress.Commands.add('confirmReCAPTCHA', () => { // Wait until the iframe (Google reCAPTCHA) is totally loaded return cy.get('iframe') .first() .its('0.contentDocument.body') .should('not.be.undefined') .and('not.be.empty') .then(cy.wrap) .find('#recaptcha-anchor') .should('be.visible') }); I get the following error "Argument of type '"confirmReCAPTCHA"' is not assignable to parameter of type 'keyof Chainable'.ts(2345)" , whats wrong am I doing here ? This was working fine with JavaScript , issue seems to be with TypeScript now that we switched. I cannot call the command in my cy.ts spec
    e
    b
    • 3
    • 3
  • Assertion Error
    i

    important-hydrogen-23885

    03/14/2023, 4:14 PM
    Hey there. So I m new to cypress and getting error in datepicker part in assertion section , I don't know if i followed correct steps or not. i hope please help me to sort out with this error. Thank you.
    b
    • 2
    • 4
  • Cypress doesn't load modal but manually if loaded
    a

    adventurous-policeman-97274

    03/14/2023, 4:22 PM
    Hello everyone. I'm having a problem with a test. The scenario in summary is the following: I arrive at a checkout, I give him pay. A modal is displayed with a 'loading' and after about 4 seconds some input appears to enter a code sent to the mail. That happens whenever I run it manually in an incognito window... but when I run my test with Cypress, the modal with 'loading' is displayed but the inputs to enter the codes never appear. Do you suddenly have any idea where the issue is going and how it could be solved? What I have shown is that I do not know why in Cypress there are no calls to services that I think are what causes the input to be loaded. I am attaching images to help me understand better.
  • What is the equivalent of console.log() for cypress GHA?
    f

    faint-ocean-92094

    03/14/2023, 7:28 PM
    Some of my tests pass headless and on the runner but fail on the pipeline. I want to debug but I can't get any logs to print on the runner. What should I use to add logs to the github actions running logs? I mean while the tests are running on the pipeline.
    m
    • 2
    • 1
1...141516...26Latest