Skip to content

Commit 63e9ec0

Browse files
hainenbercpojer
andauthored
chore: update React Native testing example project (#15832)
Co-authored-by: Christoph Nakazawa <[email protected]>
1 parent 70aa921 commit 63e9ec0

File tree

4 files changed

+260
-608
lines changed

4 files changed

+260
-608
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22

33
### Chore & Maintenance
44

5+
- `[*]` Update example repo for testing React Native projects ([#15832](https://github.com/jestjs/jest/pull/15832))
56
- `[*]` Update `jest-watch-typeahead` to v3 ([#15830](https://github.com/jestjs/jest/pull/15830))
7+
68
## Features
79

810
- `[jest-environment-jsdom-abstract]` Add support for JSDOM v27 ([#15834](https://github.com/jestjs/jest/pull/15834))

docs/TutorialReactNative.md

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,28 +5,26 @@ title: Testing React Native Apps
55

66
At Facebook, we use Jest to test [React Native](https://reactnative.dev/) applications.
77

8-
Get a deeper insight into testing a working React Native app example by reading the following series: [Part 1: Jest – Snapshot come into play](https://callstack.com/blog/testing-react-native-with-the-new-jest-part-1-snapshots-come-into-play/) and [Part 2: Jest – Redux Snapshots for your Actions and Reducers](https://callstack.com/blog/testing-react-native-with-the-new-jest-part-2-redux-snapshots-for-your-actions-and-reducers/).
8+
Get a deeper insight into testing a working React Native app example by reading the following series:
9+
10+
- [Part 1: Jest – Snapshot come into play](https://callstack.com/blog/testing-react-native-with-the-new-jest-part-1-snapshots-come-into-play/)
11+
- [Part 2: Jest – Redux Snapshots for your Actions and Reducers](https://callstack.com/blog/testing-react-native-with-the-new-jest-part-2-redux-snapshots-for-your-actions-and-reducers/).
912

1013
## Setup
1114

12-
Starting from react-native version 0.38, a Jest setup is included by default when running `react-native init`. The following configuration should be automatically added to your package.json file:
15+
Starting from react-native version 0.38, a Jest setup is included by default when running `npx @react-native-community/cli init`. The following configuration should be automatically added to your React Native's `jest.config.js` file:
1316

14-
```json
15-
{
16-
"scripts": {
17-
"test": "jest"
18-
},
19-
"jest": {
20-
"preset": "react-native"
21-
}
22-
}
17+
```js
18+
module.exports = {
19+
preset: 'react-native',
20+
};
2321
```
2422

2523
Run `yarn test` to run tests with Jest.
2624

2725
:::tip
2826

29-
If you are upgrading your react-native application and previously used the `jest-react-native` preset, remove the dependency from your `package.json` file and change the preset to `react-native` instead.
27+
If you are upgrading your react-native application and previously used the `jest-react-native` or `react-native` preset, remove the dependency from your `package.json` file and change the preset to `react-native` in `jest.config.js` instead.
3028

3129
:::
3230

@@ -133,7 +131,7 @@ The preset sets up the environment and is very opinionated and based on what we
133131

134132
### Environment
135133

136-
`react-native` ships with a Jest preset, so the `jest.preset` field of your `package.json` should point to `react-native`. The preset is a node environment that mimics the environment of a React Native app. Because it doesn't load any DOM or browser APIs, it greatly improves Jest's startup time.
134+
`react-native` ships with a Jest preset, so the `preset` field of your `jest.config.js` should point to `react-native`. The preset is a node environment that mimics the environment of a React Native app. Because it doesn't load any DOM or browser APIs, it greatly improves Jest's startup time.
137135

138136
### transformIgnorePatterns customization
139137

examples/react-native/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77
"test": "jest"
88
},
99
"dependencies": {
10-
"@react-native/babel-preset": "^0.79.2",
10+
"@react-native/babel-preset": "^0.81.1",
1111
"react": "18.3.1",
12-
"react-native": "0.76.6"
12+
"react-native": "0.81.4"
1313
},
1414
"devDependencies": {
1515
"@babel/core": "^7.27.4",

0 commit comments

Comments
 (0)