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

    icy-exabyte-68383

    04/27/2022, 7:16 PM
    Hello, I´ve added Cypress to my trusted applications on Kaspersky, but still everytime cypress opens the browser, kaspersky blocks it fully. "Certificate chain isn´t complete". anyone encountered this problem?
  • a

    adorable-smartphone-87280

    04/27/2022, 8:28 PM
    the browser invoked by Cypress isn't the same as your regular browser. Whether it's chromium or firefox or whatever, you might have to add those to your trusted list.
  • n

    nutritious-oxygen-11772

    04/27/2022, 9:22 PM
    We should be covering this case currently. When you click on a link that crosses origins you should be able to catch it by immediately following the click with a cy.origin command.
    Copy code
    it('follows a link', () => {
        cy.visit('https://github.com/cypress-io/cypress')
        cy.get('a[href="https://on.cypress.io"]').click()
        cy.origin('https://docs.cypress.io/', () => {
          cy.get('h1').invoke('text').should('include', 'Why Cypress?')
        })
      })
  • i

    icy-exabyte-68383

    04/27/2022, 9:25 PM
    Ah, yes. but the only thing that works is "Don´t inspect whatever chrome does as a whole" This doesn´t feel good 😄
  • a

    able-monkey-72947

    04/27/2022, 9:40 PM
    Much sillier question than what I asked before... is there some way to import the
    cy
    object? I'm writing a Jest test for a custom Cypress command (weird, I know, I'm just rolling with it...) and trying to mock stuff in getting pretty wild. It would be a lot easier if I could do something like this -
    Copy code
    import cy from 'somewhere'
    jest.createMockFromModule('somewhere')
  • a

    able-monkey-72947

    04/27/2022, 9:41 PM
    It's fine if I've got to fish this out of
    node_modules
    somewhere too, I think that's fine for how esoteric of a thing I'm trying to do...
  • g

    gray-kilobyte-89541

    04/27/2022, 9:57 PM
    this is pretty sweet
  • t

    thankful-controller-3208

    04/28/2022, 8:46 AM
    Hello guys, how could I open an website through company VPN? Im getting 404
  • f

    fresh-doctor-14925

    04/28/2022, 10:50 AM
    If you're running on a vpn on your local machine, be sure that you are on the VPN before running
    cypress run
    or
    cypress open
    . That's tripped me up a few times
  • w

    witty-kite-3465

    04/28/2022, 1:22 PM
    Hi! I sporadically get this number suffix on intercepted api calls from my test. I have a test isolated with
    only
    and only register the intercepts once but I guess they somehow get registered multiple times? Does anyone know how this could happen and if I can do anything to make sure it doesn't happen?
  • r

    rough-monitor-85122

    04/28/2022, 2:12 PM
    One thing to try is to either set a
    baseUrl
    or register your intercepts after cy.visit() - if you visit a domain that isn't your baseURL, cypress will refresh the page during cy.visit, which results in commands earlier in the test getting executed twice. Three times though, IDK. 🤷‍♀️
  • w

    witty-kite-3465

    04/28/2022, 2:20 PM
    Thanks for your reply, I missed to mention that its a component test so I don't call visit at all. I just noticed that it does not happen when I reload the cypress test runner page or click the rerun button though. Seems to sporadically do some kind of hot reload which causes it.
  • l

    little-france-10142

    04/28/2022, 3:49 PM
    Hello all, I am very new to testing, just got my first job as a FE dev. I watched the Nutshell video yesterday, wrote some simple tests for a React button component and a checkbox component. I used
    alert
    to verify (assert?) that the button works as intended when clicked. However my lead said let's use
    onSubmit
    or
    onClick
    instead. I'm looking over the docs for testing
    .click()
    and maybe I'm just missing something really basic and clear but I cannot seem to find a way to assert that the button has, in fact, been clicked. Any help would be greatly appreciated.
  • a

    able-monkey-72947

    04/28/2022, 4:16 PM
    I think you wouldn't want to test that the button as been clicked here, instead you'd want to assert that whatever is supposed to happen when you click the button happened. Does that make sense?
  • a

    able-monkey-72947

    04/28/2022, 4:17 PM
    Like if the button triggers an alert you want to click the button (assume it was clicked), then test that the alert appears.
  • r

    rough-monitor-85122

    04/28/2022, 4:19 PM
    Yeah. If you use cy.click, and then assert that the button was clicked... you're testing Cypress, that cy.click works the way you think. But you probably want to be testing your application - that the button is visible, or that clicking it performs the action you expect. That's the first thing to think about, what about your application are you trying to test. "When I click the button, the button is clicked" isn't terribly informative.
  • l

    little-france-10142

    04/28/2022, 4:26 PM
    Ah yes I see. So at this point I can assert that the button was clicked by using an alert. So this is actually just a base button that can be wrapped by other buttons as needed. That includes what the button will actually do moving forward. At the moment the placeholder code is
    Copy code
    onClick?: () => void
    as a React prop. I suppose I'm just trying to write a test for that base button. My logic is that I should be able to write something like this
    Copy code
    it('renders an active base button', () => {
      mount(<Button>Click me</Button>)
      cy.get(':button').click().should('return.void')
    })
  • a

    able-monkey-72947

    04/28/2022, 4:29 PM
    Honestly, for things like this in our app we use Jest. Testing what a base button does feels like a unit test to me, maybe whatever is build on top of that is a better fit for an end to end test?
  • l

    little-france-10142

    04/28/2022, 4:31 PM
    Oh interesting. Ya everything I've read so far really feels like a higher level than this. Like testing the actual, assembled, pages. I will look into Jest then. Thanks for your time!
  • a

    able-monkey-72947

    04/28/2022, 4:33 PM
    Cypress does unit testing, I haven't used it much and IIRC it's still in beta? https://github.com/cypress-io/cypress-example-recipes/tree/master/examples/unit-testing__application-code
  • r

    rough-monitor-85122

    04/28/2022, 4:37 PM
    You can also use cypress component tests instead of jest for this sort of thing, yeah. It's getting a big facelift in 10.0, but works well in 9.x too.
  • a

    able-monkey-72947

    04/28/2022, 4:38 PM
    Ah, that's what I was thinking of that's in beta.
  • l

    little-france-10142

    04/28/2022, 4:38 PM
    Can you point me to any docs for component tests? or are you saying that's in beta?
  • a

    able-monkey-72947

    04/28/2022, 4:42 PM
    https://www.cypress.io/blog/2021/04/06/cypress-component-testing-react/ This seems maybe like what you want since you mentioned using React.
  • a

    able-monkey-72947

    04/28/2022, 4:51 PM
    So I have this code in my
    plugins/index
    file,
    Copy code
    on('task', {
        doesFileExist(filename) {
          if (fs.existsSync(filename)) return true
          return null
        }
      })
    I'm trying to write a test for a Command that uses this, I'd like to mock/stub what
    fs.existSync
    returns here. Is that possible?
  • a

    able-monkey-72947

    04/28/2022, 4:57 PM
    wow, does there exist an issue that gleb bahmutov hasn't already found and made a video about?

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

  • a

    able-monkey-72947

    04/28/2022, 5:22 PM
    Bleh, turns out my situation is just different enough that this won't work : /
  • s

    salmon-oxygen-44652

    04/29/2022, 10:31 AM
    hello everyone, i am getting blank pages when running e2e tests with cypress, I am using electron and tried chrome, and I am on wsl on windows 11
  • s

    salmon-oxygen-44652

    04/29/2022, 10:31 AM
    the home page shows up correctly, but not the other ones
  • g

    gray-kilobyte-89541

    04/29/2022, 11:20 AM
    yeah, it is a little different, since you are trying to mock FS in the plugin file itself, not in the application code
1...585960...252Latest