Skip to content

Commit

Permalink
Merge pull request #266 from zaccolley/fake-timers-docs
Browse files Browse the repository at this point in the history
Add documentation for useFakeTimers
  • Loading branch information
NickColley authored Mar 23, 2023
2 parents 5bc8fd2 + b0643e3 commit b72f1b7
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,21 @@ describe("SomeComponent", () => {

> Note: You may need to extend jest by importing `jest-axe/extend-expect` at `test-setup.ts`
### Usage with jest.useFakeTimers() or mocking setTimeout

> thrown: "Exceeded timeout of 5000 ms for a test.
> Use jest.setTimeout(newTimeout) to increase the timeout value, if this is a long-running test."
aXe core does not work when timers (setTimeout) are mocked. When using `jest.useFakeTimers()` aXe core will timeout often causing failing tests.

We recommend renabling the timers temporarily for aXe:

```javascript
jest.useRealTimers();
const results = await axe(wrapper.element);
jest.useFakeTimers();
```

### Axe configuration

The `axe` function allows options to be set with the [same options as documented in axe-core](https://github.com/dequelabs/axe-core/blob/master/doc/API.md#options-parameter):
Expand Down

0 comments on commit b72f1b7

Please sign in to comment.