https://cypress.io logo
Join Discord
Powered by
# i-need-help
  • Clean slate with the form
    b

    brief-kite-35331

    02/21/2023, 8:36 AM
    I have a spec file which tests registration and it has several it blocks (test scenarios). Some scenarios which run first leave the form populated with some values after the tests are finished. This makes problems from my later it blocks which expects the form to be in the state in which it would have been if the form was initially loaded. How do I prevent or fix this to have the clean slate for my form after my first tests have been run?
    t
    • 2
    • 9
  • cy.intercept routeMatcher with query object issue
    t

    thankful-wire-37848

    02/21/2023, 9:46 AM
    Does anyone precisely know how query param object matching in the
    cy.intercept
    routeMatcher works. The docs aren't very specific but it seems that if you use strings there, they will do partial/wildcard/contains matching and not exact string matching. The reason I'm asking is because I'm testing a suggestion feature with two filter fields (first-name and last-name). Changing each field will trigger a call to the suggestion API (actually while typing but
    cy.type
    is fast enough to only trigger it once per field) which I need to intercept. I tried using this code (simplified):
    Copy code
    const pathname = `/suggestions`
    cy.intercept({
      pathname,
      query: {
        first_name: 'John',
        last_name: '',
      },
    }).as('first-name-search')
    
    cy.intercept({
      pathname,
      query: {
        first_name: 'John',
        last_name: 'Doe',
      },
    }).as('last-name-search')
    
    cy.get('input[name=first_name]').type('John')
    cy.wait('@first-name-search')
    
    cy.get('input[name=last_name]').type('Doe')
    cy.wait('@last-name-search')
    ... but then the
    first-name-search
    intercepts both API calls and the empty
    last_name
    query property seems to match twice. So even though there are only 2 API calls, I get three matches in the routes panel. I can't really use a URL string matcher here as the API library sometimes messes with the query param order. The only thing that got it working for me is to replace the empty string with a very restrictive Regex:
    /^$/
    . Is there no better way than this?
    n
    • 2
    • 1
  • default blank page
    w

    witty-pilot-73419

    02/21/2023, 10:16 AM
    Hello! How do I keep a testing session running multiple 'it's on the same page without getting to the default blank page after the first it ? Before version 12 I used 'cypress.cookies.default' but now that is not an option. I do not need authentication, I just visit the page and test
    s
    e
    • 3
    • 3
  • Microsoft SQL Server Management Studio connection using Cypress
    c

    colossal-table-38461

    02/21/2023, 11:04 AM
    Hello All, I need to verify table entries after performing few actions from UI in Microsoft SQL Server Mgmt. So could you please provide any reference Doc or Any Video link for e2e connection with this Database ?
    l
    • 2
    • 3
  • 'The Cypress extension is missing'
    c

    colossal-umbrella-95675

    02/21/2023, 1:27 PM
    Since a few days i get the 'The Cypress extension is missing' message for testing in Firefox 110. And i am not sure what changed. This was on version 12.3. Upgrade to 12.6 same error. Chrome, Electron and webkit run fine. What could be the problem? I've started the GUI with debuggin on. But i do not see any errors in the console output. I start cypress, chose E2E. Select Firefox. Then i see all my tests, so this part runs fine in Firefox. But then after selecting an E2E tests i see it starting 'Your tests are loading' and after after a few seconds this message pops up. In the attachment is the log between the moment i select my test and showing me the message. Firefox headless runs fine. Which makes it even stranger.
    • 1
    • 2
  • ESLint rule to scream when the import is missing
    b

    brief-kite-35331

    02/21/2023, 3:44 PM
    I tried to use this - eslintrc.json file :
    Copy code
    {
      "parser": "@typescript-eslint/parser",
      "plugins": [
        "@typescript-eslint"
      ],
      "extends": [
        "eslint:recommended",
        "plugin:node/recommended",
        "plugin:cypress/recommended"
      ],
      "parserOptions": {
        // Only ESLint 6.2.0 and later support ES2020.
        "ecmaVersion": 2020
      },
      "rules": {
        "cypress/no-assigning-return-values": "error",
        "cypress/no-unnecessary-waiting": "warn",
        "cypress/assertion-before-screenshot": "error",
        "cypress/no-force": "warn",
        "cypress/no-async-tests": "error",
        "node/no-missing-import": "error",
        "node/no-unsupported-features/es-syntax": "off",
        "no-unused-vars": "off"
      }
    }
    And in the package.json:
    Copy code
    "engines": {
        "node": ">=8.10.0"
      },
    But I get this errror for all the imports:
    ESLint: "../common/product-detail-actions" is not found.(node/no-missing-import)
    On the line like this:
    import { ProductDetailPageActions } from '../common/product-detail-actions';
    which I know should work. Can you please advise how to do this properly? What am I missing here?
  • cy. task it never ending
    s

    stocky-church-95567

    02/21/2023, 5:07 PM
    Could someone please help me with below, Context: I would like to compare 2 PNG's using task and verify if there is any difference but while executing the task is never ending even though it has timeout. I have used below attached image for reference. Task: on('task', { png({image1Path, image2Path}) { const image1 = fs.readFileSync(image1Path); const image2 = fs.readFileSync(image2Path); const img1 = PNG.sync.read(image1); const img2 = PNG.sync.read(image2); const { width, height } = img1; const diff = new PNG({ width, height }); pixelmatch(img1.data, img2.data, diff.data, width, height, { threshold: 0.1, }); fs.writeFileSync("diff.png", PNG.sync.write(diff)); return diff; } }); Code: cy.task("png", { image1Path: "cypress/downloads/sample.png", image2Path: "cypress/downloads/sample.png", },{ timeout: 50000 }).then((textOrNull) => { expect(textOrNull).to.equal(0);
    h
    • 2
    • 1
  • Selector from Playground causes test to fail
    f

    fresh-ability-77857

    02/21/2023, 5:45 PM
    Using the built-on tool to select an element give me this line: cy.get('#\32 > .tableV2-tbody__checkbox > .checkbox__container > [data-test="row-IndeterminateCheckbox"]').click() However after adding it to my spec file I get a Webpack Compilation Error with the stack trace pointing to the selector.
  • Docs for old versions of cypress
    i

    important-church-36572

    02/21/2023, 6:38 PM
    When I look at the docs, I can’t find any way to view docs for older versions of cypress. My company is currently using 9.6.0. Is there any way for me to view docs specific to this version? https://docs.cypress.io/guides/overview/why-cypress
    r
    • 2
    • 4
  • How to implement "on error resume next" in a loop
    g

    gray-crayon-29691

    02/21/2023, 11:15 PM
    Hi Cypress experts, I'm struggling with how to create a basic error catch (especially on error resume next) in Cypress when using a loop. Is it possible? I'm looking for something like this: for (const index of indexes) { try { cy.findByTestId("footer1") .find("span", {name: /Enter/i}) .should("be.visible") .click({force: true}); } catch (err) { // if any error continue with the loop continue } } I also tried but no luck. This cy.on works only for individual "it" test run cy.on('fail', (e)=>{ console.log (e) return false } Thank you !
    d
    h
    l
    • 4
    • 36
  • jquery-3.6.0.min.js xhr calls not executing in cypress tests but executing with normal browsers
    q

    quaint-airplane-96634

    02/22/2023, 7:07 AM
    As per the screenshot, When I load the page manually in any browser, all the xhr calls are executing fine. But when the same page loads with the cypress test its not executing xhr call having initiator as
    jquery-3.6.0.min.js
    , Is there any issue with cypress with such xhr calls?
  • Using "rerender" after "mount" with Redux Provider
    v

    victorious-traffic-84253

    02/22/2023, 9:54 AM
    I have a custom
    mount
    command that wraps my React components with my Redux Provider which works just fine - it's the same as what is explained in this guide https://docs.cypress.io/guides/component-testing/react/examples#Redux. I have a component which compares it's previous props to it's current props, and so in my component test I need to rerender it from one boolean state to the other; To do this I am making use of the
    rerender
    method like this:
    Copy code
    it("temporarily displays a 'saved' state when the 'saving' prop changes from true to false", () => {
      const WrappedButton = ({ ...props }) => (
        <Button {...props}>Click me</Button>
      );
    
      cy.mount(<WrappedButton saving={true} />).then(({ rerender }) => {
        cy.get("[data-test='button-loading']").should("exist");
        cy.get("[data-test='button-saved']").should("not.exist");
    
        rerender(<WrappedButton saving={false} />);
    
        cy.get("[data-test='button-loading']").should("not.exist");
        cy.get("[data-test='button-saved']").should("exist");
      });
    });
    Because my
    Button
    component connects to the Redux store, I'm getting the following error in Cypress when it gets to the
    rerender…
    line of code.
    Copy code
    (uncaught exception)Invariant Violation: Could not find "store" in the context of "Connect(Button)". Either wrap the root component in a <Provider>, or pass a custom React context provider to <Provider> and the corresponding React context consumer to Connect(Button) in connect options.
    Does anyone have any ideas how to solve this? If I refactor my Button component so that it doesn't connect to the Redux store everything works as expected, but in this scenario that isn't a viable solution. I would expect any rerendered component to still be wrapped in the Redux Provider.
    h
    • 2
    • 6
  • Custom commands results reused inside another custom command - good practice?
    n

    nutritious-honey-65632

    02/22/2023, 11:54 AM
    Basically I have custom commands for API calls to create environment needed for tests. So I have something like this:
    Copy code
    Cypress.Commands.add('getSomeDataById', (dataId, userId) => {
        cy.request('GET', '/myEndpoint')
            .its('body')
            .then((body) => {
                body.data.forEach((data) => {
                    if (data.id === dataId && data.userId === userId) {
                        cy.wrap(data).as('data');
                    }
                });
            });
    });
    then in the next command I have:
    Copy code
    Cypress.Commands.add(
        'someOtherCustomCommandForCreation', () => {
            cy.get('@data').then((data) => {
                // For this data do that
            });
        },
    );
    h
    l
    • 3
    • 24
  • When contributing to Cypress, how can I test a development version in another local repo?
    h

    high-holiday-75305

    02/22/2023, 2:23 PM
    I'm taking a look at writing a PR to fix a bug I filed in Cypress a little while back (https://github.com/cypress-io/cypress/issues/24407), and I wanted to test my fix by using my local development version of Cypress instead of a published version to see if it fixes my reproduction example project. I followed the contributing document and made a build of Cypress with my fix using
    yarn build
    . Then, in my bug reproduction project, I switched the Cypress version in
    package.json
    from a normal published version to point into the local pre-release build (
    "cypress": "file:../cypress/cli/build"
    ). When I run an npm install in the reproduction repo, I get a message saying
    Warning: You are installing a pre-release build of Cypress.
    , which is fair, but then the install fails with
    Error: Failed downloading the Cypress binary.
    . The URL it's saying it tried is https://cdn.cypress.io/beta/binary/12.6.0/darwin-x64/develop-49fdb6bbf1aba86728c219e6b4c04a41299a23d1/cypress.zip, which seems to legitimately be a 404, probably because the hash is of something that isn't a published binary. Does anyone know if it's possible to get this binary installation step to succeed in local development?
    w
    • 2
    • 12
  • How to check for API duration in Cypress -
    s

    some-cartoon-73108

    02/22/2023, 6:51 PM

    https://www.youtube.com/watch?v=sRllUFmJ4UA&ab_channel=ResterTest▾

  • Chrome Extension
    e

    echoing-tent-95037

    02/22/2023, 8:18 PM
    Is there another method of getting chrome extensions loaded with Cypress 12.5.1? Ive followed this https://www.cypress.io/blog/2020/01/07/how-to-load-the-react-devtools-extension-in-cypress/ as well as add browser extension here but never see it show up when testing https://docs.cypress.io/api/plugins/browser-launch-api#Modify-browser-launch-arguments-preferences-and-extensions The extension is within it's own folder under
    cypress
    directory.
    • 1
    • 2
  • Testing components using VueX
    m

    melodic-napkin-77320

    02/22/2023, 9:42 PM
    I've looked at this page to understand how to do this: https://docs.cypress.io/guides/component-testing/vue/examples#Vuex and it has this line: import { getStore } from '../../src/plugins/store' I haven't been able to find where 'getStore' is, and I can't find any reference to it in the VueX documentation.
    b
    • 2
    • 1
  • Any way to make a dummy intercept/alias
    c

    cool-truck-21040

    02/23/2023, 12:17 AM
    Hello. If I have a conditional, aliased intercept in one custom command and want to cy.wait on it in another custom command, is there a way to make a dummy alias or intercept that I can wait on elsewhere that will immediately resolve? Basically what I want is something that acts like Promise.resolve() for cy.wait("@alias") if the intercept didn't actually get set. Thanks.
    n
    g
    • 3
    • 3
  • Basic click crashes in Cypress 12.6.0
    n

    narrow-spoon-96183

    02/23/2023, 9:13 AM
    Hi all. I've been using v10 in the past and I've now updated to v12.6.0 and I've now got a problem with a basic click call. The following seems to crash and returns me to the Specs screen. With Cypress Run, it just hangs
    Copy code
    cy.visit('https://www.google.com/');
    cy.get('.LX3sZb .gb_p').contains('Gmail').click({force: true});
    This happens in all browsers. Happy to share any other info
    • 1
    • 1
  • Testing watch function of a props in Vue component
    c

    cold-journalist-13653

    02/23/2023, 9:18 AM
    Hi all, I have a simple watch into my component watch( () => props.checked, () => _checked.value = props.checked, ) but when I set the props during the cy test (after mount) this watch callback is never called wrapper.setProps({checked: true}); If someone has an idea Thanks 🙂
    • 1
    • 1
  • Cypress Component test coverage not working
    a

    acoustic-psychiatrist-35111

    02/23/2023, 12:23 PM
    Hi, I'm working on a project based on: React (react-create-app) and Typescript, recently I've tried to introduce test coverage for component tests, it is worth mentioning that the same config works just fine for E2E tests and results correct coverage. I've tried using multiple approaches including: NYC (directly), the exact steps from the https://docs.cypress.io/guides/tooling/code-coverage and just default cypress config. I've also tried instrumenting the code in different ways before running the tests: for example ``npx nyc instrument --compact=false --all src --in-place`` and cra instrumentation I've introduced additional nyc config and fiddled with that but no luck. My cypress config and nyc config can be found within the attached screenshots Once component tests run the coverage looks as follows (command that I use to run the test: ``nyc cypress run --headless --component --browser chrome --config-file ./cypress.config.ts``
    h
    • 2
    • 9
  • Will cypress 9.0.0 work with node 17+ versions? I am getting plugin error even for default tests
    r

    refined-lamp-49218

    02/23/2023, 2:17 PM
    I was using Cypress 9.0.0 with Node 16, but had to upgrade Node to 17+ for compliance. Now cypress is throwing plugin file error even for the default tests created by cypress. Any workaround is available?
    h
    m
    • 3
    • 31
  • writing a test (school task)
    d

    damp-appointment-29257

    02/23/2023, 3:50 PM
    Hey, I am trying to write a test where I have to: See picture. I have done most of it but I’m stack to point 6. Where I have to go to next Saturday from today…
    h
    e
    g
    • 4
    • 8
  • Component testing, wait for webpack to finish
    g

    green-sugar-75539

    02/23/2023, 5:02 PM
    Hi everyone 🙂 Does anyone else also experience this issue: https://github.com/cypress-io/cypress/discussions/24204
  • What is the correct way to set up a file with credentials?
    f

    faint-ocean-92094

    02/23/2023, 5:17 PM
    Hey everyone, this is a pretty noob question but I've never had a project with this many accounts. In order to test my app I need to have a different account for every 4 or 5 tests. I have my global variables, settled in the environment, but I already have like 50 because of this so I would like to get those out in a file. What is the correct way/best practice to do this? Should I create a json file as a fixture or what do you recommend to keep it clean?
    e
    h
    • 3
    • 10
  • in cypress 9.7.0 I cannot test display screen , Can anyone help me on this.
    g

    gorgeous-wolf-24355

    02/23/2023, 6:05 PM
    in cypress 9.7.0 I cannot test display screen , Can anyone help me on this.
    e
    • 2
    • 1
  • Your tests are loading... (infinite loading)
    p

    powerful-hamburger-23724

    02/23/2023, 7:46 PM
    I have a problem in the new version of cypress (12.0.2), when trying to access a url the test is in infinite loading, be it executed by electron or browser like Chrome can someone help me?
    w
    l
    • 3
    • 4
  • Authorization header set in intercept, not in xhr request
    t

    thousands-hair-55512

    02/23/2023, 8:09 PM
    Hello, I have set up an intercept to set a token in the Authorization header like so, in the console.log the header is clear there and the request is being intercepted as expected, however in the network request none of the intercepted requests have the Authorization header set. Looking at a few different resources and it seems like this is the pattern recommended to use to do this, wonder if anyone sees what I can't
    Copy code
    cy.intercept(`${Cypress.env('API_BASE_PATH')}/**`, ({ headers }) => {
          headers['Authorization'] = `Bearer ${Cypress.env('token')}`;
          console.log(headers);
        }).as('authInterceptor');
    h
    • 2
    • 22
  • task readExcelFile
    a

    agreeable-twilight-32980

    02/24/2023, 2:45 AM
    CypressError cy.task('readExcelFile') failed with the following error: > invalid signature: 0x8074b50Learn more View stack trace Print to console at (https://hub3-dev2.azurewebsites.net/__cypress/runner/cypress_runner.js:141553:78) From previous event: at Context.task (https://hub3-dev2.azurewebsites.net/__cypress/runner/cypress_runner.js:141538:15) at wrapped (https://hub3-dev2.azurewebsites.net/__cypress/runner/cypress_runner.js:151160:43) From Your Spec Code: at ExcelFiles.validateExcelFileContents (cypress/support/common/excelFiles.ts:73:11) at ExcelFiles.validateContentsOfExcelFileNamed (cypress/support/common/excelFiles.ts:57:13) at Context.eval (cypress/e2e/testcases/ui/imdexAdminUserRole/administration/companies.cy.ts:178:24) From Node.js Internals: Error: invalid signature: 0x8074b50 at (C:\Backup\Documents\Source\AzureDevOpsCypressV10\AzureDevOps\IMDEXHUB-IQ-Test\Functional\node_modules\unzipper\lib\parse.js:66:26) at tryCatcher (C:\Backup\Documents\Source\AzureDevOpsCypressV10\AzureDevOps\IMDEXHUB-IQ-Test\Functional\node_modules\unzipper\node_modules\bluebird\js\release\util.js:16:23) at Promise._settlePromiseFromHandler (C:\Backup\Documents\Source\AzureDevOpsCypressV10\AzureDevOps\IMDEXHUB-IQ-
  • selectFile command deprecated?
    w

    witty-gpu-64102

    02/24/2023, 9:57 AM
    Source: https://docs.cypress.io/api/commands/selectfile I would just like to share my experience with this command - I tried using this official command to get image file from my fixtures and upload it to input=file field but every time the image would get uploaded and I wanted to preview it, it would look something like this (no img element) - image 1 After trying many workarounds, I figured that I can just use attachFile command which provided me with good solution, image preview available (rendered as img element). https://www.npmjs.com/package/cypress-file-upload Hope this will save someone some time 🙂
    g
    a
    • 3
    • 4
1...91011...26Latest