https://cypress.io logo
Join Discord
Powered by
# i-need-help
  • Separate tsconfig for cypress configuration
    b

    big-dinner-62817

    02/02/2023, 5:18 PM
    I have a monorepo setup with multiple react applications. I have cypress.config.ts at the root of the monorepo, and each project has its own
    tsconfig.json
    (which extends from
    ./packages/tsconfig
    - but that's besides the point). I want to have a
    tsconfig.cypress.json
    or a way to keep cypress' tsconfig separate. I am inclined to think that this can be configured in the
    setupNodeEvents
    option of
    cypress.config.ts
    - however, I can't find clarity on what I should do. That being said, the RWA example has a
    tsconfig
    in the cypress folder. I tried that and it didn't work - is there something I have to do to point cypress to a specific tsconfig in a specific location? I'd appreciate some pointers in the right direction.
  • App url redirects
    e

    early-book-33004

    02/02/2023, 5:35 PM
    Hello guys i'am having a problem with my E2E Automation. I login on a login component from a different team, then i'm redirected to my app i do some stuff and on the mid of the flow i am redirect to another component from another team that re-uses the same data on the browser. The problem is during test execution it fails the authentication. But i am able to do it manually and i am able to open a new tab in cypress and reuse the same url and also perform it manually. Thanks in advance , hope someone can give me some insights.
    c
    g
    • 3
    • 7
  • Cypress Tasks Failing Suddenly
    c

    chilly-needle-94710

    02/02/2023, 5:39 PM
    My Cypress tests are suddenly failing at trying to run tasks that have worked up until today. The tasks were built in a plugins/index.js file and looks like they were imported to the new config when they migration happened. But these tests and tasks worked on the version of cypress I have installed for what it’s worth. I’ve tried updating my version of Cypress locally as well but no dice. Was there a breaking change to how these tasks are set up and I need to address perhaps? Didn’t see it in the change log but perhaps I missed something.
    c
    • 2
    • 7
  • Custom asserts on Studio
    c

    colossal-hair-89675

    02/02/2023, 6:33 PM
    Hello everyone, I would like to help to improve this project creating custom assets for cypress studio. I couldn't find the process to do it. Can someone give me a tip?
    b
    • 2
    • 4
  • Overwrite command to do a followup action?
    l

    late-planet-4481

    02/02/2023, 8:55 PM
    I need some syntax help. I have a custom command
    cy.waitForSpinner()
    that waits for the loading animation to disappear (if it exists). I would like to overwrite
    cy.click()
    to execute this after every click. I've tried a few ways of doing this, but I don't know the proper syntax to make it work. This doesn't work:
    Copy code
    Cypress.Commands.overwrite('click', (click, ...args) => {
      return click(...args).then(() => cy.waitForSpinner())
    })
    What's the right way to do this?
  • How to chain custom commands in for loop?
    b

    best-lunch-5240

    02/02/2023, 9:53 PM
    I have a custom commands created:
    cy.createUser()
    which implementation looks like this:
    Copy code
    Cypress.Commands.add('createUser', (user: User, userNumber: number) => {
        user.name = `User ${userNumber}`
        cy.request({
            method: 'POST',
            url: '/createUserEndpoint',
            body: user,
            headers: {
                authorization: 'token'
            }
        }).then(response => {
            return response.body;
        });
    });
    Copy code
    declare global {
        namespace Cypress {
            interface Chainable {
                createUser(user: User, userNumber: number): Chainable<void>;
            }
        }
    }
    And in the test to create let's say 3 users one after another I have to do this:
    Copy code
    import { userData } from '../../fixtures'
    let user: User = JSON.parse(JSON.stringify(userData));
    
    it('test', () => {
        cy.createUser(user, 1)
          .createUser(user, 2)
          .createUser(user, 3);
    )};
    But is it possible to create a custom command which would chain these commands inside it? Something like:
    Copy code
    Cypress.Commands.add('createUsers', (user: User, usersNumber: number) => {
        for (let i = 1; i < usersNumber+1: i++) {
            user.name = `User ${userNumber}`
            cy.request({
                method: 'POST',
                url: '/createUserEndpoint',
                body: user,
                headers: {
                    authorization: 'token'
                }
            }).then(response => {
                return response.body;
            });
        }
    });
    And in the test I would like to have:
    Copy code
    import { userData } from '../../fixtures'
    let user: User = JSON.parse(JSON.stringify(userData));
    
    it('test', () => {
        cy.createUsers(user, 3);
    )};
    But this code doesn't work the way I would expect it to. Cypress sends a request with the same data of the last iteration so with Body: {...,"name":"User 3",...} Is it possible to implement one cystom command which would chain multiple commands on each other for a given number? How to do it?
    b
    • 2
    • 6
  • Does any one know how to handle redirect, when link is generated after hitting button to redirect?
    k

    kind-memory-80031

    02/02/2023, 10:19 PM
    I have a button element that I interact with and it opens another page. That page link though is not exactly the same every time, since generated UUID is passed as one of the URL parameters. Is there a way to handle this?
    e
    • 2
    • 2
  • Cypress 12.5.0 lodash bundle typescript error
    g

    great-oil-15113

    02/02/2023, 10:42 PM
    Hi I have just upgraded my Cypress to the latest version of 12.5.0. I noticed that there seems to be something wrong with Cypress._. Typescript is complaining about some methods not found whereas the script still works. Is there anything wrong with the type definitions? Thanks
    c
    • 2
    • 2
  • Clicking button in iframe does not add additional options to another dropdown in the iframe
    q

    quaint-airplane-96634

    02/03/2023, 9:29 AM
    We have a toolbar in an iframe, We have one + (Add) button, which adds additional options to the highlighted dropdown, It works fine manually, but does not work with cypress test, I am able to click on the + button inside the iframe, But its adding require options to the dropdown. [Please refer the screenshot]
  • Issues with cy.origin (cypress 12)
    g

    gentle-mechanic-51366

    02/03/2023, 9:36 AM
    I'm having some issues with cy.origin (cypress 12) the test passes in open mode, but fails in headlees
    b
    n
    • 3
    • 3
  • Gitlab pipeline returns error after migrating to Typescript
    b

    bored-baker-20372

    02/03/2023, 10:02 AM
    We migrated from JS to TS. Before on JS. We were not encountering any error before on JS, after migration to TS that's where the errors came in. Hoping that someone has encountered this before as well Stackoverflow link: https://stackoverflow.com/questions/75333540/gitlab-pipeline-returns-error-when-using-import This is the error we encounter on git push (we use Gitlab btw)
    Copy code
    Oops...we found an error preparing this test file:
      > cypress/e2e/fetchcookie/fetchCookie.cy.ts
    The error was:
    Error: Webpack Compilation Error
    ./cypress/e2e/functions/login.ts
    Module not found: Error: Can't resolve '@fixture/userAuto.json' in '/usr/src/app/cypress/e2e/functions'
    resolve '@fixture/userAuto.json' in '/usr/src/app/cypress/e2e/functions'
      Parsed request is a module
      using description file: /usr/src/app/package.json (relative path: ./cypress/e2e/functions)
    g
    • 2
    • 1
  • Setup complex API data in before without promise hell
    b

    broad-analyst-94821

    02/03/2023, 10:17 AM
    Cypress 12.5.0 Our server may take a while for certain API calls. So we got flakiness often between tests as some processes hadn't completed. I tried out
    cypress-promise
    to allow for use of
    async
    await
    actions to avoid promise hell. It works locally but fails in
    beforeAll / before
    in the pipeline How can I avoid promise hell? There are more complex calls that depend on the result of previous calls for the setup between tests.
    g
    l
    p
    • 4
    • 16
  • Changing status/result of a spec through plugin
    h

    hundreds-library-57018

    02/03/2023, 10:32 AM
    Is there a way of changing spec result from a plugin? we're working on a test quarantine plugin to skips tests that meet certain critereas
    b
    g
    +2
    • 5
    • 6
  • Github Actions CI - VPN
    a

    ancient-beach-22254

    02/03/2023, 12:08 PM
    I'm using github actions to create a test pipeline, but to run the routines I use the approval base that is only available on the corporate network and to access externally it is necessary to have a VPN. When the action runs, it fails to communicate with my base. Does anyone know how I can proceed?
    b
    • 2
    • 1
  • Help needed.
    c

    cold-author-79999

    02/03/2023, 2:55 PM
    I created few tests.They are running fine in local. Why do they fail in jenkins?
    e
    b
    n
    • 4
    • 3
  • Headers for SharedArrayBuffer
    d

    dry-battery-91871

    02/03/2023, 3:49 PM
    Our application makes use of SharedArrayBuffer, which requires the following headers to be added to the server:
    Copy code
    "Cross-Origin-Opener-Policy", "same-origin"
    "Cross-Origin-Embedder-Policy", "require-corp"
    Without the headers, when attempting to run tests in Chrome, the following error appears:
    Copy code
    (uncaught exception) ReferenceError:
    SharedArrayBuffer is not defined
    In Cypress 10 (specifically 10.3.1), we placed these headers in the following file: Cypress/10.3.1/Cypress/resouces/app/packages/server/lib/server-base.js. This allowed us to run tests in Chrome successfully. However, we have migrated to Cypress 12.4.0, which does not seem to have this file. Where should the headers be placed in Cypress 12.4.0? We added the flag enable-features=SharedArrayBuffer to the launch options in cypress.config.ts, but it either negates or is negated by the other two flags needed to enable visualization in our app (enable-features=Vulkan and enable-unsafe-webgu) depending on which order the flags are set, so we cannot use the flag.
  • Cypress - Access web-cam
    l

    loud-leather-28859

    02/03/2023, 6:20 PM
    Hello Everyone, Our web-app has a feature of taking a picture using a web-cam for identity verification. Currently, we don't have an option to upload a file. I am trying to automate this feature using Cypress but facing this issue. Issue: The app throws a message saying "Couldn't access camera. Please allow access to your device's camera" Troubleshooting: I've tried the below options to resolve this issue but none of them seem to be working 1. Based on the Cypress documentation , a default set of chrome switches are being passed before the browser is launched, among them we have '--use-fake-ui-for-media-stream' and '--use-fake-device-for-media-stream**' which would fake the UI/Device. I've filtered them in the config file. launchOptions.args = launchOptions.args.filter((arg) => { return arg !== "--use-fake-device-for-media-stream" && arg !== "--use-fake-ui-for-media-stream" }) 2. Also, the browser does not throw a prompt asking for camera permissions. In the cypress documentation it specifically says a switch has been added that would 'Disables prompts requesting permission to use devices like cameras or mics'. On researching, found that the corresponding switch for this is '--use-fake-device-for-media-stream' 3. Tried using an open-source library (https://github.com/kamranayub/cypress-browser-permissions) for setting the camera permissions. 4. I've tried the same feature in Webdriver using the same Chrome version (v109) and it does prompt for camera permissions. Data Cypress version: 10.3.0 Chrome version: 109 I cannot share the source-code. Any suggestions are appreciated.
    r
    • 2
    • 1
  • Can't get Cypress Studio running
    t

    thousands-kilobyte-34127

    02/03/2023, 8:01 PM
    I have spent hours pouring through youtube tutorials and the cypress website trying to cypress-studio running. I do not have a repo, but I can provide SC if that would help. Current setup: OS: Ubuntu 20.04 (VM) Node: 18.14.0 Cypress 12.5.1 I have the cypress config.js set just to enable cypress studio, so it's a short file currently (This is the config file the cypress UI points to when I go to settings)
    Copy code
    const { defineConfig } = require("cypress");
    
    module.exports = defineConfig({
      e2e: {
        experimentalStudio: true
      },
    });
    But when I run
    npx cypress open
    and get to the e2e tests, the option to add a new test does not appear! What am I doing wrong?
    a
    • 2
    • 3
  • --record --key unable to get local issuer certificate
    b

    big-secretary-95832

    02/03/2023, 8:54 PM
    I just upgraded from 10.9.0 to 12.5.1 version and I cannot run my scripts against my record key. I get the error "unable to get local issuer certificate" I am running the following command npm test "test": npm run scripts || npm run posttest "scripts": cypress run --env configFile=qa --record --key --browser chrome My project id is set in cypress.config.js and I double checked under project settings that I am using the correct record keys. also i have attempted to create a new key and get the same results. when I remove the --record --key from my scripts everything runs fine. Has anyone run into this issue and been able to resolve it?
    a
    • 2
    • 1
  • Cypress(v12) Nuxt (v2) Props not working
    p

    prehistoric-stone-17757

    02/03/2023, 9:16 PM
    Hello, i uploaded a picture of my current test - component.js of cypress - nuxt component. In my component test I want to pass props to my nuxt component. Current behaviour, the component renders with the default props and not with the custom ones from the test. Do you see any mistakes I made, maybe in the component.js? Since the docs are lacking if working with vuetify and nuxt. Docs: https://docs.cypress.io/guides/component-testing/vue/examples#Passing-Data-to-a-Component https://docs.cypress.io/guides/component-testing/vue/examples#Replicating-the-expected-Component-Hierarchy https://docs.cypress.io/guides/component-testing/vue/overview#Nuxt
    b
    w
    • 3
    • 4
  • How can I make absolute path work in Cypress?
    b

    billions-king-35651

    02/04/2023, 1:17 PM
    I intend to be able to import my component like: import Component from "@/src/Component" Then, I can go ahead and test but I am getting an error which states: Cannot find module '@/modals/wallet/CreatePin' or its corresponding type declarations.
    b
    • 2
    • 1
  • Bitbucket CI works super slow
    s

    straight-pencil-91170

    02/05/2023, 7:20 AM
    for some reason locally all the automation is running super fast, but on bitbucket CI, it always reach the 2 hour limit after few tests, which all of them combined take like 2 min, anyone encountered in something like that? I'm also getting an error that says: Container 'docker' exceeded memory limit.
    a
    b
    • 3
    • 4
  • Github actions connection issue
    a

    adamant-printer-77643

    02/05/2023, 5:33 PM
    Hi, I have a simple github actions workflow that does the following: 1. Clones the backend laravel repo and frontend Vue3 repo 2. Runs:
    php artisan serve --host=127.0.0.1 --port=1234 &
    3. Checks the server status using curl:
    curl -vv http://127.0.0.1:1234
    (it returns the correct default page of the api) 4. Runs cypress:
    Copy code
    - name: Cypress run
          uses: cypress-io/github-action@v5
          env:
            API_BASE_URL: http://127.0.0.1:1234/
          with:
            start: npm run dev
            wait-on: "http://127.0.0.1:1234/"
    5. The cypress command fails on `http://127.0.0.1:1234/ timed out on retry 91 of 3, elapsed 90245ms, limit 90000ms`' in github actions. Any ideas on how I can debug this further? Thanks!
    m
    a
    • 3
    • 10
  • Browsers will not fire the load event until all stylesheets and scripts are done downloading.
    s

    strong-wolf-38676

    02/05/2023, 6:47 PM
    Hello I try cy.visit('https://www.saucedemo.com/') but it opens only first time. Than some data cache up and another open this website with a cypress testing script stuck on load. Error below at timedOutWaitingForPageLoad (https://www.saucedemo.com/__cypress/runner/cypress_runner.js:137290:72) at (https://www.saucedemo.com/__cypress/runner/cypress_runner.js:138264:16) From previous event: at Context.visit (https://www.saucedemo.com/__cypress/runner/cypress_runner.js:138263:61) at wrapped (https://www.saucedemo.com/__cypress/runner/cypress_runner.js:151118:43) From Your Spec Code: at Context.eval (webpack:///./cypress/e2e/test.login.cy.ts:11:13) I tryed solutions from this website https://github.com/cypress-io/cypress/issues/2938 and nothing works. Only when I manually delete C:\Users\\AppData\Roaming\Cypress\cy\production\browsers\ and there folder for the proper browser, than I have one new clear run when the website is successfully loaded.
  • Verifying downloaded files don't seem to work anymore
    s

    straight-chef-47891

    02/06/2023, 12:28 AM
    I don't use plugins to verify downloaded files but my tests just stopped working with these lines:
    Copy code
    js
    const downloadsFolder = Cypress.config('downloadsFolder');
    const path = require('path');
    cy.readFile(path.join(downloadsFolder, fileName)).should('have.length.greaterThan', 0);
    Not sure if its a chrome thing too.
  • Verify javaScript redirects to email
    g

    great-oil-15113

    02/06/2023, 12:52 AM
    Hi All My application uses javascript redirects to open an email client with subject, body, link etc. For example,
    Copy code
    <html>
      <button id="email">Email</button>
      <script>
        document.querySelector('#email').addEventListener('click', () => {
          window.location.href = 'mailto:?subject=XXXXXX&body=YYYYYYlink:%20https:/localhost:12345/id'
        })
      </script>
    </html>
    I don't want the email client to open and need to verify the content of the email when click the button. Is there a way to do that? Thanks
  • How to use websocket protocol
    m

    mysterious-psychiatrist-29678

    02/06/2023, 10:14 AM
    I'm trying to connect to Kubernetes API, especially its exec functionality, and that requires procotol change from HTTP to websocket. Calling cy.reqest() as normally I'd do it can't handle protocol change and gives error 400 status . Do you have any idea how to manage, please? request:
    Copy code
    cy.request({
          method: "POST",
          url: url,
          failOnStatusCode: false,  
          headers: {
            authorization:
              "Bearer " + token,
          },
        }).then((resp) => {
          expect(resp.status).to.eq(200);
        });
    response:
    Copy code
    {
      "kind": "Status",
      "apiVersion": "v1",
      "metadata": {},
      "status": "Failure",
      "message": "Upgrade request required",
      "reason": "BadRequest",
      "code": 400
    }
  • FormData with File
    s

    swift-morning-54751

    02/06/2023, 3:25 PM
    I've got a test where I'm uploading a file, but when I try to assert on the request, I'm getting an empty JSON object. I looked at the actual network request, and it is posting fine as
    form/multipart
    but because it has binary data included in a field, the entire request doesn't seem to be presenting well in Cypress. How do I either parse the request so that I can assert on the
    multipart
    text or work around this somehow? Using Cypress 12.2.0, working with React and e2e tests. I've tested the flow outside of Cypress and everything works as expected.
    • 1
    • 1
  • Cypress Authentication with pop up token password
    b

    brief-pencil-55035

    02/06/2023, 3:56 PM
    Hi all, i need to test my website the thing is that i have a security pop up window with password i need to insert (it is like a usb flash drive token with pass) - is there a way to bypass this and get in the website itself to test it? or can i make cypress to catch this pop up window somehow and input the passcode? thank you in advance!!!
    b
    n
    • 3
    • 2
  • Upgrading Cypress 9 to 12
    r

    rhythmic-agency-74865

    02/06/2023, 4:57 PM
    Hello I am having issues upgrading my cypress project from version 9 to 12 after using npm install latest to get 12 version. When I run cypress to open the test runner it starts trying to migrate my files but never completes the process. Is this a known issue with a work around or fix? Is there a way to completely remove cypress 9 from my project and have it recreate all of the new files for cypress 12? Thank you all for your time...
    p
    a
    • 3
    • 2
1...567...26Latest