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

    purple-afternoon-2408

    07/29/2022, 10:09 AM
    wow, the typescript supportability in Cypress is very complicated :S
  • n

    nutritious-analyst-96582

    07/29/2022, 10:09 AM
    GG @purple-afternoon-2408, you just advanced to level 1!
  • g

    gray-kilobyte-89541

    07/29/2022, 11:36 AM
    https://cypress.tips/courses/network-testing could be your friend
  • a

    adorable-stone-42197

    07/29/2022, 1:33 PM
    https://stackoverflow.com/questions/69769440/cypress-i-am-trying-to-intercept-the-10-calls-which-originate-from-1-button-cli can some one check this? Second comment does not work for me because i don’t know how many calls i gonna have. @gray-kilobyte-89541
  • a

    able-monkey-72947

    07/29/2022, 2:25 PM
    Maybe a silly question, but is there was way to set a data-attr on an element from a test? I've been googling it but its hard because it appears stack overflow is down...
    cy.get('body').then(body => body[0].dataset['no-js'] = '???')
    That seems like it should work but I'm getting a
    setting getter-only
    error.
  • a

    able-monkey-72947

    07/29/2022, 2:29 PM
    For context - I have a data attr on my body element that gets removed immediately by a js script. I use that attr to style thing different when the client side JS isn't there. So what I really want to do here is run a test suit in a mode where the browser has JS turned off. If I can do that I don't need to do this business I asked about above.
  • a

    able-monkey-72947

    07/29/2022, 2:39 PM
    I found this issue - https://github.com/cypress-io/cypress/issues/1611 Is this still the best way to do this?
  • g

    gray-kilobyte-89541

    07/29/2022, 2:41 PM
    intercept HTML, remove all JS, boom!
  • g

    gray-kilobyte-89541

    07/29/2022, 2:42 PM
    if you search https://cypress.tips/search among the examples you can find it. Since Cy commands yield jQuery object, it is very simple to set an attribute
  • g

    gray-kilobyte-89541

    07/29/2022, 2:43 PM
    I bet it is covered in https://cypress.tips/courses/network-testing
  • a

    able-monkey-72947

    07/29/2022, 2:43 PM
    Ah, yeah, I always forget its jquery behind the scenes. I think just rendering the html with no script tags is what I want, closer to what would actually happen to a user.
  • a

    able-monkey-72947

    07/29/2022, 2:43 PM
    Thank you!
  • m

    mammoth-australia-81192

    07/29/2022, 3:40 PM
    Hi all, I'm having some trouble getting Cypress component testing working and I'm wondering if someone could help? I've tried the following steps a couple of different times and I am getting the same result. I've tried different machines as well, just in case. After trying the steps below, Cypress gets stuck on the "Your tests are loading..." screen.
    Copy code
    # create a new vite/react-ts project
    > pnpm create vite
    # name the project, choose react for framework and react-ts for variant
    > cd <project> && pnpm install
    > pnpm add -D cypress
    > pnpm exec cypress open
    # follow the automated setup steps for component testing setup from Cypress, choosing react/vite
    # choose to create a new test file automatically
    # change it to have a .tsx extension
    # import the default created <App /> from src and add it to cy.mount()
    # run the component test
    I've also tried the above with
    npm
    just to be safe and got the same result. I feel like I'm just missing something silly and could really use a hand. I can also put up a small repo as an issue if that's better / helps! Versions: react@18.2.0 vite@3.0.0 typescript@4.6.4 cypress@10.3.1
  • n

    nutritious-honey-65632

    07/29/2022, 8:39 PM
    I googled the error and it says you need to declare namespace Cypress. I use cypress helper extension for VS code and it does it for me https://stackoverflow.com/questions/69927966/argument-type-string-is-not-assignable-to-parameter-type-keyof-chainable-in-c
  • a

    adorable-stone-42197

    07/31/2022, 10:43 AM
    I have your course. Can u help me find it? I try to find on course but didn’t manage. U better know where it is @gray-kilobyte-89541
  • e

    eager-chef-77344

    07/31/2022, 10:58 AM
    Did anyone managed to make cypress component testing work with vite? It losses the process.envs, and can't load. On webpack it fails to load my config
  • w

    wonderful-match-15836

    07/31/2022, 4:32 PM
    A minimal reproduction repo would be great, thanks!
    m
    • 2
    • 8
  • w

    wonderful-match-15836

    07/31/2022, 4:33 PM
    We use Cy component testing with Vite at Cypress, if you can make a reproduction showing the problems in your situation I'd be happy to take a look.
    e
    • 2
    • 2
  • a

    acceptable-hamburger-48790

    07/31/2022, 5:23 PM
    this might help https://medium.com/@gurudatt.sa26/cypress-adding-a-custom-command-f6ae05751b61
  • e

    eager-chef-77344

    08/01/2022, 5:55 AM
    We use Cy component testing with Vite at
  • m

    melodic-dawn-73228

    08/01/2022, 8:00 AM
    Hey all, I have an issue with Cypress App where it shows not responding after sometime I started my test. I couldnt find any similar thread online, anyone faced same issue before?
  • m

    melodic-dawn-73228

    08/01/2022, 8:02 AM
    Basically every time i edited my code, I need to terminate the batch job, and do cypress open again to run my new code
  • l

    little-horse-39027

    08/01/2022, 8:31 AM
    Hi all, the application that I use to automate is a Single SPA. Recently there was a code change to include refresh token code for session timeout which had a check for iframe to do a silent callback for signin. function inIframe() { try { return window.self !== window.top; } catch (e) { return true; } } After this change, when I try to launch the app via Cypress, it does not launch the app at all. There is a blank page always with no error.
  • g

    gray-kilobyte-89541

    08/01/2022, 12:02 PM
    "Bonus 19: How to get the last network call of multiple ones"?
  • a

    adorable-stone-42197

    08/01/2022, 1:01 PM
    This is not working at all for me… can u check again what i posted. I don’t know how many i api calls gonna have….
  • l

    late-planet-4481

    08/01/2022, 2:46 PM
    If you don't know how many calls are incoming I probably can't help you and you'll have to refer to Gleb's guide. But usually call count will be consistent (and if it's not, why not?) so triple check to see if there's a pattern. Once you have the pattern figured out you can use an array with
    cy.wait()
    to wait for one of each thing. Example:
    Copy code
    cy.intercept('updateCalendar').as('uc')
    cy.intercept('saveOrder').as('so')
    cy.get('[data-test-id="shinyRedButton"]').click()
    cy.wait(['uc','so'])
    If you expect duplicates, just put duplicates in the array.
    cy.wait(['uc','uc','uc','so'])
    https://docs.cypress.io/api/commands/wait#Aliases
  • g

    gray-kilobyte-89541

    08/01/2022, 3:25 PM
    🙂 I don't know how to help with "suggestion number 2 is not working for me, and I don't know how many calls I have". Like what do you expect the test to do? If you don't know if the network is making 0, 1, 10 or 100 calls, what do you want to check? Maybe wait 10 seconds, and then grab the last network call? Use alias.all if necessary
  • a

    able-monkey-72947

    08/01/2022, 3:41 PM
    I'm having a really silly issue I just can't seem to get to work... I'm trying to check some a11y stuff, I want to make sure each of my
    tabpanels
    is
    labelledby
    correctly.
    Copy code
    cy.wrap(panel).invoke('attr', 'aria-labelledby').then(label => {
      const expectedLabel = cy.get('@tabs').eq(index).invoke('attr', 'id')
      cy.wrap(label).should('eq', expectedLabel)
    })
    I can see in the cypress test runner console that
    const expectedLabel = ...
    gives me what I expect -
    Yielded:         web-component-tabs-web-component-tab-one
    . However, on the next line, the text fails like this
    component-tab-one to equal { Object (userInvocationStack, specWindow, ...) }
    Do I need to put a
    .then(label => ...
    in there somewhere on the line calling
    .invoke('attr', 'id')
    ?
  • a

    acceptable-hamburger-48790

    08/01/2022, 4:01 PM
    Can you combine these two lines const expectedLabel = cy.get('@tabs').eq(index).invoke('attr', 'id') cy.wrap(label).should('eq', expectedLabel) to single line cy.get('@tabs').eq(index).invoke('attr', 'id').should('eq', label)
  • s

    salmon-computer-88142

    08/01/2022, 4:07 PM
    does anyone know how can i debug cypress commands / tasks running on the backend? it seems like cypress allows me to debug only code running in the browser
1...117118119...252Latest