https://cypress.io logo
Join Discord
Powered by
# i-need-help
  • Re-try failed test cases
    w

    wonderful-carpenter-84941

    03/23/2023, 8:04 PM
    Hello everyone! I want to re-run only failed test cases one the 1st run is finish and if there are any failure 2 run should only the failed test cases. I had this in pytest using
    --last-failed
    is there a way to achieve this in cypress? ( I'm already aware of https://docs.cypress.io/guides/guides/test-retries in cypress but it retries the test case as soon as it fails )
  • Cypress Microsoft authentication Help!!
    c

    chilly-queen-22182

    03/23/2023, 10:13 PM
    there is code when this authenticate button is clicked its navigate to Microsoft browser in a new window, Is there any way I can tackle it with Cypress, I know cypress origin command but its not work in different browser, Is there any trick I can manipulate to automate this please, Please help
  • How to simulate drawing with pointer-events?
    m

    magnificent-waiter-2215

    03/24/2023, 10:49 AM
    Hello folks! I'm attempting to test OSD-Annotorious using Cypress, and my goal is to draw a figure by clicking and dragging over an element. I've tried using
    trigger()
    with pointer events, but haven't been successful so far. Do you have any suggestions or tips on how to simulate a click-and-drag action in Cypress that would allow me to draw the desired figure? Any help would be appreciated!
    Copy code
    it('Should draw a rectangle', { scrollBehavior: false }, function () {
      cy.visit('https://recogito.github.io/annotorious/getting-started/');
    
      cy.wait(1500);
    
      cy.get('.a9s-annotationlayer')
        .trigger('pointerdown', {
          position: 'topLeft',
          force: true,
          x: 50,
          y: 50,
        })
        .trigger('pointermove', {
          position: 'topLeft',
          force: true,
          x: 150,
          y: 150,
        })
        .trigger('pointerup', {
          position: 'topLeft',
          force: true,
          x: 150,
          y: 150,
        });
    });
  • Cypress.io test using Windows Authentication and local user account
    i

    icy-sundown-22930

    03/24/2023, 3:49 PM
    I am trying to setup Cypress.io to run tests as a local Windows user against a .NET Core web application that uses Windows Authentication. I can achieve this manually by opening the web browser to run as the local user, so I know the authentication is working. However, I'm still getting 401 when I try to run a simple test. I have successfully installed both cypress and cypress-ntlm plugin. I open Cypress using the command npx cypress-ntlm open. My test code is: describe('visit site', () => { it('passes', () => { cy.ntlm(['localhost:7136'], 'username', 'password'); cy.visit('https://localhost:7136/') }) }) What configuration/setup am I missing?
  • Best practices on creating re-usable scenarios for multiple tests
    t

    thankful-pizza-16453

    03/24/2023, 5:36 PM
    Hi! In the organisation I'm currently working in we opted for Cypress as our E2E testing tool. Lately, we're developing a mission critical feature that requires jumping among 3 different sections while compiling several forms before getting to the page I want to test. In order to speed up the test and make it more readable/maintainable, I was thinking about creating several scenarios that perform multiple requests to our BE in order to create the application state. It would look something like this: - perform a login; - create an item into the warehouse; - add it to a cart; - delete item for availabilities; then I want to the test cart and simulate a real user interaction. Everything else is just pre-populating the application state so it would be incredibly long to setup the test using the UI. Is it a reasonable approach? Are there any available resources in the official documentation I can look at? Thanks, Maurizio
    e
    • 2
    • 5
  • Running Test Suites in Parallel locally concurrently
    h

    helpful-country-95146

    04/13/2023, 2:47 PM
    I have a use case where it would help a lot if I could run several very small suites concurrently locally. The documentation mentions that it is possible, but not recommended. Each of my test suites have their own cypress.config files, and the tests themselves only run for a few seconds, but it takes a long time to spin up and close down each suite sequentially. I'd tested a bit and got a workaround using 'concurrently' while making sure each of the configs have their own folder for screenshots, run on different ports, and this works quite well. The problem is that it will occasionally just break with sporadic errors "cy.login is undefined" and such (even though they're clearly defined and usually work) As I said, this is only for a very small subset of tests, so I don't need the features of Cypress Cloud. Any ideas on the (correct / least horrible / most stable) approach for this?
  • How to capture any variable value from .js file and pass into a test case file
    r

    ripe-notebook-54640

    04/13/2023, 3:08 PM
    I am creating test data in .js file and I want to pass that test data into test cases
    c
    • 2
    • 2
  • Migrate CRA to VITE
    g

    gifted-ability-23116

    04/13/2023, 5:32 PM
    Im currently migrating a large app from CRA to VITE. When I run the cypress tests locally it is fetching 100s of files for the whole app for each test, which is really slow. Is there some config I need to change for cypress to help with the migration from CRA to VITE?
  • Reports in openMode
    n

    narrow-lizard-57235

    04/14/2023, 9:27 AM
    Is there a way to create/safe reports from e2e runs that were made in the interactive mode? I only get reports with cypress run, but not with cypress open.
    e
    • 2
    • 2
  • Is there a way to return a synchronous value ?
    b

    bumpy-insurance-8581

    04/14/2023, 9:48 AM
    Hello, I meet a big problem with Cypress sometimes. To avoid duplication code I’ve made a method that should return a value that I get like that :
    Copy code
    getTextValueFromElement(){
      let text;
      cy.get('elementClass').then($element => {text = $element.text()}
      return text;
    }
    But I meet this error message sometimes :

    https://cdn.discordapp.com/attachments/1096371322042466354/1096371322398965800/IMG_3963.png▾

    b
    g
    • 3
    • 7
  • Windows Git bash throws error
    a

    ambitious-animal-14300

    04/14/2023, 10:24 AM
    My co-worker is facing an error while trying to run cypress through vscode -> git bash (Im guessing vscode uses git bash for the git tab). I have set up the project using husky to run cypress tests before commiting (pre commit hook). Everything when manually running every single command in powershell. But when using the git tab in vscode it fails with the following error. Havent used Windows for some years, and i am not really sure whats going on. There are none
    start-cypress
    file next to
    index.jsc
    and couldnt find it anywhere in the server package. Havent been able to find any related issues.
    Copy code
    bash
    $ C:\Users\{user}\Documents\code\vue-webapp\node_modules\.bin\cypress run --e2e
    Error: Cannot find module './start-cypress'
    Require stack:
    - C:\Users\{user}\AppData\Local\Cypress\Cache\12.9.0\Cypress\resources\app\packages\server\index.jsc
        at Module._resolveFilename (node:internal/modules/cjs/loader:940:15)
        at Module._load (node:internal/modules/cjs/loader:785:27)
        at c._load (node:electron/js2c/asar_bundle:5:13339)
        at Module.require (node:internal/modules/cjs/loader:1012:19)
        at i (C:\Users\{user}\AppData\Local\Cypress\Cache\12.9.0\Cypress\resources\app\index.js:1:2232)
        at startCypress (evalmachine.<anonymous>:1:799866)
        at evalmachine.<anonymous>:1:800126
        at v (C:\Users\{user}\AppData\Local\Cypress\Cache\12.9.0\Cypress\resources\app\index.js:1:2573)
        at Object.<anonymous> (C:\Users\{user}\AppData\Local\Cypress\Cache\12.9.0\Cypress\resources\app\index.js:1:2764)
        at Module._compile (node:internal/modules/cjs/loader:1120:14) {
      code: 'MODULE_NOT_FOUND',
      requireStack: [
        'C:\\Users\\{user}\\AppData\\Local\\Cypress\\Cache\\12.9.0\\Cypress\\resources\\app\\packages\\server\\index.jsc'
      ]
    }
    m
    • 2
    • 4
  • Let CI Run component tests?
    b

    broad-wire-63018

    04/14/2023, 12:04 PM
    Hello, I can't seem to find docs or guidance on how to add my Cypress components tests to my Gitlab CI. I can't even find a package-json command to just run the tests anywhere on the web. I think I am misunderstanding something, can someone explain how I can run my tests?
    m
    • 2
    • 4
  • How to handle authentication via another site
    b

    best-flower-17510

    04/14/2023, 4:08 PM
    Hey @lively-monkey-14354 did you have any more context regarding this question?
    l
    • 2
    • 2
  • {{ steps.cypress.outputs.dashboardUrl }}
    e

    echoing-actor-29720

    04/14/2023, 7:29 PM
    Hello! Using custom command to run cypress tests with cypress-io/github-action@v5 prevents printing the dashboardUrl. Is there any way to overcome this issue? Here is how I use it: - uses cypress-io/github-action@v5 with: Install: false record: true command: $run-cypress-with-grepTags I want to keep running cypress with tags so I guess I have to use custom command. The above approach doesn’t print {dashboardUrl}
    m
    • 2
    • 6
  • fixing or ignoring code coverage on typescript and why it's helpful
    b

    busy-agency-3812

    04/14/2023, 8:39 PM
    I am trying to fix or ignore code coverage errors I've had in my cypress window for a long time:
    Copy code
    Could not find any coverage information in your application
    by looking at the window coverage object.
    Did you forget to instrument your application?
    See code-coverage#instrument-your-application
    [@cypress/code-coverage]
    Following these steps (https://docs.cypress.io/guides/tooling/code-coverage#E2E-code-coverage.) don't work for me because we're on version 12 and I think the issue is that plugins/index.js is no longer supported: https://docs.cypress.io/api/plugins/writing-a-plugin. I don't see instructions on instrumenting code coverage with cypress in typescript anywhere in the official docs We are already using jest code coverage with --coverage and it generates lcov. I'm not sure to be honest what the value of @cypress/code-coverage is and whether we can just ignore it. I do not want the warning to show up in my cypress window either way. I tried this even though we're using E2E and not component testing, no luck: https://glebbahmutov.com/blog/component-code-coverage/ also https://github.com/bahmutov/cra-ts-code-coverage-example Does anyone have any suggestions? Happy to follow up w/ questions about my package.json or anything. Babel is in my project already.
    g
    • 2
    • 9
  • Is there a way to calculate the code coverage with the nextjs turbopack rather than webpack
    b

    better-carpenter-12966

    04/15/2023, 4:29 AM
    Is there a way to calculate the code coverage in component testing with the nextjs turbopack rather than webpack.
    a
    • 2
    • 3
  • Imitate ERR_CONNECTION_REFUSED with cy.intersept or other
    c

    curved-kangaroo-10618

    04/16/2023, 4:24 PM
    need to check how website behaves with backend down
    m
    • 2
    • 1
  • cypress/jest/TL conflict
    l

    late-agency-82724

    04/16/2023, 6:22 PM
    Hi everyone! i'm having problem when i use cypress in combination with jest and testing library, i'm getting type errors when using jest-dom matchers as shown in the screenshot below. any idea on how to correct this conflict?

    https://cdn.discordapp.com/attachments/1097225533076557844/1097225533584052234/Sans_titre.png▾

    r
    • 2
    • 7
  • How to npm link the cypress package?
    f

    fresh-zebra-34262

    04/17/2023, 2:22 AM
    I have read the contributing readme.md and it does not say anything about this. I I am new to open source contributing and was wondering how one would use the cypress packages that they changes in a real cypress application for testing purposes. I have forked the main cypress repo and applied some changes to it and I would like to see if those changes caused any issues on a dummy application that is using cypress I heard about using npm link on a package, then applying that package elsewhere, but I am getting an error Photo 1 is me applying npm link the cypress project with changes that I made Photo 2 is me getting the link from a different project Photo 3 is me running cypress in that different project

    https://cdn.discordapp.com/attachments/1097346357393641562/1097346357775302776/image.png▾

    https://cdn.discordapp.com/attachments/1097346357393641562/1097346358098280508/image.png▾

    https://cdn.discordapp.com/attachments/1097346357393641562/1097346358358331482/image.png▾

    m
    • 2
    • 1
  • Order of executed tests in mochawesome report
    p

    proud-vegetable-5507

    04/17/2023, 9:17 AM
    Hey everyone..I have a question..When I run all my tests I can see in console that all runs in expected order.But in mochawesome report firste executed test results written in the last row and the rest written in expected row..is there any solution about it.. Thanks in advance.
    b
    • 2
    • 2
  • Testing router events in cypress component testing
    r

    rich-rain-38719

    04/17/2023, 2:09 PM
    Hello everyone, I have details that should be opened (as angular secondary router-outlet) after clicking on an item, I would like to check that it works fine with cypress component testing. Is it possible?
    b
    • 2
    • 1
  • Passing Javascript objects to Cy.origin()
    s

    some-zoo-23167

    04/18/2023, 12:56 AM
    Hi All, I am trying to pass JavaScript class object created to cy.origin function but it’s always coming up as function not defined. // loginPage.js Class loginPage(){ Login(){ //code} } Const Obj= new loginPage() export default Obj; // ///Test script Import Obj from loginPage.js it(‘Should login to inventory page’, () =>{ cy.visit(something) cy.origin(){ Obj.login(); } }) Getting error function not defined. How do I pass the object from the JavaScript class to the cy.origin function?? #1064946933187235880 #763114122065739818
    m
    • 2
    • 2
  • Best Practices: Custom commands assertions & supplying test data
    p

    proud-ice-52191

    04/18/2023, 5:47 AM
    Questions: Which is considered more efficient or better in general regarding these two? 1. When you run a custom command to create something, do you run assertions within the command or inside the test case where the command is being used? 2. When you supply test data to supposedly create a new entity (say from a fixture), is it recommended to do that on the test (it) block level or within the custom command used? Example: A command used to create new 'products' & 'customers' etc
    Copy code
    Cypress.Commands.add('createNewEntity', (entityType, entityData) => {
        // Customize the API endpoint based on the entity type
        let endpoint;
        let modal;
    
        // Code here to manage endpoint and the create form modal 
    
        // Intercept the create request
        cy.intercept('POST', env.baseUrlAPI + endpoint).as('createRequest');
      
        // Fill in the form fields based on the entity data
        // cy.get(modal).within(() => {
          Object.entries(entityData).forEach(([labelText, value]) => {
            cy.fillField(modal, labelText, value);
          });
          cy.get('data-testId='create-button').click({ force: true });
       // });
      
        // Close the create modal and wait for the response
        cy.get('.mdi-close').click();
        cy.wait('@createRequest').its('response.status code).should('eq', 200);
    
        // Verify that the entity was created
        // extra assertions code goes here.
    Now for instance I can now call this inside my tests using
    Copy code
    // to be loaded by data from the customer fixture
    
    // Create a new entity
      cy.createNewEntity('customer', {
          'first name': 'Test',
          'last name': 'Tests',
          'email': 'test001@test.com',
          'phone': '0923823525',
          'location': '32a Test',
          'password': '12345678',
          'confirm password': '12345678',
             });
    This works, however, I am not entirely sure if it is recommended, what are your thoughts?
    e
    e
    • 3
    • 4
  • Cypress.require used with cy.origin gives node error
    r

    red-jordan-59778

    04/18/2023, 6:40 AM
    How are you all ? Cypress version used - 12.9.0 I'm trying to do this in my cy.origin code of my CRM and getting below error - Can someone here suggest right usage? cy.origin('https://xxx-dynamics.com/', () => { const contactPage1 = Cypress.require('./ContactPage.js'); CypressError cy.origin() failed to run the callback function due to the following error: Processing the origin callback errored: TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received undefined at new NodeError (node:internal/errors:399:5) at validateString (node:internal/validators:163:11) at Object.dirname (node:path:1276:5) Cypress documentation advises me to use like this - https://docs.cypress.io/api/commands/origin const utils = Cypress.require('../support/utils')
    m
    b
    • 3
    • 24
  • Intercept Cypress traffic with Burpsuite
    b

    busy-author-51492

    04/18/2023, 11:19 AM
    I'm trying to intercept traffic with burpsuite using cypress, but i'm obtaining this error: "This browser was not launched through Cypress. Tests cannot run." I don't knwo how to solve this problem, some fixed that I have tried: - Use foxyproxy in firefox -> Same error - Set HTTP_Proxy and NO_PROXY variable -> Same error - Set Proxy in the test.cy.js using the function cy.request -> Same error The proxy in burp is set to 127.0.0.1:808X. Any ideas on how to fix this problem?
    m
    b
    • 3
    • 4
  • Implementing Cypress App Actions
    g

    gray-exabyte-2941

    04/18/2023, 5:20 PM
    Hello, I am relatively new to using Cypress and I am currently trying to determine if POM or Cypress app actions would be best to implement. I've read a few articles explaining the differences between the two and the pros/cons of each. The consensus seems to favor app actions, however, this is a new concept for me, and I'm wondering if Cypress app actions can be used on legacy code. From what I learned, the app would need to be exposed using
    if (window.Cypress) {window.model = model }
    in the application code and then using
    cy.window().its(‘model’)
    to call the internal logic within my spec file. Is exposing the application something that a developer can easily add to existing files without much effort or would it be best for me to implement POM in this scenario?
    a
    • 2
    • 7
  • Cypress shows outdated cached version of our app after navigation
    p

    proud-breakfast-29892

    04/18/2023, 6:20 PM
    We used cy.session for a while, so each test started cleared of outdated cache. However, we have a limitation that forced us to not use it. Now, the testing proccess is the following: 1. We log into the system which takes us to a landing page, without cy.session (However each test the login begins again) 2. We prepare the environment via API requests 3. We use cy.visit to start the test at a speicifc page in our app The issue is that after step 3, the app displays the OLD data, prior to sending the data in our API. If we use cy.reload however, the page refreshes and we see the new data. I tried to reproduce it manually and I did not encounter it, so it looks like a cypress-only issue. Obviously, the issue is that we never refresh the cache. How can we do it without cy.reload? Because reload takes a lot of time in each test. Note: each test begins on a new, clean environment, so it's not an issue of not cleaning the environment from the previous test.
  • How to get my cy.task() to show correctly during Cypress tests?
    c

    curved-magician-42592

    04/18/2023, 7:24 PM
    my code in test:
    Copy code
    cy.task('show_files', __dirname).then((file) => forEach((file) => cy.log(file)))
    output:
    Copy code
    task:            show_files, cypress/integration/tests
    my task code:
    Copy code
    on('task', {
        show_files(directory) {
        return fs.readdirSync(directory);
    }
    
    }
    My custom cy.task
    Copy code
    show_files()
    works but I can't get my Cypress logs to list the contents of my directory. fs.readdirSync() returns an Array. How can I loop through the returned Array to show each element in Cypress? I spent 8 hours on this ticket and I can't figure it out.. :[
  • Using conditionals (if else)
    g

    green-elephant-92285

    04/18/2023, 10:32 PM
    I have a simple test that I cannot seem to solve. I want to basically check if an element is visible or not. If element is visible, do xyz. Else do something else. The problem I’m facing is that cypress times out in the if block. It will try to look for the element and fail. It never reaches the else block like I want it to. I’ve tried using jquery but none of the elements have any static properties. All properties and classes are generated. And we don’t use id properties either. So I’m stuck in a hole. I’m not sure what the best way to tackle this. Any advice is appreciated.
    g
    p
    b
    • 4
    • 13
  • Overriding alias value results in a "Maximum call stack size exceeded" Error
    p

    proud-breakfast-29892

    04/19/2023, 10:07 AM
    cy.get('someSelector').as('someAlias') // later in the code cy.get('@someAlias') .find('someOtherSelector') .as('someAlias'); Before V. 12, this worked fine, now I get "Maximum call stack size exceeded".
1...171819...26Latest