Skip to content

jest.useFakeTimers() breaks waitForDomChange, waitForElement, waitForElementToBeRemoved due to setTimeout  #300

@LaurensBosscher

Description

@LaurensBosscher

Issue:

When running any tests with:

  • waitForDomChange
  • waitForElement
  • waitForElementToBeRemoved

with jest.useFakeTimers enabled, these functions only run once and then fail.

This is because they use setTimeout internally to set a timeout.

However wait does work as expected because wait-for-expect has implemented a workaround, see: https://github.com/TheBrainFamily/wait-for-expect/pull/5/files

Would it be possible to implement this workaround for waitForDomChange, waitForElement, waitForElementToBeRemoved as well?

I'm willing to make a PR if I could talk the changes through with someone (e.g do we want to implement setTimeout as a util function or do we want to add the workaround to these three functions, how do we make sure that this will not break again in the future?).

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requesthelp wantedExtra attention is needed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions