Skip to content

Commit 0e12929

Browse files
chore: readme tweaks (#1614)
* chore: readme tweaks * chore: tweak
1 parent 76de7d2 commit 0e12929

File tree

2 files changed

+20
-51
lines changed

2 files changed

+20
-51
lines changed

README.md

Lines changed: 19 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -6,25 +6,23 @@
66
alt="owl"
77
src="https://raw.githubusercontent.com/callstack/react-native-testing-library/main/website/static/img/owl.png"
88
/>
9-
<p>Simple and complete React Native testing utilities that encourage good testing practices.</P>
9+
<p>Developer-friendly and complete React Native testing utilities that encourage good testing practices.</P>
1010
</div>
1111

12-
![Version][version-badge]
13-
![codecov][codecov-badge]
14-
![Build](https://github.com/callstack/react-native-testing-library/actions/workflows/main.yml/badge.svg)
15-
[![downloads](https://img.shields.io/npm/dm/@testing-library/react-native.svg?style=flat-square)](http://www.npmtrends.com/@testing-library/react-native)
16-
![PRs Welcome][prs-welcome-badge]
17-
[![Chat][chat-badge]][chat]
18-
![Sponsored by Callstack][callstack-badge]
19-
[![Star on GitHub](https://img.shields.io/github/stars/callstack/react-native-testing-library.svg?style=social)](https://github.com/callstack/react-native-testing-library/stargazers)
12+
[![Version][version-badge]][package]
13+
[![Build Status][build-badge]][build]
14+
[![Code Coverage][coverage-badge]][coverage]
15+
[![Downloads][downloads-badge]][downloads]
16+
[![MIT License][license-badge]][license]
17+
[![Sponsored by Callstack][callstack-badge]][callstack]
2018

2119
## The problem
2220

2321
You want to write maintainable tests for your React Native components. As a part of this goal, you want your tests to avoid including implementation details of your components and rather focus on making your tests give you the confidence for which they are intended. As part of this, you want your tests to be maintainable in the long run so refactors of your components (changes to implementation but not functionality) don't break your tests and slow you and your team down.
2422

2523
## This solution
2624

27-
The React Native Testing Library (RNTL) is a lightweight solution for testing React Native components. It provides light utility functions on top of `react-test-renderer`, in a way that encourages better testing practices. Its primary guiding principle is:
25+
The React Native Testing Library (RNTL) is a comprehensive solution for testing React Native components. It provides React Native runtime simulation on top of `react-test-renderer`, in a way that encourages better testing practices. Its primary guiding principle is:
2826

2927
> The more your tests resemble the way your software is used, the more confidence they can give you.
3028
@@ -34,19 +32,15 @@ This project is inspired by [React Testing Library](https://github.com/testing-l
3432

3533
Open a Terminal in your project's folder and run:
3634

37-
#### Using `yarn`
38-
3935
```sh
36+
# Yarn install:
4037
yarn add --dev @testing-library/react-native
41-
```
42-
43-
#### Using `npm`
4438

45-
```sh
39+
# NPM install
4640
npm install --save-dev @testing-library/react-native
4741
```
4842

49-
This library has a `peerDependencies` listing for `react-test-renderer`. Make sure that your `react-test-renderer` version matches exactly the `react` version.
43+
This library has a `peerDependencies` listing for `react-test-renderer`. Make sure that your `react-test-renderer` version matches exactly the `react` version, avoid using `^` in version number.
5044

5145
### Additional Jest matchers
5246

@@ -56,32 +50,6 @@ You can use the built-in Jest matchers by adding the following line to your `jes
5650
import '@testing-library/react-native/extend-expect';
5751
```
5852

59-
### Custom Jest Preset (React Native before 0.71)
60-
61-
We generally advise using the "react-native" preset when testing with this library.
62-
63-
However, if you use React Native version earlier than 0.71 with [modern Jest fake timers](https://jestjs.io/blog/2020/05/05/jest-26#new-fake-timers) (default since Jest 27), you'll need to apply this custom Jest preset or otherwise awaiting promises, like using `waitFor` or `findBy*`, queries will fail with a timeout.
64-
65-
This is a [known issue](https://github.com/facebook/react-native/issues/29303). It happens because React Native's Jest preset overrides native Promise. Our preset restores it to defaults, which is not a problem in most apps out there.
66-
67-
Here's how you apply a custom preset in your Jest config:
68-
69-
```json
70-
{
71-
"preset": "@testing-library/react-native"
72-
}
73-
```
74-
75-
If this doesn't work for you, please fall back to using "legacy" fake timers.
76-
77-
### Flow
78-
79-
Note for [Flow](https://flow.org) users – you'll also need to install typings for `react-test-renderer`:
80-
81-
```sh
82-
flow-typed install react-test-renderer
83-
```
84-
8553
## Example
8654

8755
```jsx
@@ -162,11 +130,13 @@ Supported and used by [Rally Health](https://www.rallyhealth.com/careers).
162130

163131
[version-badge]: https://img.shields.io/npm/v/@testing-library/react-native.svg?style=flat-square
164132
[package]: https://www.npmjs.com/package/@testing-library/react-native
165-
[prs-welcome-badge]: https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square
166-
[prs-welcome]: http://makeapullrequest.com
167-
[chat-badge]: https://img.shields.io/discord/426714625279524876.svg?style=flat-square&colorB=758ED3
168-
[chat]: https://discord.gg/QbGezWe
133+
[build-badge]: https://github.com/callstack/react-native-testing-library/actions/workflows/main.yml/badge.svg
134+
[build]: https://github.com/callstack/react-native-testing-library/actions/workflows/main.yml
135+
[coverage-badge]: https://img.shields.io/codecov/c/github/callstack/react-native-testing-library.svg
136+
[coverage]: https://codecov.io/github/callstack/react-native-testing-library
137+
[downloads-badge]: https://img.shields.io/npm/dm/@testing-library/react-native.svg?style=flat-square
138+
[downloads]: http://www.npmtrends.com/@testing-library/react-native
139+
[license-badge]: https://img.shields.io/npm/l/@testing-library/react-native.svg
140+
[license]: https://opensource.org/licenses/MIT
169141
[callstack-badge]: https://callstack.com/images/callstack-badge.svg
170142
[callstack]: https://callstack.com/open-source/?utm_source=github.com&utm_medium=referral&utm_campaign=react-native-testing-library&utm_term=readme
171-
[codecov-badge]: https://codecov.io/gh/callstack/react-native-testing-library/branch/main/graph/badge.svg?token=tYVSWro1IP
172-
[codecov]: https://codecov.io/gh/callstack/react-native-testing-library

package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,8 @@
99
"url": "https://www.github.com/callstack/react-native-testing-library.git"
1010
},
1111
"homepage": "https://callstack.github.io/react-native-testing-library",
12-
"author": "Michał Pierzchała <thymikee@gmail.com>",
12+
"author": "Michał Pierzchała <thymikee@gmail.com> (https://github.com/thymikee), Maciej Jastrzębski <mdjastrzebski@gmail.com> (https://github.com/mdjastrzebski)",
1313
"contributors": [
14-
"Maciej Jastrzębski <mdjastrzebski@gmail.com> (https://github.com/mdjastrzebski)",
1514
"Augustin Le Fèvre <augustin.le-fevre@klarna.com> (https://github.com/AugustinLF)",
1615
"Pierre Zimmermann <pierrez@nam.tech> (https://github.com/pierrezimmermannbam)",
1716
"MattAgn <matthieua@bam.tech> (https://github.com/MattAgn)"

0 commit comments

Comments
 (0)