Skip to content

Commit b72f1b7

Browse files
authored
Merge pull request #266 from zaccolley/fake-timers-docs
Add documentation for useFakeTimers
2 parents 5bc8fd2 + b0643e3 commit b72f1b7

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

README.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,21 @@ describe("SomeComponent", () => {
168168

169169
> Note: You may need to extend jest by importing `jest-axe/extend-expect` at `test-setup.ts`
170170
171+
### Usage with jest.useFakeTimers() or mocking setTimeout
172+
173+
> thrown: "Exceeded timeout of 5000 ms for a test.
174+
> Use jest.setTimeout(newTimeout) to increase the timeout value, if this is a long-running test."
175+
176+
aXe core does not work when timers (setTimeout) are mocked. When using `jest.useFakeTimers()` aXe core will timeout often causing failing tests.
177+
178+
We recommend renabling the timers temporarily for aXe:
179+
180+
```javascript
181+
jest.useRealTimers();
182+
const results = await axe(wrapper.element);
183+
jest.useFakeTimers();
184+
```
185+
171186
### Axe configuration
172187

173188
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):

0 commit comments

Comments
 (0)