https://cypress.io logo
Join Discord
Powered by
# i-need-help
  • Vue Component testing
    c

    crooked-branch-31688

    05/10/2023, 12:26 PM
    Hello guys! Here is my situation: I would like to add component testing to my app, however it seems like that I can't handle the store syntax in .vue files. For example I have the following part in the component: {{content.text}} . Looks like with mounting I need to feed cypress this syntax somehow. I would appreciate any kind of help here. Thanks!
  • Navigate through categories until the end level category is reached
    b

    brief-kite-35331

    05/10/2023, 12:41 PM
    I have a category menus, each category has subcategories and so on. There can be various levels of categories and their subcategories. I am trying to write a cypress script that would click on the random category and then random subcategory all the way til the end level category which doesn't have anymore subcategories. This is what I have now, but it doesn't work:
    Copy code
    Typescript
    Cypress.Commands.add('getRandomFromList', { prevSubject: true }, (subject) => {
      return cy
        .wrap(subject)
        .should('have.length.above', 0)
        .then(function ($items) {
          return Cypress._.sampleSize($items.toArray(), 1);
        });
    });
    
     goToRandomCategory() {
        cy.get('#homepageCategories ul').getRandomFromList().click();
      }
    
      goToRandomEndLevelCategory() {
        this.goToRandomCategory();
        this.goToRandomSubCategory();
      }
    
      goToRandomSubCategory() {
        cy.location('pathname').should('include', '--c'); // to ensure that the category page is loaded
        cy.get('[itemtype*="SiteNavigationElement"]:nth-child(2) > ul').then((subcategories) => {
          if (subcategories.length > 0) {
            cy.wrap(subcategories).getRandomFromList().click();
            this.goToRandomCategory();
          }
        });
      }
    It only clicks the homepage category and opens first level category but doesn't go further then that. The weird thing is that it shows category list, I can see it but the trace says the elements are not visible :/ Can you please help 😄 ?

    https://cdn.discordapp.com/attachments/1105836979695915038/1105836979846914068/image.png▾

    g
    • 2
    • 15
  • Running Cypress Tests in Cloud Build
    r

    red-diamond-5625

    05/10/2023, 2:43 PM
    Is it possible to run cypress tests in Cloud Build ? I checked the cypress documentation , i cant seem to find an example where you are running cypress tests in Cloud build. https://github.com/cypress-io/cypress-example-kitchensink#ci-status
    a
    m
    • 3
    • 12
  • New to Cypress - Need help in setting up Cypress for API test automation.
    p

    prehistoric-television-46163

    05/11/2023, 1:52 AM
    #958013993425960971 I am new to Cypress and trying to automate API test cases. I am unable to find any documentation and videos with latest changes of Cypress to start with API set-up. I have installed all dependencies and cypress. Created API test cases under e2e folder since there is no Integration folder available. When i try executing it is always showing cypress welcome screen with E2E and component testing options and browser to select. Please help me with set-up and configurations anything needs to be added for API test automation. Thanks
    w
    • 2
    • 4
  • Help!
    b

    blue-river-76581

    05/11/2023, 12:09 PM
    : hello, I need to import a file into a zone: I ask him to read the file, he reads it but when I ask to select it. it gives me an error: here is my code and my tree

    https://cdn.discordapp.com/attachments/1106191353991401573/1106191354893172837/image.png▾

    https://cdn.discordapp.com/attachments/1106191353991401573/1106191355266469948/1.PNG▾

    https://cdn.discordapp.com/attachments/1106191353991401573/1106191355560067194/2.PNG▾

  • Example in "Types for Custom Commands" documentation gives TypeScript errors
    e

    elegant-insurance-66438

    05/11/2023, 2:38 PM
    The example here https://docs.cypress.io/guides/tooling/typescript-support#Types-for-Custom-Commands gives multiple TypeScript errors. - Augmentations for the global scope can only be directly nested in external modules or ambient module declarations.ts(2669) - ES2015 module syntax is preferred over custom TypeScript modules and namespaces.eslint@typescript-eslint/no-namespace - Type 'Chainable' is not generic.ts(2315)

    https://cdn.discordapp.com/attachments/1106228797814079488/1106228797986050089/Screenshot_2023-05-11_at_16.37.49.png▾

  • Testing Expo Image Picker
    n

    nutritious-article-48038

    05/11/2023, 6:11 PM
    Hi I am working on a react native app for school and trying to learn cypress for it. I have managed to do some basic testing but I am not sure how to test the expo image picker in my app.

    https://cdn.discordapp.com/attachments/1106282480283168838/1106282480442548294/Capture.PNG▾

  • How to validate a session via local storage?
    e

    elegant-insurance-66438

    05/11/2023, 8:09 PM
    I am using
    cy.session
    to login a user and I need to validate the token has been set in local storage, however when using the
    validate()
    method the result from
    cy.getAllLocalStorage()
    does not contain the token item - the login is succesful though as the user is redirected as expected and that test passes. Here is my code. Cypress.Commands.add("loginViaUi" as any, (user: any) => { cy.session( user, () => { cy.visit("/public/login"); cy.get("#username").type(user.username, { log: false }); cy.get("#password").type(user.password, { log: false }); cy.get(".ant-btn").click(); }, { cacheAcrossSpecs: true, validate: () => { cy.getAllLocalStorage().then((result) => { console.log("result", result); }); }, } ); });
    e
    • 2
    • 3
  • Cypress custom command working on local but throwing error on jenkins
    q

    quick-egg-50511

    05/12/2023, 5:47 AM
    When the script is executed via jenkins, its failing with the following error "TypeError: cy.closeDrs is not a function" but the same script executes on local system. Im using JS and I don't have cypress/support/index.ts. Using cypress 12.7.0
  • Cypresse cucumber-preprocessor help
    p

    plain-potato-68806

    05/12/2023, 8:00 AM
    I am using the preprocessor https://github.com/badeball/cypress-cucumber-preprocessor and I am seeking help for the below questions. I can see the screenshot is available on the report when the tests fail. However, I would like to have a screenshot at every step. Is this configurable? In BDD-Java, usually, I can call the function because it will be inside a public void function() with an annotation. However, in Javascript it normally looks like below
    Copy code
    javascript
    Given("I am a customer", () => {
      cy.log("INFO: User Login");
      initilizeRun();
    });
    Is there any way for me to call this step when the cucumber step definition is slightly different or I need to combine multiple steps?
  • Can we load the page which returns with the header as application/pdf
    q

    quaint-airplane-96634

    05/12/2023, 8:43 AM
    What does this error mean? can we load the page which returns with the header as application/pdf:
    Copy code
    The content-type of the response we received from your web server was:
    
    application/pdf
    
    This was considered a failure because responses must have content-type: 'text/html'

    https://cdn.discordapp.com/attachments/1106501858278785044/1106501858509455370/image.png▾

  • How to prevent logging session user credentials?
    e

    elegant-insurance-66438

    05/12/2023, 10:37 AM
    I need to prevent the user credentials from being logged for security reasons - how can this be done?

    https://cdn.discordapp.com/attachments/1106530498148319314/1106530498307686420/Screenshot_2023-05-12_at_12.32.36.png▾

    e
    • 2
    • 5
  • Component Testing With Custom Dev Server - Rspack
    s

    steep-belgium-18144

    05/12/2023, 12:32 PM
    Hello, I am looking to use Cypress Component Testing with my app, which uses Rspack as its bundler. I am wondering if anyone has any good examples of configuring a custom dev server that does not use Webpack or Vite. I tried looking through the docs on using a custom dev server but they seem very vague and limited, so wondering if anyone has a good example of making this work. Thank you in advance!
  • dashboard is not compressing the videos completely
    a

    adamant-beard-17074

    05/12/2023, 5:43 PM
    example: https://cloud.cypress.io/projects/syegqm/runs/bc09ce7b-8667-41f3-a06f-a09a7756f35d/test-results/c1162f05-a708-4cdd-bcfc-e8c7e9ff155c/video
  • Github Actions
    f

    famous-dress-70846

    05/12/2023, 6:35 PM
    Hi this is my first time using github actions and I followed the instructions of cypress documentations Notes - I have a repo where I'm practicing E2E test - I'm using yarn instead of npm -this is the yml file that cypress told me to copy and paste (I only change the "npm start" for "yarn run start") - for the package.json I saw a example on cypress documentation Finally this is the error that github tell me. I followed the instructions but now I'm really lost 😦

    https://cdn.discordapp.com/attachments/1106650790766067823/1106650790996742295/image.png▾

    https://cdn.discordapp.com/attachments/1106650790766067823/1106650791252598844/image.png▾

    https://cdn.discordapp.com/attachments/1106650790766067823/1106650791516848151/image.png▾

    m
    g
    • 3
    • 10
  • unable to look up source with cypress code coverage plugin
    g

    gray-beard-8992

    05/12/2023, 9:37 PM
    I have setup the code coverage plugin and I get the report and it seems to be working fine, but I can't get into any source code files, it gives an error Unable to lookup source. I am just running this on my local environment, no docker or anything. @gray-kilobyte-89541 any ideas on why it doesn't see the sources? Do I have to specify path somewhere? Thanks
    g
    • 2
    • 1
  • DataTable in the badeball/cypress-cucumber-preprocessor
    a

    astonishing-actor-1092

    05/13/2023, 7:21 AM
    Is DataTable or at least TableDefinition in the new @badeball/cypress-cucumber-preprocessor? It seems that are not recognized. Despite the fact that I do import {When, Then, DataTable } from "@badeball/cypress-cucumber-preprocessor"; and then into the code When(/^the table of the '(.+)' modal contains the following entries:$/, (dataTable: DataTable) => { dataTable.hashes().forEach((row) => { When Cypress run I always get: "dataTable.hashes is not a function"
  • Cypress open Error
    b

    boundless-needle-41679

    05/13/2023, 4:50 PM
    I'm facing this issue with npx cypress open. Please, anyone, help Not getting the next page

    https://cdn.discordapp.com/attachments/1106986918807347381/1106986919033843842/Screenshot_from_2023-05-13_22-17-48.png▾

    https://cdn.discordapp.com/attachments/1106986918807347381/1106986919365202031/Screenshot_from_2023-05-13_22-19-27.png▾

    m
    • 2
    • 1
  • Query related to Dynamic Value Assertion
    c

    colossal-table-38461

    05/14/2023, 9:03 AM
    Hello All, I need to validate the dynamic value in Assertion, any idea how we can do that? Example: 1. Creating 1 Random Number using Math.Random() 2. Storing that value in 1 Variable 3. After processing the data need to validate that Random Number in Assertion. Currently using cy.contains() but its failing for me.
    g
    • 2
    • 5
  • cypress api delete test gives 200 instead of 204 and never delete it
    c

    cold-carpet-69043

    05/15/2023, 1:00 AM
    Hello, From api-project repo, I am able to delete customer info as it gives me 204 status code. this repo only contains api test code. However, from UI project repo, it always give me 200 instead of 204, so it never delete after creating using cy.request api. This UI project repo contains mostly UI testing codes. Is it something wrong with the cypress version? Please let me if you have similar experience and know the solution. thanks. UI project repo version: 12.11.0 api-project repo version: 10.3.1 cy.apiLogin(url, user, pass).then(response => { token = response.body.token; cy.deleteInfo(url, token, id); });
  • Getting error - Cannot find module '@badeball/cypress-cucumber-preprocessor/esbuild'
    p

    prehistoric-television-46163

    05/15/2023, 6:16 AM
    I am getting error: "Cannot find module '@badeball/cypress-cucumber-preprocessor/esbuild' or its corresponding type declarations" in cypress config file. Below is the config file details. please let me know if any issue with this. Getting error at import createEsbuildPlugin. import { defineConfig } from "cypress"; import createBundler from "@bahmutov/cypress-esbuild-preprocessor"; import { addCucumberPreprocessorPlugin } from "@badeball/cypress-cucumber-preprocessor"; import createEsbuildPlugin from "@badeball/cypress-cucumber-preprocessor/esbuild"; export default defineConfig({ e2e: { specPattern: "**/*.feature", async setupNodeEvents( on: Cypress.PluginEvents, config: Cypress.PluginConfigOptions ): Promise { // This is required for the preprocessor to be able to generate JSON reports after each run, and more, await addCucumberPreprocessorPlugin(on, config); on( "file:preprocessor", createBundler({ plugins: [createEsbuildPlugin(config)], }) ); // Make sure to return the config object as it might have been modified by the plugin. return config; }, }, });
  • Show correct line number when using Typescript?
    a

    abundant-architect-46477

    05/15/2023, 8:01 AM
    Hi, I'm using TypeScript to write my tests, but in the command log, when a test fails, the line number is off by a dozens, if not hundreds of lines. Is there a configuration I might be missing to use the write sourceMaps so that it displays the right line numbers? Thx
    m
    • 2
    • 2
  • Extending cypress.config.ts
    f

    fierce-nail-97204

    05/15/2023, 11:25 AM
    Does Cypress support this? I saw a workaround for json by Gleb. But I did not see anything for typescript.
  • Testid Never been found
    i

    incalculable-ability-58905

    05/15/2023, 12:01 PM
    Hello guys, I am new on cypress, and my work now using cypress. I still confused. I got an error said "Timed out retrying after 4000ms: Expected to find element: [data-testid="testId "], but never found it." When I looked at the code I have testId. I got confused why testId never been found?
    s
    l
    g
    • 4
    • 6
  • Cypress cloud for pr's run in github actions triggered by forks
    p

    powerful-gigabyte-69168

    05/15/2023, 2:15 PM
    I have an open source app (code: https://github.com/cuttle-cards/cuttle) that runs cypress tests in github actions when pr's are submitted and/or updated. The test runs are recorded in cypress cloud, and the record key is stored as a Github Secret that's shared with the workflow via an environment variable. This works well for PR's submitted by team members, but runs that are triggered by contributors outside of the organization do not get access to secrets in github action by default and therefore those runs are not recorded. It results in the following error message:
    Copy code
    Warning: It looks like you are trying to record this run from a forked PR.
    
    The Record Key is missing. Your CI provider is likely not passing private environment variables to builds from forks.
    
    These results will not be recorded.
    
    This error will not alter the exit code.
    Is there a standard approach to this setup i.e. where tests run in CI using github actions and get recorded in cypress cloud such that test-runs triggered by forks are recorded successfully? I could include the record key in the source code but this seems unideal as I'd prefer to only record the test runs that correspond to PR's against the main repo itself
    m
    • 2
    • 6
  • Cypress does not retry when using 'cypress run'
    a

    adorable-insurance-32249

    05/15/2023, 3:03 PM
    I've enabled retries by passing in the retries object in my cypress.config.json "retries" : { "runMode": 1, "openMode": 0 } My full command was `npx cypress run --spec My terminal never displays the second attempt in run mode. When running it in open mode with 'cypress open', I can see that retries are attempted

    https://cdn.discordapp.com/attachments/1107684717815418971/1107684717970600096/Screen_Shot_2023-05-15_at_09.28.55.png▾

  • No way to log to stdout from within a command
    g

    gorgeous-kitchen-56640

    05/15/2023, 4:53 PM
    Hi, I feel like I reached a bit of a deadend here. I am trying to get some debug output that I can evaluate to figure out some page load timeout issues I'm hitting. The way I'm trying to do this is by outputting a set of resources that have not been "loaded" by the time a page load event is reached, or in 100s after a
    visit
    command is started (whichever comes first). The issue is that, in order to output to the stdout, I am using
    cy.task('log', ...)
    , a pretty familiar pattern, I'm sure, since it's outlined in Cypress' own docs for
    cy.task
    . When this command is run within the context of a
    cy.visit
    command, it gives me this error:
    Cypress detected that you returned a promise from a command while also invoking one or more cy commands in that promise.
    (outlined here: https://docs.cypress.io/guides/references/error-messages#Cypress-detected-that-you-returned-a-promise-from-a-command-while-also-invoking-one-or-more-cy-commands-in-that-promise). There are no promises being used anywhere, so I figure the mere usage of
    cy.task
    is a violation. To me, this would indicate that there's actually no safe way to output to stdout from within the context of a command, which seems like a major shortcoming of the interface. But I'm sure I'm missing something. Example code:
    Copy code
    // plugins code
    ...
    on('task', {
      log(message) {
        // eslint-disable-next-line no-console
        console.log(message);
    
        return null;
      },
    ...
    
    // func that logs to cy.task
    function someFunc() {
      cy.task('log', 'log to stdout');
    }
    
    // func that overwrites visit
    Cypress.Commands.overwrite(
      'visit',
      (originalFn, url, options) => {
        someFunc();
    
        return originalFn(url, options);
      }
    );
    g
    • 2
    • 8
  • Run Interactive GUI test in cypress without any selection of test name
    f

    freezing-activity-66869

    05/15/2023, 6:12 PM
    Currently, i execute cypress test on headless mode so that i give exact test to run but on GUI test i need to select the test to run it with couple of user mouse clicks, is there a way we can pass run time commands to execute the cypress test in interactive GUI? Current command being used: npx cypress run --browser chrome --spec cypress/tests/client/portal/wifi/cucumber/login/login.feature
    l
    • 2
    • 4
  • Getting chromesecurity error when domain of url is getting changed as part of automation test
    f

    freezing-activity-66869

    05/15/2023, 6:24 PM
    As my test is getting executed as long as redirection to different domain is not happening it is working all good, if url changes to different domain as part of user action it is failing with error as chromesecurity. only way i can bypass is switching the flag as false for chromesecurity, is there any robust way to do that ?
  • I want to execute cypress test from desktop with a bash.sh script ( help needed)
    f

    freezing-activity-66869

    05/15/2023, 9:13 PM
    I have a bash script in the desktop executing a cypress test as follows , but even though we give the location of the test, it is requiring cypress package is available on desktop .Is there a way we can skip so that cypress package gets hosted on the inside folders itself where test files are present so that we are not duplicating cypress installation in 2 places? Bottleneck i am facing is, i need to execute the bash script by going inside the cypress folder so that test gets executed, i am trying to find a way i can run cypress test from desktop without any dependency? (Attached the bash.sh file) npx cypress-repeat -n 5 --until-passes run --browser chrome --spec 'cypress/tests/client/**/login_AP.feature' https://cdn.discordapp.com/attachments/1107777878835351593/1107777879078609020/bashAP.sh
    m
    • 2
    • 1
1...2223242526Latest