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

Commit 8bbf7e1

Browse files
author
Brandon Carroll
committed
merge conflicts
1 parent 77f3014 commit 8bbf7e1

22 files changed

+74
-9592
lines changed

docs/api-act.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,5 @@ sidebar_label: Act
77
## `act`
88

99
This is a light wrapper around the
10-
[`react-test-renderer` `act` function](https://reactjs.org/docs/test-renderer.html).
11-
All it does is forward all arguments to the act function if your version of
12-
react supports `act`.
10+
[`react-test-renderer` `act` function](https://reactjs.org/docs/test-renderer.html). All it does is
11+
forward all arguments to the act function if your version of react supports `act`.

docs/api-events.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ sidebar_label: Firing Events
77
## Basic example
88

99
```javascript
10-
import { fireEvent, NativeTestEvent, render } from 'native-testing-library';
10+
import { fireEvent, NativeTestEvent, render } from '@testing-library/react-native';
1111

1212
const { getByText } = render(<Button title="Submit" />);
1313
fireEvent(getByText(container, 'Submit'), new NativeTestEvent('press'));
@@ -24,7 +24,7 @@ Convenience methods for firing events. Check out
2424
for a full list as well as `validTargets` for every event type.
2525

2626
```javascript
27-
import { fireEvent, render } from 'native-testing-library';
27+
import { fireEvent, render } from '@testing-library/react-native';
2828

2929
const { getByText } = render(<Button title="Submit" />);
3030
fireEvent.press(getByText('Submit'));

docs/api-helpers.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,15 @@ sidebar_label: Helpers
66

77
## Custom Queries
88

9-
`native-testing-library` exposes some of the helper functions that are used to implement the default
10-
queries. You can use the helpers to build custom queries. For example, the code below shows a way to
11-
query your TestInstance by a `style` prop. Note: test files would need to now import `test-utils.js`
12-
instead of using `native-testing-library` directly. Also note, please never actually implement this
13-
helper, it's just an example of what's possible.
9+
RNTL exposes some of the helper functions that are used to implement the default queries. You can
10+
use the helpers to build custom queries. For example, the code below shows a way to query your
11+
TestInstance by a `style` prop. Note: test files would need to now import `test-utils.js` instead of
12+
importing directly from RNTL. Also note, please never actually implement this helper, it's just an
13+
example of what's possible.
1414

1515
```javascript
1616
// test-utils.js
17-
import * as nativeTestingLib from 'native-testing-library';
17+
import * as nativeTestingLib from '@testing-library/react-native';
1818

1919
const { queryHelpers } = nativeTestingLib;
2020

@@ -78,7 +78,7 @@ query functions, allowing them to be used without manually specifying a containe
7878
Example: To get the username input of a login form within a `<LoginModal />`, you could do:
7979

8080
```js
81-
import { render, within } from 'native-testing-library';
81+
import { render, within } from '@testing-library/react-native';
8282

8383
const { getByLabelText } = render(<LoginModal />);
8484
const loginForm = getByLabelText('login-form');

docs/api-queries.md

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ This will search for all elements with an `accessibilityHint` prop and find one
7777
given [`TextMatch`](#textmatch).
7878

7979
```js
80-
import { render } from 'react-testing-library';
80+
import { render } from '@testing-library/react-native';
8181

8282
const { getByHintText } = render(<View accessibilityHint="summary" />);
8383

@@ -117,7 +117,7 @@ function Login({ onPress }) {
117117
);
118118
}
119119

120-
import { render } from 'native-testing-library';
120+
import { render } from '@testing-library/react-native';
121121

122122
const { getByLabelText } = render(<Login onPress={jest.fn()} />);
123123

@@ -141,7 +141,7 @@ This will search for all elements with an `accessibilityRole` prop and find one
141141
given [`TextMatch`](#textmatch).
142142

143143
```js
144-
import { render } from 'react-testing-library';
144+
import { render } from '@testing-library/react-native';
145145

146146
const { getByRole } = render(<View accessibilityRole="summary" />);
147147

@@ -173,7 +173,7 @@ This will search for all elements with a `placeholder` prop and find one that ma
173173
[`TextMatch`](#textmatch).
174174

175175
```javascript
176-
import { render } from 'native-testing-library';
176+
import { render } from '@testing-library/react-native';
177177

178178
const { getByPlaceholderText } = render(<TextInput placeholder="Username" />);
179179

@@ -201,7 +201,7 @@ This will search for all elements of type `Text` with `props.children` matching
201201
also search for `Button` elements by their `title` [`TextMatch`](#textmatch).
202202

203203
```js
204-
import { render } from 'native-testing-library';
204+
import { render } from '@testing-library/react-native';
205205

206206
const { getByText } = render(<Text>About ℹ</Text>);
207207

@@ -229,7 +229,7 @@ This will search for all `Button` or `RefreshControl` elements with `props.title
229229
by their value [`TextMatch`](#textmatch).
230230

231231
```js
232-
import { render } from 'native-testing-library';
232+
import { render } from '@testing-library/react-native';
233233

234234
const { getByTitle } = render(<Button title="About" />);
235235

@@ -258,7 +258,7 @@ This will search for all `TextInput` elements with a `value` prop and `Picker` o
258258
with a `selectedValue` prop and find ones that matches the given [`TextMatch`](#textmatch).
259259

260260
```js
261-
import { render } from 'native-testing-library';
261+
import { render } from '@testing-library/react-native';
262262

263263
const { getByDisplayValue } = render(<Input value="About ℹ" onChangeText={() => ({})} />);
264264

@@ -286,7 +286,7 @@ This will search for all elements with a `testID` and find one that matches the
286286
[`TextMatch`](#textmatch).
287287

288288
```js
289-
import { render } from 'native-testing-library';
289+
import { render } from '@testing-library/react-native';
290290

291291
const { getByTestId } = render(<Text testID="test">hi there</Text>);
292292

@@ -319,9 +319,9 @@ of string matching:
319319

320320
### Normalization
321321

322-
Before running any matching logic against text, `native-testing-library` automatically normalizes
323-
that text. By default, normalization consists of trimming whitespace from the start and end of text,
324-
and collapsing multiple adjacent whitespace characters into a single space.
322+
Before running any matching logic against text, RNTL automatically normalizes that text. By default,
323+
normalization consists of trimming whitespace from the start and end of text, and collapsing
324+
multiple adjacent whitespace characters into a single space.
325325

326326
If you want to prevent that normalization, or provide alternative normalization (e.g. to remove
327327
Unicode control characters), you can provide a `normalizer` function in the options object. This

docs/cheat-sheet.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ sidebar_label: Cheat Sheet
55
---
66

77
There is a printable one-page cheat sheet available for you to download. It is intended to be a
8-
quick reference for `native-testing-library`, but is not a complete API glossary or guide. Keep a
9-
copy of it on your desk to quickly take a peek at the most commonly used functionality!
8+
quick reference for RNTL, but is not a complete API glossary or guide. Keep a copy of it on your
9+
desk to quickly take a peek at the most commonly used functionality!
1010

1111
[Download the cheat sheet][cheatsheet]
1212

docs/ecosystem-jest-native.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ title: Jest Matchers
44
sidebar_label: Jest Matchers
55
---
66

7-
[`jest-native`](https://github.com/testing-library/jest-native) is a companion library for
8-
`native-testing-library` that provides custom element matchers for Jest.
7+
[`jest-native`](https://github.com/testing-library/jest-native) is a companion library for RNTL that
8+
provides custom element matchers for Jest.
99

1010
```
1111
npm install --save-dev jest-native

docs/example-context.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ sidebar_label: Context
88
import React from 'react';
99
import { Text } from 'react-native';
1010

11-
import { render } from ' native-testing-library';
11+
import { render } from '@testing-library/react-native';
1212
import { NameContext, NameProvider, NameConsumer } from '../react-context';
1313

1414
test('NameConsumer shows default value', () => {

docs/example-input-event.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ sidebar_label: Input Event
77
```javascript
88
import React from 'react';
99
import { Text, TextInput } from 'react-native';
10-
import { render, fireEvent } from ' native-testing-library';
10+
import { render, fireEvent } from '@testing-library/react-native';
1111

1212
class CostInput extends React.Component {
1313
state = {

docs/example-intl.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import { FormattedDate } from 'react-intl-native';
1212
import IntlPolyfill from 'intl';
1313
import 'intl/locale-data/jsonp/pt';
1414

15-
import { getByText, render } from ' native-testing-library';
15+
import { getByText, render } from '@testing-library/react-native';
1616

1717
const setupTests = () => {
1818
if (global.Intl) {

docs/example-navigation.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import React from 'react';
99
import { Button, Text, View } from 'react-native';
1010
import { createStackNavigator, createAppContainer, withNavigation } from 'react-navigation';
1111

12-
import { render, fireEvent } from ' native-testing-library';
12+
import { render, fireEvent } from '@testing-library/react-native';
1313

1414
jest.mock('NativeAnimatedHelper').mock('react-native-gesture-handler', () => {
1515
const View = require('react-native/Libraries/Components/View/View');

docs/example-redux.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import React from 'react';
99
import { Button, Text, View } from 'react-native';
1010
import { createStore } from 'redux';
1111
import { Provider, connect } from 'react-redux';
12-
import { render, fireEvent } from ' native-testing-library';
12+
import { render, fireEvent } from '@testing-library/react-native';
1313

1414
class Counter extends React.Component {
1515
increment = () => {

docs/example-update-props.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ sidebar_label: Update Props
77
```javascript
88
import React from 'react';
99
import { Text, View } from 'react-native';
10-
import { render } from ' native-testing-library';
10+
import { render } from '@testing-library/react-native';
1111

1212
let idCounter = 1;
1313

@@ -32,5 +32,4 @@ test('calling render with the same component on the same container does not remo
3232

3333
expect(getByTestId('instance-id').props.children).toEqual(1);
3434
});
35-
3635
```

docs/example.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ sidebar_label: Example
77
```javascript
88
import React from 'react';
99
import { Button, Text, TextInput, View } from 'react-native';
10-
import { fireEvent, render, wait } from 'native-testing-library';
10+
import { fireEvent, render, wait } from '@testing-library/react-native';
1111

1212
function Example() {
1313
const [name, setUser] = React.useState('');

docs/guide-disappearance.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,11 @@ id: guide-disappearance
33
title: Appearance and Disappearance
44
---
55

6-
`dom-testing-library` can utilize a fake DOM `MutationObserver` to look for changes, but we don't
7-
have that luxury in the native/test renderer environment. Since we don't have that, you should know
8-
that all `wait-*` utilities in this library offer roughly the same functionality, just with some
9-
added convenience.
6+
Testing Library implementations that leverage
7+
[DTL](https://github.com/testing-library/dom-testing-library) can utilize a fake DOM
8+
`MutationObserver` to look for changes, but we don't have that luxury. Since we don't have that, you
9+
should know that all `wait-*` utilities in this library offer roughly the same functionality, just
10+
with some added convenience.
1011

1112
Since we can't "observe" a DOM, we just have to poll it at a given interval
1213

docs/guiding-principles.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,6 @@ Utilities are included in this project based on the following guiding principles
1919
they're intended to be used.
2020
3. Utility implementations and APIs should be simple and flexible.
2121

22-
In summary, we believe in the principles of `testing-library`, and adhere to them as closely as
22+
In summary, we believe in the principles of Testing Library, and adhere to them as closely as
2323
possible. At the end of the day, what we want is for this library to be pretty light-weight, simple,
2424
and understandable.

docs/install.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ sidebar_label: Install
99
This module should be installed in your project's `devDependencies`:
1010

1111
```
12-
npm install --save-dev native-testing-library
12+
npm install --save-dev @testing-library/react-native
1313
```
1414

1515
You will need `react` and `react-native` installed as _dependencies_ in order to run this project.
@@ -87,7 +87,7 @@ these components that isn't mocked, just `debug()` to see what your users are se
8787
You will likely be able to import everything you'll need from the project entry point like this:
8888

8989
```js
90-
import { render } from 'native-testing-library';
90+
import { render } from '@testing-library/react-native';
9191
```
9292

9393
The library's tests run in Node 8-11 before all new versions are published, and all files are

docs/intro.md

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,24 +7,23 @@ sidebar_label: Introduction
77
## The problem
88

99
You want to write maintainable tests for your React Native application. You love Kent Dodds'
10-
[testing library](https://testing-library.com), and you want to be able to write maintainable tests
10+
[Testing Library](https://testing-library.com), and you want to be able to write maintainable tests
1111
for your React Native application. You don't want to use a library that renders components to a fake
1212
DOM, and you've had a hard time finding what you need to write tests using that philosophy in React
1313
Native.
1414

1515
## This solution
1616

17-
`native-testing-library` is an implementation of the well-known `testing-library` API that works for
18-
React Native. The primary goal is to mimic the testing library API as closely as possible while
17+
Native Testing Library (RNTL) is an implementation of the well-known Testing Library API that works
18+
for React Native. The primary goal is to mimic the testing library API as closely as possible while
1919
still accounting for the differences in the platforms. Accomplishing this is no small feat because
20-
of the differences between the two platforms. Although most framework implementations like
21-
`react-testing-library` are thin layers over [dom-testing-library](https://testing-library.com),
20+
of the differences between the two platforms. Although most framework implementations like React
21+
Testing Library (RTL) are thin layers over [DOM Testing Library (DTL)](https://testing-library.com),
2222
this library needed to have its own base implementation as well as a user-facing API. This library
23-
uses the [react-test-renderer](https://reactjs.org/docs/test-renderer.html), whereas
24-
`dom-testing-library` uses ReactDOM to render to JSDOM. The main philosophy is that you should find
25-
elements the way your users would. This approach is meant to give you confidence that your app is
26-
working as a cohesive unit. Just like the `dom-testing-library`, `native-testing-library`'s primary
27-
guiding principle is:
23+
uses the [react-test-renderer](https://reactjs.org/docs/test-renderer.html), whereas DOM Testing
24+
Library (DTL) uses JSDOM. The main philosophy here is that you should find elements on the "screen"
25+
the way users would. This approach is meant to give you confidence that your app is working as a
26+
cohesive unit. Just like DTL, RNTL's primary guiding principle is:
2827

2928
> [The more your tests resemble the way your software is used, the more confidence they can give you.](guiding-principles.md)
3029

docs/setup.md

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@ sidebar_label: Setup
66

77
## Setting up your project
88

9-
The `native-testing-library` API should work out of the box for most tests. All of the snippets
10-
you'll find throughout the website work without any additional configuration assuming you use Jest
11-
and a moderately recent version of React Native.
9+
The RNTL API should work out of the box for most tests. All of the snippets you'll find throughout
10+
the website work without any additional configuration assuming you use Jest and a moderately recent
11+
version of React Native.
1212

13-
We strongly encourage you to use Jest with the `native-testing-library` preset. The `react-native`
14-
preset should also work, but you'll be getting the best experience when using our preset. There may
15-
be some additional mocks you need to provide to such as mocks for `react-native-gesture-handler`
16-
when using `react-navigation`.
13+
We strongly encourage you to use Jest with the `@testing-library/react-native` preset. The
14+
`react-native` preset may also work, but you'll be getting the best experience when using our
15+
preset. There may be some additional mocks you need to provide to such as mocks for
16+
`react-native-gesture-handler` when using `react-navigation`.
1717

1818
## Cleanup
1919

@@ -39,23 +39,22 @@ module.exports = {
3939

4040
It's often useful to define a custom render method that includes things like global context
4141
providers, data stores, etc. To make this available globally, one approach is to define a utility
42-
file that re-exports everything from `native-testing-library`. You can replace
43-
`native-testing-library` with this file in all your imports. See
44-
[below](#configuring-jest-with-test-utils) for a way to make your test util file accessible without
45-
using relative paths.
42+
file that re-exports everything from RNTL. You can replace `@testing-library/react-native` with this
43+
file in all your imports. See [below](#configuring-jest-with-test-utils) for a way to make your test
44+
util file accessible without using relative paths.
4645

4746
The example below sets up data providers using the [`wrapper`](api-main.md#render-options) option to
4847
`render`.
4948

5049
```diff
5150
// my-component.test.js
52-
- import { render, fireEvent } from 'native-testing-library';
51+
- import { render, fireEvent }from '@testing-library/react-native';
5352
+ import { render, fireEvent } from '../test-utils';
5453
```
5554

5655
```js
5756
// test-utils.js
58-
import { render } from 'native-testing-library';
57+
import { render } from '@testing-library/react-native';
5958
import { ThemeProvider } from 'my-ui-lib';
6059
import { TranslationProvider } from 'my-i18n-lib';
6160
import defaultStrings from 'i18n/en-x-default';
@@ -71,7 +70,7 @@ const AllTheProviders = ({ children }) => {
7170
const customRender = (ui, options) => render(ui, { wrapper: AllTheProviders, ...options });
7271

7372
// re-export everything
74-
export * from 'native-testing-library';
73+
export * from '@testing-library/react-native';
7574

7675
// override render method
7776
export { customRender as render };

0 commit comments

Comments
 (0)