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

    handsome-kilobyte-99728

    06/03/2021, 10:02 PM
    repro added! https://github.com/andrew-anguiano/reproductions/tree/main/cypress-component-testing-16784
  • b

    bulky-sundown-74498

    06/03/2021, 10:05 PM
    Neat thank you
  • b

    bulky-sundown-74498

    06/03/2021, 10:06 PM
    ... hum... that is embarassing
  • b

    bulky-sundown-74498

    06/03/2021, 10:07 PM
    I never logged ssh into github...
  • b

    bulky-sundown-74498

    06/03/2021, 10:07 PM
    "kyber-ui": "git+ssh://git@github.com/pro-football-focus/kyber-ui.git#semver:1.3.6",
  • b

    bulky-sundown-74498

    06/03/2021, 10:17 PM
    Actually I believe these repos are private which make installing impossible
  • b

    bulky-sundown-74498

    06/03/2021, 10:19 PM
    Removing them
  • h

    handsome-kilobyte-99728

    06/04/2021, 12:05 AM
    oh yep i meant to remove them sorry
  • h

    hallowed-orange-38556

    06/04/2021, 4:08 AM
    Can someone point me some article which compares cypress and selenium. It's advantages, disadvantages, features etc
  • f

    flat-electrician-52949

    06/04/2021, 8:43 AM
    I can't seem to get the
    cy.tick()
    working as I expect. Got this case:
    Copy code
    ts
    const [minutesLeft, minutesLeftSet] = React.useState<number>(10)
    
      React.useEffect(() => {
        let timer
        if (minutesLeft > 0) {
          timer = setTimeout(() => {
            console.log(new Date())
            minutesLeftSet((minutesLeft) => minutesLeft - 1)
          }, 1000 /*ms*/ * 60 /*sec*/ * 1 /*min*/)
        }
    
        return () => {
          if (timer) clearTimeout(timer)
        }
      }, [minutesLeft])
    (this is finial version - it will do it from a date but this is fine for now)
    Copy code
    ts
    ...
    / Time left
        cy.contains('10 min', { matchCase: false }).should('be.visible')
        cy.tick(1000 /*ms*/ * 60 /*sec*/ * 1 /*min*/ + 300 /*ms*/)
        cy.contains('9 min', { matchCase: false }).should('be.visible')
        cy.tick(1000 /*ms*/ * 60 /*sec*/ * 1 /*min*/ + 300 /*ms*/)
        cy.contains('8 min', { matchCase: false }).should('be.visible')
  • f

    flat-electrician-52949

    06/04/2021, 8:45 AM
    only 1 date is shown in the console...
  • f

    flat-electrician-52949

    06/04/2021, 8:46 AM
    it works in the browser
  • i

    icy-rainbow-39970

    06/04/2021, 8:46 AM
    Cy.clock () need to be called before cy.tick()
  • f

    flat-electrician-52949

    06/04/2021, 8:46 AM
    sorry that is done
  • f

    flat-electrician-52949

    06/04/2021, 8:47 AM
    Copy code
    ts
      it.only('shows a ticket order and an estimate on when it is ready', () => {
        cy.stub(nextRouterMock, 'useRouter').callsFake((): Partial<TRouter> => {
          return { query: { ticketNumber: '7' } }
        })
    
        const now = new Date()
    
        cy.clock(now)
    
        mount(
          <>
            <ResizeWrapper>
              <CartProvider>
                <PaymentSucceededMessage />
              </CartProvider>
            </ResizeWrapper>
          </>
        )
    
        // Ticket number
        cy.findByText('Ditt biljettnummer är').should('be.visible')
        cy.findByText('7').should('be.visible')
    
        // Time left
        cy.contains('10 min', { matchCase: false }).should('be.visible')
        cy.tick(1000 /*ms*/ * 60 /*sec*/ * 1 /*min*/ + 300 /*ms*/)
        cy.contains('9 min', { matchCase: false }).should('be.visible')
        cy.tick(1000 /*ms*/ * 60 /*sec*/ * 1 /*min*/ + 300 /*ms*/)
        cy.contains('8 min', { matchCase: false }).should('be.visible')
    
        cy.contains('Om du inte har angett en annan gång i anteckningen till köket')
      })
  • f

    flat-electrician-52949

    06/04/2021, 8:48 AM
    just wanted keep the examples short
  • f

    flat-electrician-52949

    06/04/2021, 8:50 AM
    Don't understand why I can't forward time...
  • u

    user

    06/04/2021, 9:52 AM
    coincidentally I'm getting the same problem so I opened a ticket with another repo if that helps 😄
  • u

    user

    06/04/2021, 9:53 AM
    I didn't know if it was a global problem or because I'm using TypeScript + Vue, so my repo has those configured
  • b

    billowy-spoon-30011

    06/04/2021, 3:26 PM
    Hello ! I'm trying to cy.visit an url copied into my clipboard through the click of a button. Is there a way to test that action ? I'm reading several things but it doesn't look like it's working for me. Thanks !
  • e

    echoing-piano-69699

    06/04/2021, 5:11 PM
    @User have you come across this stack overflow?
  • e

    echoing-piano-69699

    06/04/2021, 5:11 PM
    https://stackoverflow.com/questions/50633601/is-it-possible-to-paste-from-clipboard-onclick-in-javascript
  • b

    billowy-spoon-30011

    06/04/2021, 5:11 PM
    @User not this one, no
  • e

    echoing-piano-69699

    06/04/2021, 5:12 PM
    If the general approach is new to you I think that could be a ~solit~ solid* starting point of getting the contents of the clipboard and then programmatically going to that address (assuming it's an address)
  • b

    billowy-spoon-30011

    06/04/2021, 5:14 PM
    Thanks ! I'm kind of new to programming on Cypress (and in general as well), I'm trying to get to visit the URL address I get from clicking on a button that should be in my clipboard
  • e

    echoing-piano-69699

    06/04/2021, 5:15 PM
    Okay. Once you have the URL from your clipboard, you can do something like
    window.location.href = /*your variable value*/
  • b

    billowy-spoon-30011

    06/04/2021, 5:15 PM
    I'll have a look at your link with greater attention on Monday morning as I'm not at work at the moment 🙂
  • e

    echoing-piano-69699

    06/04/2021, 5:16 PM
    Can someone help me better understand what Cypress can offer in terms of confirming a particular function was called? I have tried using
    cy.spy
    and
    cy.stub
    but it doesn't seem to be working the way I expect it to I have tried instantiating both of these in different places (at beginning of
    describe
    , in
    beforeEach
    , etc.) but haven't gotten it to work I am definitely calling the methods I'm spying on but something appears to not be connected in how I'm testing this with Cypress
  • e

    echoing-piano-69699

    06/04/2021, 5:52 PM
    To give more detail, I am trying to test like this
    Copy code
    typescript
    import segment from 'utils/segment'
    
    export {}
    
    const formDefinition = {}
    
    describe('Analytics', () => {
        beforeEach(() => {
            cy.intercept('/metric/formio/latency', { statusCode: 200 })
        })
    
        describe('page navigation', () => {
            beforeEach(() => {
                cy.visit('/cypress_tests', {
                    onBeforeLoad() {
                        cy.spy(segment, 'init').as('initSpy')
                        cy.spy(segment, 'track').as('trackSpy')
                    }
                })
                cy.loadForm(formDefinition)
            })
    
            it('initializes segment', () => {
                cy.get('@initSpy').should('be.called')
            })
        })
    })
  • e

    echoing-piano-69699

    06/04/2021, 6:02 PM
    I tried making
    init
    available as an individual export and changing my import to
    import * as segment from 'utils/segment'
    but got this error
    Attempted to wrap undefined property init as function
    so I don't think that's the correct route to take
1...202122...252Latest