Skip to content

Commit ff10a3a

Browse files
author
Damian Sznajder
committed
Merge branch 'master' into AugustinLF/non-recursive-text-match-options
2 parents e1ad2b4 + ffda1de commit ff10a3a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

84 files changed

+5055
-3626
lines changed

.circleci/config.yml

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ aliases:
1212

1313
defaults: &defaults
1414
docker:
15-
- image: circleci/node:10
15+
- image: circleci/node:12
1616
working_directory: ~/react-native-testing-library
1717

1818
jobs:
@@ -65,6 +65,13 @@ jobs:
6565
at: ~/react-native-testing-library
6666
- run: |
6767
cd website && yarn install && yarn build
68+
test-examples:
69+
<<: *defaults
70+
steps:
71+
- attach_workspace:
72+
at: ~/react-native-testing-library
73+
- run: |
74+
ls -d ./examples/* | xargs -I {} bash -c "cd '{}' && yarn install && yarn test"
6875
deploy-website:
6976
<<: *defaults
7077
steps:
@@ -96,6 +103,10 @@ workflows:
96103
- install-dependencies
97104
# docusuarus build is running when deploying website as well
98105
filters: *filter-ignore-master
106+
- test-examples:
107+
requires:
108+
- install-dependencies
109+
filters: *filter-only-master
99110
- deploy-website:
100111
requires:
101112
- install-dependencies

.flowconfig

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@ emoji=true
3232
esproposal.optional_chaining=enable
3333
esproposal.nullish_coalescing=enable
3434

35+
well_formed_exports=true
36+
types_first=true
37+
3538
module.file_ext=.js
3639
module.file_ext=.json
3740
module.file_ext=.ios.js
@@ -41,15 +44,6 @@ munge_underscores=true
4144
module.name_mapper='^react-native/\(.*\)$' -> '<PROJECT_ROOT>/node_modules/react-native/\1'
4245
module.name_mapper='^@?[./a-zA-Z0-9$_-]+\.\(bmp\|gif\|jpg\|jpeg\|png\|psd\|svg\|webp\|m4v\|mov\|mp4\|mpeg\|mpg\|webm\|aac\|aiff\|caf\|m4a\|mp3\|wav\|html\|pdf\)$' -> '<PROJECT_ROOT>/node_modules/react-native/Libraries/Image/RelativeImageStub'
4346

44-
suppress_type=$FlowIssue
45-
suppress_type=$FlowFixMe
46-
suppress_type=$FlowFixMeProps
47-
suppress_type=$FlowFixMeState
48-
49-
suppress_comment=\\(.\\|\n\\)*\\$FlowFixMe\\($\\|[^(]\\|(\\(<VERSION>\\)? *\\(site=[a-z,_]*react_native\\(_ios\\)?_\\(oss\\|fb\\)[a-z,_]*\\)?)\\)
50-
suppress_comment=\\(.\\|\n\\)*\\$FlowIssue\\((\\(<VERSION>\\)? *\\(site=[a-z,_]*react_native\\(_ios\\)?_\\(oss\\|fb\\)[a-z,_]*\\)?)\\)?:? #[0-9]+
51-
suppress_comment=\\(.\\|\n\\)*\\$FlowExpectedError
52-
5347
[lints]
5448
sketchy-null-number=warn
5549
sketchy-null-mixed=warn

.github/dependabot.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: npm
4+
directory: "/"
5+
schedule:
6+
interval: monthly
7+
open-pull-requests-limit: 10
8+
ignore:
9+
- dependency-name: react-native
10+
versions:
11+
- 0.64.0-rc.3
12+
- dependency-name: "@babel/preset-env"
13+
versions:
14+
- 7.13.8
15+
- dependency-name: flow-bin
16+
versions:
17+
- 0.143.1
18+
- 0.145.0
19+
- dependency-name: "@types/react-native"
20+
versions:
21+
- 0.63.43

README.md

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ This library has a peerDependencies listing for `react-test-renderer` and, of co
5050
5151
### Additional Jest matchers
5252

53-
In order to use addtional React Native-specific jest matchers from [@testing-library/jest-native](https://github.com/testing-library/jest-native) package add it to your project:
53+
In order 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:
5454

5555
#### Using `yarn`
5656

@@ -64,7 +64,7 @@ yarn add --dev @testing-library/jest-native
6464
npm install --save-dev @testing-library/jest-native
6565
```
6666

67-
Then automatically add it to your jest tests by using `setupFilesAfterEnv` option in your Jest configuration (it's usually located either in `package.json` under `"jest"` key or in a `jest.config.js` file):
67+
Then automatically add it to your jest tests by using `setupFilesAfterEnv` option in your Jest configuration (it's usually located either in `package.json` under `"jest"` key or in a `jest.config.json` file):
6868

6969
```json
7070
{
@@ -73,6 +73,24 @@ Then automatically add it to your jest tests by using `setupFilesAfterEnv` optio
7373
}
7474
```
7575

76+
### Custom Jest Preset
77+
78+
> **important** if you use "modern" Fake Timers
79+
80+
We generally advise to use the "react-native" preset when testing with this library. However, if you use ["modern" Fake Timers](https://jestjs.io/blog/2020/05/05/jest-26#new-fake-timers) (default since Jest 27), you'll need to apply our custom Jest preset or awaiting promises, like `waitFor`, will timeout.
81+
82+
This is a [known issue](https://github.com/facebook/react-native/issues/29303). It happens because React Native's Jest preset overrides native Promise. Our preset restores it to defaults, which is not a problem in most apps out there.
83+
84+
Here's how you apply a custom preset in your Jest config:
85+
86+
```json
87+
{
88+
"preset": "@testing-library/react-native"
89+
}
90+
```
91+
92+
If this doesn't work for you, please fall back to using "legacy" fake timers.
93+
7694
### Flow
7795

7896
Note for [Flow](https://flow.org) users – you'll also need to install typings for `react-test-renderer`:
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import 'react-native-gesture-handler/jestSetup';
2+
3+
jest.mock('react-native-reanimated', () => {
4+
const Reanimated = require('react-native-reanimated/mock');
5+
6+
// The mock for `call` immediately calls the callback which is incorrect
7+
// So we override it with a no-op
8+
Reanimated.default.call = () => {};
9+
10+
return Reanimated;
11+
});
12+
13+
// Silence the warning: Animated: `useNativeDriver` is not supported because the native animated module is missing
14+
jest.mock('react-native/Libraries/Animated/src/NativeAnimatedHelper');

examples/reactnavigation/jest.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module.exports = {
22
preset: 'react-native',
3-
setupFiles: ['./node_modules/react-native-gesture-handler/jestSetup.js'],
3+
setupFiles: ['./jest-setup.js'],
44
transformIgnorePatterns: [
55
'node_modules/(?!(jest-)?react-native|@react-native-community|@react-navigation)',
66
],

examples/reactnavigation/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
},
99
"dependencies": {
1010
"@react-native-community/masked-view": "^0.1.9",
11+
"@react-navigation/drawer": "^5.11.4",
1112
"@react-navigation/native": "^5.1.6",
1213
"@react-navigation/stack": "^5.2.13",
1314
"prop-types": "^15.7.2",

examples/reactnavigation/src/App.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import 'react-native-gesture-handler';
12
import React from 'react';
23
import { StatusBar, StyleSheet, View } from 'react-native';
34
import { NavigationContainer } from '@react-navigation/native';
@@ -9,7 +10,6 @@ export default function App() {
910
<NavigationContainer>
1011
<View style={styles.container}>
1112
<StatusBar barStyle="dark-content" />
12-
1313
<AppNavigator />
1414
</View>
1515
</NavigationContainer>

examples/reactnavigation/src/AppNavigator.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
import 'react-native-gesture-handler';
2-
import React from 'react';
1+
import * as React from 'react';
32
import { createStackNavigator } from '@react-navigation/stack';
43

54
import HomeScreen from './screens/HomeScreen';
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import 'react-native-gesture-handler';
2+
import React from 'react';
3+
import { NavigationContainer } from '@react-navigation/native';
4+
5+
import DrawerAppNavigator from './DrawerAppNavigator';
6+
7+
export default function DrawerApp() {
8+
return (
9+
<NavigationContainer>
10+
<DrawerAppNavigator />
11+
</NavigationContainer>
12+
);
13+
}

0 commit comments

Comments
 (0)