Skip to content
This repository was archived by the owner on Jul 30, 2020. It is now read-only.

Commit 6aea9a7

Browse files
committed
docs: update docs for 3.0.0
BREAKING CHANGE: Release 3.0.0 adds exciting new features like a bundled jest preset, and aligns more closely to the testing-library guiding principles.
1 parent 0878fcf commit 6aea9a7

File tree

1 file changed

+26
-48
lines changed

1 file changed

+26
-48
lines changed

README.md

Lines changed: 26 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,13 @@
3939
- [The problem](#the-problem)
4040
- [This solution](#this-solution)
4141
- [Example](#example)
42-
- [Guiding principles](#guiding-principles)
4342
- [Installation](#installation)
4443
- [Hooks](#hooks)
45-
- [Inspiration](#inspiration)
4644
- [Other Solutions](#other-solutions)
4745
- [Guiding Principles](#guiding-principles)
46+
- [Inspiration](#inspiration)
4847
- [Contributors](#contributors)
48+
- [Docs](#docs)
4949

5050
<!-- END doctoc generated TOC please keep comment here to allow auto update -->
5151

@@ -92,7 +92,7 @@ function Example() {
9292
}
9393

9494
test('examples of some things', async () => {
95-
const { getByTestId, getByText, queryByTestId, rootInstance } = render(<Example />);
95+
const { getByTestId, getByText, queryByTestId } = render(<Example />);
9696
const famousWomanInHistory = 'Ada Lovelace';
9797

9898
const input = getByTestId('input');
@@ -103,33 +103,11 @@ test('examples of some things', async () => {
103103

104104
await wait(() => expect(queryByTestId('printed-username')).toBeTruthy());
105105

106-
expect(getByTestId('printed-username').props.children).toBe(famousWomanInHistory);
106+
expect(getByTestId('printed-username')).toHaveTextContent(famousWomanInHistory);
107107
expect(rootInstance).toMatchSnapshot();
108108
});
109109
```
110110

111-
## Guiding principles
112-
113-
> [The more your tests resemble the way your software is used, the more confidence they can give you.](https://twitter.com/kentcdodds/status/977018512689455106)
114-
115-
We try to only expose methods and utilities that encourage you to write tests that closely resemble
116-
how your apps are used.
117-
118-
Utilities are included in this project based on the following guiding principles:
119-
120-
1. Rendering React Native components ultimately creates native views, and those views should be
121-
what you test rather than the React component instances you rendered to make them.
122-
2. In general, test the way your users use your app. There are instances where you'll need to write
123-
unit tests, but try your best to write with this first -- the more your tests resemble the way
124-
your app works, the more confident you'll be with your app.
125-
3. Be responsible, and remember that testing exists to serve you, not the other way around. If the
126-
library isn't working for you, contribute to make it work or do something more intuitive. Make
127-
your tests work for you and your team!
128-
129-
In summary, we believe in the principles of `dom-testing-library` and its companion libraries, and
130-
try to adhere to them as closely as possible. Changes to this library should always consider how
131-
they relate to what's happening in the other libraries in this family of tools.
132-
133111
## Installation
134112

135113
This module should be installed in your project's `devDependencies`:
@@ -142,34 +120,15 @@ You will need `react` and `react-native` installed as _dependencies_ in order to
142120

143121
## Hooks
144122

145-
You can test hooks out of the box with this package as follows:
146-
147-
```javascript
148-
import { renderHook } from 'native-testing-library';
149-
```
150-
151-
Reads more about hooks on the [docs site](https://native-testing-library.com/docs/api-render-hook).
152-
153-
## Inspiration
154-
155-
Huge thanks to Kent C. Dodds for evangelizing this approach to testing. We could have never come up
156-
with this library without him 🙏. Check out his awesome work and learn more about testing with
157-
confidence at [testingjavascript.com](https://testingjavascript.com/) (you won't regret purchasing
158-
it), and of course, use this library's big brother, `react-testing-library` for your DOM
159-
applications as well!
160-
161-
The hook testing ability of this library is the same implementation as
162-
[react-hooks-testing-library](https://github.com/mpeyper/react-hooks-testing-library). The only
163-
reason it was included in this package is because we need you to import render from us, not the
164-
`dom-testing-library`, and that's an important blocker. Some day, maybe we'll try to allow use of
165-
that library with this one somehow.
123+
If you are interested in testing a custom hook, check out
124+
[react-hooks-testing-library](https://github.com/mpeyper/react-hooks-testing-library).
166125

167126
## Other Solutions
168127

169128
- [`react-native-testing-library`](https://github.com/callstack/react-native-testing-library)
170129
- [`enzyme`](https://airbnb.io/enzyme/docs/guides/react-native.html)
171130

172-
## Guiding Principles
131+
## Guiding principles
173132

174133
> [The more your tests resemble the way your software is used, the more confidence they can give you.](https://twitter.com/kentcdodds/status/977018512689455106)
175134
@@ -190,6 +149,20 @@ In summary, we believe in the principles of `testing-library`, and adhere to the
190149
possible. At the end of the day, what we want is for this library to be pretty light-weight, simple,
191150
and understandable.
192151

152+
## Inspiration
153+
154+
Huge thanks to Kent C. Dodds for evangelizing this approach to testing. We could have never come up
155+
with this library without him 🙏. Check out his awesome work and learn more about testing with
156+
confidence at [testingjavascript.com](https://testingjavascript.com/) (you won't regret purchasing
157+
it), and of course, use this library's big brother, `react-testing-library` for your DOM
158+
applications as well!
159+
160+
The hook testing ability of this library is the same implementation as
161+
[react-hooks-testing-library](https://github.com/mpeyper/react-hooks-testing-library). The only
162+
reason it was included in this package is because we need you to import render from us, not the
163+
`dom-testing-library`, and that's an important blocker. Some day, maybe we'll try to allow use of
164+
that library with this one somehow.
165+
193166
## Contributors
194167

195168
Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/docs/en/emoji-key)):
@@ -202,3 +175,8 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
202175

203176
This project follows the [all-contributors](https://github.com/all-contributors/all-contributors)
204177
specification. Contributions of any kind welcome!
178+
179+
## Docs
180+
181+
[**Read The Docs**](https://native-testing-library.com) |
182+
[Edit the docs](https://github.com/testing-library/native-testing-library-docs)

0 commit comments

Comments
 (0)