Skip to content

Commit 5d4d4d9

Browse files
authored
Merge branch 'main' into docs/move-dtl-to-peer-dep-rtl
2 parents 99a9cb0 + 33e4f5e commit 5d4d4d9

File tree

11 files changed

+400
-127
lines changed

11 files changed

+400
-127
lines changed

.all-contributorsrc

+36
Original file line numberDiff line numberDiff line change
@@ -2637,6 +2637,42 @@
26372637
"contributions": [
26382638
"doc"
26392639
]
2640+
},
2641+
{
2642+
"login": "vadimshvetsov",
2643+
"name": "Vadim Shvetsov",
2644+
"avatar_url": "https://avatars.githubusercontent.com/u/16336572?v=4",
2645+
"profile": "https://github.com/vadimshvetsov",
2646+
"contributions": [
2647+
"doc"
2648+
]
2649+
},
2650+
{
2651+
"login": "domnantas",
2652+
"name": "Domantas Petrauskas",
2653+
"avatar_url": "https://avatars.githubusercontent.com/u/51953549?v=4",
2654+
"profile": "https://domnantas.lt",
2655+
"contributions": [
2656+
"doc"
2657+
]
2658+
},
2659+
{
2660+
"login": "Efim-Kapliy",
2661+
"name": "Efim",
2662+
"avatar_url": "https://avatars.githubusercontent.com/u/126895483?v=4",
2663+
"profile": "https://portfolio.edkt.ru",
2664+
"contributions": [
2665+
"doc"
2666+
]
2667+
},
2668+
{
2669+
"login": "denisx",
2670+
"name": "denisx",
2671+
"avatar_url": "https://avatars.githubusercontent.com/u/427776?v=4",
2672+
"profile": "https://github.com/denisx",
2673+
"contributions": [
2674+
"code"
2675+
]
26402676
}
26412677
],
26422678
"contributorsPerLine": 7,

README.md

+7-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ and [related projects](https://github.com/testing-library)
2020
https://api.netlify.com/api/v1/badges/24366204-84ca-41e9-b573-2a64f0845e46/deploy-status
2121
[build]: https://app.netlify.com/sites/testing-library/deploys
2222
[allcontributors-badge]:
23-
https://img.shields.io/badge/all_contributors-2-orange.svg?style=flat-square
23+
https://img.shields.io/github/all-contributors/testing-library/testing-library-docs?color=ee8449&style=flat-square
2424
[coc-badge]:
2525
https://img.shields.io/badge/code%20of-conduct-ff69b4.svg?style=flat-square
2626
[coc]:
@@ -509,6 +509,12 @@ Thanks goes to these wonderful people
509509
<td align="center" valign="top" width="14.28%"><a href="https://www.dylangordon.co.nz/"><img src="https://avatars.githubusercontent.com/u/3656794?v=4?s=100" width="100px;" alt="Dylan Gordon"/><br /><sub><b>Dylan Gordon</b></sub></a><br /><a href="https://github.com/testing-library/testing-library-docs/commits?author=agentdylan" title="Documentation">📖</a></td>
510510
<td align="center" valign="top" width="14.28%"><a href="https://michael.cousins.io"><img src="https://avatars.githubusercontent.com/u/2963448?v=4?s=100" width="100px;" alt="Michael Cousins"/><br /><sub><b>Michael Cousins</b></sub></a><br /><a href="https://github.com/testing-library/testing-library-docs/commits?author=mcous" title="Documentation">📖</a> <a href="https://github.com/testing-library/testing-library-docs/pulls?q=is%3Apr+reviewed-by%3Amcous" title="Reviewed Pull Requests">👀</a></td>
511511
<td align="center" valign="top" width="14.28%"><a href="https://kettanaito.com"><img src="https://avatars.githubusercontent.com/u/14984911?v=4?s=100" width="100px;" alt="Artem Zakharchenko"/><br /><sub><b>Artem Zakharchenko</b></sub></a><br /><a href="https://github.com/testing-library/testing-library-docs/commits?author=kettanaito" title="Documentation">📖</a></td>
512+
<td align="center" valign="top" width="14.28%"><a href="https://github.com/vadimshvetsov"><img src="https://avatars.githubusercontent.com/u/16336572?v=4?s=100" width="100px;" alt="Vadim Shvetsov"/><br /><sub><b>Vadim Shvetsov</b></sub></a><br /><a href="https://github.com/testing-library/testing-library-docs/commits?author=vadimshvetsov" title="Documentation">📖</a></td>
513+
<td align="center" valign="top" width="14.28%"><a href="https://domnantas.lt"><img src="https://avatars.githubusercontent.com/u/51953549?v=4?s=100" width="100px;" alt="Domantas Petrauskas"/><br /><sub><b>Domantas Petrauskas</b></sub></a><br /><a href="https://github.com/testing-library/testing-library-docs/commits?author=domnantas" title="Documentation">📖</a></td>
514+
<td align="center" valign="top" width="14.28%"><a href="https://portfolio.edkt.ru"><img src="https://avatars.githubusercontent.com/u/126895483?v=4?s=100" width="100px;" alt="Efim"/><br /><sub><b>Efim</b></sub></a><br /><a href="https://github.com/testing-library/testing-library-docs/commits?author=Efim-Kapliy" title="Documentation">📖</a></td>
515+
</tr>
516+
<tr>
517+
<td align="center" valign="top" width="14.28%"><a href="https://github.com/denisx"><img src="https://avatars.githubusercontent.com/u/427776?v=4?s=100" width="100px;" alt="denisx"/><br /><sub><b>denisx</b></sub></a><br /><a href="https://github.com/testing-library/testing-library-docs/commits?author=denisx" title="Code">💻</a></td>
512518
</tr>
513519
</tbody>
514520
</table>

docs/guides-using-fake-timers.mdx

+14-11
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,8 @@ flaky.
1010

1111
To solve these problems, or if you need to rely on specific timestamps in your
1212
code, most testing frameworks offer the option to replace the real timers in
13-
your tests with fake ones. This should be used sporadically and not on a regular
14-
basis since using it contains some overhead.
15-
16-
When using fake timers in your tests, all of the code inside your test uses fake
17-
timers.
13+
your tests with fake ones. This has a side effect - when using fake timers in
14+
your tests, _all_ of the code inside your test uses fake timers.
1815

1916
The common pattern to setup fake timers is usually within the `beforeEach`, for
2017
example:
@@ -26,12 +23,10 @@ beforeEach(() => {
2623
})
2724
```
2825

29-
When using fake timers, you need to remember to restore the timers after your
30-
test runs.
31-
32-
The main reason to do that is to prevent 3rd party libraries running after your
33-
test finishes (e.g cleanup functions), from being coupled to your fake timers
34-
and use real timers instead.
26+
Since fake timers are mocking native timer functions, it is necessary to restore
27+
the timers after your test runs, just like regular mocks. This prevents fake
28+
timers leaking into other test cases and cleanup functions, where real timers
29+
are expected.
3530

3631
For that you usually call `useRealTimers` in `afterEach`.
3732

@@ -51,3 +46,11 @@ afterEach(() => {
5146
jest.useRealTimers()
5247
})
5348
```
49+
50+
:::note
51+
52+
Combining fake timers with `user-event` may cause test timeouts. Refer to
53+
[`advanceTimers`](user-event/options.mdx#advancetimers) option to prevent this
54+
issue.
55+
56+
:::

docs/react-testing-library/example-intro.mdx

+2
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,12 @@ test('loads and displays greeting', async () => {
6666
See the following sections for a detailed breakdown of the test
6767

6868
:::note
69+
6970
We recommend using the
7071
[Mock Service Worker (MSW)](https://github.com/mswjs/msw) library to
7172
declaratively mock API communication in your tests instead of stubbing
7273
`window.fetch`, or relying on third-party adapters.
74+
7375
:::
7476

7577
```jsx title="__tests__/fetch.test.jsx"

docs/react-testing-library/setup.mdx

+8-8
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,10 @@ make your test util file accessible without using relative paths.
3131
The example below sets up data providers using the [`wrapper`](api.mdx#wrapper)
3232
option to `render`.
3333

34-
<Tabs groupId="test-utils" defaultValue="jsx" values={[ {label: 'JavaScript',
35-
value: 'jsx'}, {label: 'TypeScript', value: 'tsx'}, ]}>
34+
<Tabs groupId="test-utils" defaultValue="js" values={[ {label: 'JavaScript',
35+
value: 'js'}, {label: 'TypeScript', value: 'ts'}, ]}>
3636

37-
<TabItem value="jsx">
37+
<TabItem value="js">
3838

3939
```diff title="my-component.test.jsx"
4040
- import { render, fireEvent } from '@testing-library/react';
@@ -70,7 +70,7 @@ export {customRender as render}
7070

7171
</TabItem>
7272

73-
<TabItem value="tsx">
73+
<TabItem value="ts">
7474

7575
```diff title="my-component.test.tsx"
7676
- import { render, fireEvent } from '@testing-library/react';
@@ -250,10 +250,10 @@ passing a [`queries`](api.mdx#render-options) option.
250250
If you want to add custom queries globally, you can do this by defining your
251251
customized `render`, `screen` and `within` methods:
252252

253-
<Tabs groupId="test-utils" defaultValue="jsx" values={[ {label: 'JavaScript',
254-
value: 'jsx'}, {label: 'TypeScript', value: 'tsx'}, ]}>
253+
<Tabs groupId="test-utils" defaultValue="js" values={[ {label: 'JavaScript',
254+
value: 'js'}, {label: 'TypeScript', value: 'ts'}, ]}>
255255

256-
<TabItem value="jsx">
256+
<TabItem value="js">
257257

258258
```js title="test-utils.js"
259259
import {render, queries, within} from '@testing-library/react'
@@ -278,7 +278,7 @@ export {customScreen as screen, customWithin as within, customRender as render}
278278

279279
</TabItem>
280280

281-
<TabItem value="tsx">
281+
<TabItem value="ts">
282282

283283
```ts title="test-utils.ts"
284284
import {render, queries, within, RenderOptions} from '@testing-library/react'

0 commit comments

Comments
 (0)