https://cypress.io logo
Join Discord
Powered by
# help
  • f

    flaky-fountain-4670

    01/11/2023, 7:09 AM
    Hi, two weeks ago, I started https://github.com/cypress-io/cypress/discussions/25306, though did not yet get an answer. Does Cypress have a way to wait for an HTTP response callback to be processed, as
    cy.wait(@alias)
    apparently only waits for the request to be submitted?
  • s

    sticky-dentist-24502

    01/11/2023, 7:58 AM
    Hi, I have problem with cypress project on Windows on Mac is without problems. When I open Cypress project on Mac I get error
    Copy code
    Error [ERR_UNSUPPORTED_ESM_URL_SCHEME]: Only URLs with a scheme in: file, data are supported by the default ESM loader. On Windows, absolute paths must be valid file:// URLs. Received protocol 'c:'
    Node version is 18. What can I be problem ? Thanks for help.
  • b

    bright-printer-23884

    01/11/2023, 11:46 AM
    Hoping someone can help me out here, I'm trying to add a new command using typescript, however type script keeps moaning in the editor about my method name string not being an assignable to the parameter of type 'keyof Chainable:
  • b

    bright-printer-23884

    01/11/2023, 11:46 AM
    Any ideas ?
  • b

    bright-printer-23884

    01/11/2023, 11:48 AM
    I copied this straight out of the example comment further up the file: // -- This is a parent command -- // Cypress.Commands.add('login', (email, password) => { ... })
  • b

    bright-printer-23884

    01/11/2023, 12:11 PM
    Ok nm, I got it working after some cajoling using this:
  • b

    bright-printer-23884

    01/11/2023, 12:47 PM
    Q: Is before( in cypress spec the equivalent of beforeAll( in a mocha spec ?
  • b

    bright-printer-23884

    01/11/2023, 12:49 PM
    nm doesn't seem right, how do you do a beforeAll in a cypress spec?
  • b

    bright-printer-23884

    01/11/2023, 12:50 PM
    this is resulting in error:
  • b

    bright-printer-23884

    01/11/2023, 12:54 PM
    nm found it; Its beforeEach if anyone searches this in the future.
  • b

    bright-printer-23884

    01/11/2023, 12:54 PM
    and before.
  • b

    bright-printer-23884

    01/11/2023, 12:54 PM
    before = beforeAll
  • e

    enough-author-35578

    01/11/2023, 2:19 PM
    Is there a way to verify that
    cy.mount
    throws an error? I have a component that throws an error when it is not wrapped in a particular contextProvider, and a test to verify that it does so. I have been using
    @testing-library/react
    for my component tests, and was able to test this behavior like this, which worked:
    Copy code
    js
    import { render } from "@testing-library/react"
    
    it("throws an error when not wrapped in the right context", () => {
      expect(() => render(<MyComponent />))
        .throws("The right error message")
    })
    I am currently trying to migrate my component tests over to
    cy.mount
    , and wasn't able to find a way to make this test work anymore.
  • g

    green-controller-97889

    01/11/2023, 2:43 PM
    How does
    contains
    search for text ? How deep does it go ? I have the following structure:
    Copy code
    html
    <body>
      <section data-cy="_title">
        <div>
          <div>
            <span>Some Title</span>
          </div>
        </div>
      </section>
    </body>
    Should
    cy.get("[data-cy='_title']").contains("Some Title")
    work ?
  • g

    gray-kilobyte-89541

    01/11/2023, 3:16 PM
    https://on.cypress.io/contains (My advice simply use
    cy.contains('[data-cy="_title"]', 'Some title')
  • g

    green-controller-97889

    01/11/2023, 3:44 PM
    Any idea on why
    cy.get("_dropdown");
    doesn't find the element ? It has
    display:block
    . I know it's nested, but that should not matter, right ? Or does it has something to do with Ant Design ?
  • c

    cool-truck-21040

    01/11/2023, 4:35 PM
    👋 . Sorry for re-posting, but I did this in a thread, above, and it seems to have gotten lost (couldn't figure out how to un-thread a thread): I am upgrading from Cypress pre-v10 to latest and have everything basically working, but locally (MacOS Monterey), I'm frequently getting this when running either
    cypress:run
    or
    cypress:open
    (using
    yarn
    scripts)
    Copy code
    Your configFile threw an error from: cypress.config.js
    We stopped running your tests because your config file crashed.
    Error: spawn /Users/my-username/.nvm/versions/node/v18.12.1/bin/node EACCES
        at Process.onexit (node:internal/child_process:283:19)
        at onErrorNT (node:internal/child_process:478:16)
        at process.processTicksAndRejections (node:internal/process/task_queues:83:21)
    error Command failed with exit code 1.
    Here's my `cypress.config.js`: https://gist.github.com/Josh68/25d318e2678116cb82b60a5d7b5d82d5. Note that I'm using a few plugins, including cypress-visual-regression and cypress-html-validate (with their own config options) and am also calling a few custom commands within
    setupNodeEvents
    . Can anyone spot what my issue might be, or tell me how to debug further (the Cypress docs reference using
    DEBUG=cypress:server:config
    , but that does nothing, and
    DEBUG=cypress:*
    is way too verbose).
  • m

    magnificent-finland-58048

    01/11/2023, 5:00 PM
    doesn't look wrong, but certainly you have the issue the plugin + task config gets tricky, it's hard not to break it, specially without TS (i'm no TS fanboi...) take a look at this content, and then check out the repo maybe you can do a similar refactor to tame things and optimize

    https://www.youtube.com/watch?v=9d7zDR3eyB8▾

    https://github.com/muratkeremozcan/tour-of-heroes-react-cypress-ts/blob/main/cypress.config.ts
  • s

    some-keyboard-52751

    01/11/2023, 5:18 PM
    hi
  • s

    some-keyboard-52751

    01/11/2023, 5:18 PM
    i am getting issue .
  • b

    brave-doctor-62978

    01/11/2023, 5:35 PM
    can i not do this for a command on an interceptor?
    Copy code
    Cypress.Commands.add('requestBody', { prevSubject: true }, subject => {
        return subject.its('request.body');
      });
    called as
    Copy code
    cy.intercept('/2/users', {}).as('userRequest');
        
        cy.get('@userRequest').requestBody().should('deep.equal', {
          ...(new User({
            first_name: 'Isaiah',
            last_name: 'Berlin',
            email: 'haha@.com',
            phone_number: '',
          }).toJSON()),
          invite: false,
        });
  • b

    brave-doctor-62978

    01/11/2023, 5:35 PM
    i get
    cy.get(...).requestBody is not a function
    ...
  • c

    cool-truck-21040

    01/11/2023, 5:40 PM
    Thanks, @magnificent-finland-58048 . Yeah, I wanted to convert this to TS, but given our current TS config, I'm avoiding for now to minimize unintended breakage, and currently the top level of our codebase isn't TS compiled (and I am a TS proponent, not necessarily fanboi). I'll have a look at your suggestions. Any suggestions for debugging, though? This error message doesn't tell me much, and it doesn't help that i happens randomly, meaning the config is actually OK, at some level. Same thing happens in headed tests, and the UI will show the config's broken but then show it's fine when I reload the page. 🤷‍♂️
  • n

    narrow-arm-9964

    01/11/2023, 5:47 PM
    I'm new here; trying to figure out how to see all of my github branches in my cypress cloud account... When I go to https://cloud.cypress.io/projects/PROJECTID/branches, it shows my default branch (
    develop
    ), but it says that my
    master
    branch is stale (even though I have been running jobs against that branch this week). Perhaps I'm not referencing the branch properly when I start my jobs 🤔 I am using cypress-io/github-action@v5, where the docs state:
    Copy code
    Cypress actions use `GITHUB_TOKEN` to get the correct branch
  • n

    narrow-arm-9964

    01/11/2023, 5:48 PM
    I have that setup (obviously, since it is getting the
    develop
    branch)
  • m

    modern-dawn-86006

    01/11/2023, 6:40 PM
    Post your issue
  • g

    gray-kilobyte-89541

    01/11/2023, 6:53 PM
    why not simply
    Copy code
    js
    cy.wait('@userRequest').its('request.body').should(...)
  • b

    brave-doctor-62978

    01/11/2023, 6:54 PM
    that's what i ended up with, i just wanted a prettier way
  • c

    cool-truck-21040

    01/11/2023, 7:22 PM
    @magnificent-finland-58048, I just started watching that video. We have no component tests, but it's stated that I must have a
    components.ts
    file. Could that be my problem (that and adding a
    comopnent
    section in my config and pointing it at the new support file)? In my config, I also specified that my
    /support/e2e.ts
    could end in
    {js, ts, jsx, tsx}
    , and it's currently a
    .ts
    , so I'll just change that.
  • f

    full-helmet-93291

    01/11/2023, 7:55 PM
    Hi, we've migrated to Cypress 12.3.0 and we're facing some new problems with our old tests. I've read the release notes and found the handling of cookies and sessions is different now. Without digressing, the tests which are failing are the ones that do a login, a logout and then another login again (with the same original account or another one). Something happens with the cookies that affects the server, and a 500 is shown in the app we're testing against. Just to give you context, these logins and logouts are contained within a single test, not across several, meaning each test is atomic.
    Copy code
    describe("Logout test", () => {
    
    beforeEach(function () {
            cy.visit("/");
            cy.log("Verifying the Login page is displayed.");
            cy.get("#kc-login").should("be.visible");
        });
    
        it("testing login and logout", () => {
                cy.get("#username").type("username");
    cy.get("#password").type("password");
                cy.get("#kc-login").click();
    
    
            cy.log("Loging out of the application");
            cy.get("div[data-testid='navbar-profile-dropdown-items']").invoke("show");
    
            cy.get("div[data-testid='navbar-profile-dropdown-items'] > a[href='/users/logout']").click();
    
            cy.log("Verifying the Login page is displayed.");
            cy.get("#kc-login").should("be.visible");
    
            cy.get("#username").type("username");
    cy.get("#password").type("password");
                cy.get("#kc-login").click();
                
            });
        });
        
    });
    After the new login, the page crashes. Any clues on why this is happening?
1...247248249...252Latest