Skip to content

Commit 2bce396

Browse files
docs: expose jest matchers publically (docs, examples, etc) (#1523)
* docs: update references to Jest Native * chore: update docs * chore: update example apps * docs: update * chore: upgrade example apps * chore: self code review * chore: docs tweaks * docs: code review changes
1 parent bc1ec0d commit 2bce396

26 files changed

+25856
-166
lines changed

.gitignore

+1-2
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,5 @@ build
1616
!.yarn/sdks
1717
!.yarn/versions
1818

19-
# Ignore lock files in examples for now
20-
examples/**/yarn.lock
19+
# Docusaurus
2120
.docusaurus

README.md

+3-20
Original file line numberDiff line numberDiff line change
@@ -50,27 +50,10 @@ This library has a `peerDependencies` listing for `react-test-renderer`. Make su
5050

5151
### Additional Jest matchers
5252

53-
To use additional React Native-specific jest matchers from [@testing-library/jest-native](https://github.com/testing-library/jest-native) package add it to your project:
53+
You can use the built-in Jest matchers by adding the following line to your `jest-setup.ts` file (configured using [`setupFilesAfterEnv`](https://jestjs.io/docs/configuration#setupfilesafterenv-array)):
5454

55-
#### Using `yarn`
56-
57-
```sh
58-
yarn add --dev @testing-library/jest-native
59-
```
60-
61-
#### Using `npm`
62-
63-
```sh
64-
npm install --save-dev @testing-library/jest-native
65-
```
66-
67-
Then automatically add it to your jest tests by using the `setupFilesAfterEnv` option in your Jest configuration (it's usually located either in `package.json` under the `"jest"` key or in a `jest.config.json` file):
68-
69-
```json
70-
{
71-
"preset": "react-native",
72-
"setupFilesAfterEnv": ["@testing-library/jest-native/extend-expect"]
73-
}
55+
```ts
56+
import '@testing-library/react-native/extend-expect';
7457
```
7558

7659
### Custom Jest Preset (React Native before 0.71)

examples/basic/jest-setup.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/* eslint-disable no-undef, import/no-extraneous-dependencies */
22

3-
// Import Jest Native matchers
4-
import '@testing-library/jest-native/extend-expect';
3+
// Import built-in Jest matchers
4+
import '@testing-library/react-native/extend-expect';
55

66
// Silence the warning: Animated: `useNativeDriver` is not supported because the native animated module is missing
77
jest.mock('react-native/Libraries/Animated/NativeAnimatedHelper');

examples/basic/package.json

+1-2
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,7 @@
1919
},
2020
"devDependencies": {
2121
"@babel/core": "^7.20.0",
22-
"@testing-library/jest-native": "^5.4.3",
23-
"@testing-library/react-native": "^12.3.2",
22+
"@testing-library/react-native": "^12.3.3",
2423
"@types/react": "~18.2.14",
2524
"jest": "^29.7.0",
2625
"react-test-renderer": "18.2.0",

0 commit comments

Comments
 (0)