Skip to content

Commit

Permalink
fea(docs): add docs for testing with react native testing library
Browse files Browse the repository at this point in the history
  • Loading branch information
yjose committed Jan 6, 2025
1 parent 87b0032 commit 563d029
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions docs/pages/faq.md
Original file line number Diff line number Diff line change
Expand Up @@ -151,3 +151,39 @@ This is because the example app is configured as a Yarn workspace, and there is
```yml
nodeLinker: node-modules
```
## Testing with React Native testing library
To test with React Native testing library, you may need to use `@react-native/babel-preset` preset for test environment in `babel.config.js` file.

```js
// babel.config.js
module.exports = {
presets: ['module:react-native-builder-bob/babel-preset'],
env: {
test: {
presets: ['module:@react-native/babel-preset'],
},
},
};
```
Then update the jest config in your `package.json` file.

```json
// package.json
"jest": {
"preset": "react-native",
"modulePathIgnorePatterns": [
"<rootDir>/example/node_modules",
"<rootDir>/lib/"
],
"transformIgnorePatterns": [
"node_modules/(?!(jest-)?react-native|@react-native|@react-native-community|react-native-reanimated)"
],
"setupFilesAfterEnv": [
"@testing-library/react-native/extend-expect"
]
},
```

0 comments on commit 563d029

Please sign in to comment.