Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cy.tick does not advance the clock correctly #9674

Open
bahmutov opened this issue Sep 13, 2020 · 7 comments
Open

cy.tick does not advance the clock correctly #9674

bahmutov opened this issue Sep 13, 2020 · 7 comments
Labels
CT Issue related to component testing prevent-stale mark an issue so it is ignored by stale[bot] type: bug

Comments

@bahmutov
Copy link
Contributor

bahmutov commented Sep 13, 2020

Seems to only advance it by 1 second ...

  it.skip('shows the timer after 700 seconds (using cy.tick)', () => {
    const now = Cypress.moment('2010-01-20')
    cy.clock(now.toDate())
    mount(
      <SudokuContext.Provider value={{ timeGameStarted: now }}>
        <div className="innercontainer">
          <section className="status">
            <Timer />
          </section>
        </div>
      </SudokuContext.Provider>,
    )
    cy.contains('.status__time', '00:00')
    cy.tick(700 * 1000)
    cy.contains('.status__time', '11:40')
  })

in https://github.com/bahmutov/sudoku-qafest/blob/main/src/components/Timer.spec.js#L57

@dmtrKovalenko
Copy link
Contributor

@lmiller1990 lmiller1990 transferred this issue from cypress-io/cypress-react-unit-test Dec 11, 2020
@lmiller1990 lmiller1990 added the npm: @cypress/react @cypress/react package issues label Dec 11, 2020
@cellog
Copy link

cellog commented Jan 7, 2022

this is still an issue, and is not just that it doesn't advance, cy.clock() + cy.tick() don't work at all in react component testing.

@alexandrzavalii
Copy link

is anyone looking at this issue?

@glomotion
Copy link

bump. on this issue. Im also seeing this right now.

@wengzilla
Copy link

I'm also noticing that something isn't working quite right for cy.clock() and component tests... For some reason not rendering my component properly. When I remove the cy.clock() it seems to work fine.

@cypress-app-bot
Copy link
Collaborator

This issue has not had any activity in 180 days. Cypress evolves quickly and the reported behavior should be tested on the latest version of Cypress to verify the behavior is still occurring. It will be closed in 14 days if no updates are provided.

@cypress-app-bot cypress-app-bot added the stale no activity on this issue for a long period label Sep 24, 2023
@jennifer-shehane jennifer-shehane removed the stale no activity on this issue for a long period label Oct 4, 2023
@mpavel
Copy link

mpavel commented Oct 19, 2023

We also had issues with cy.clock() and Cypress 16.8.1 in a large React app.
I've explained in #27744 how we overcame this.
It would be interesting to see if you experience the same behaviour: will the UI assertions work if you restore the clock, before making the actual assertion?

@jennifer-shehane jennifer-shehane added CT Issue related to component testing type: bug and removed npm: @cypress/react @cypress/react package issues labels Dec 16, 2023
@jennifer-shehane jennifer-shehane added the prevent-stale mark an issue so it is ignored by stale[bot] label May 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CT Issue related to component testing prevent-stale mark an issue so it is ignored by stale[bot] type: bug
Projects
None yet
Development

No branches or pull requests

10 participants