You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: CONTRIBUTING.md
+116-2Lines changed: 116 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -35,21 +35,135 @@ npm run build:umd:min
35
35
36
36
### Testing and Linting
37
37
38
-
To run the tests:
38
+
To run the tests in the latest React version:
39
39
```
40
40
npm run test
41
41
```
42
42
43
+
To run in explicit React versions (the number is the version, so `test:16.3` will run in React version `16.3`):
44
+
```
45
+
REACT=16.4 npm run test:ci
46
+
```
47
+
48
+
To run tests in all supported React versions, `0.14`, `15`, `16.2`, `16.3`, `16.4`,
49
+
```
50
+
REACT=all npm run test:ci
51
+
```
52
+
43
53
To continuously watch and run tests, run the following:
44
54
```
45
-
npm run test:watch
55
+
npm run test -- --watch
46
56
```
47
57
48
58
To perform linting with `eslint`, run the following:
49
59
```
50
60
npm run lint
51
61
```
52
62
63
+
#### Adding a new React version for testing
64
+
65
+
To add a new version of React to test react-redux against, create a directory structure
66
+
in this format for React version `XX`:
67
+
68
+
```
69
+
test/
70
+
react/
71
+
XX/
72
+
package.json
73
+
test/
74
+
getTestDeps.js
75
+
```
76
+
77
+
So, for example, to test against React 15.4:
78
+
79
+
80
+
```
81
+
test/
82
+
react/
83
+
15.4/
84
+
package.json
85
+
test/
86
+
getTestDeps.js
87
+
```
88
+
89
+
The package.json must include the correct versions of `react`, `react-dom`,
90
+
`react-test-renderer` and the correct enzyme adapter for the React version
91
+
being used, as well as the needed `create-react-class`, `jest`, `enzyme` versions
92
+
and the `jest` and `scripts` sections copied verbatim like this:
93
+
94
+
```json
95
+
{
96
+
"private": true,
97
+
"devDependencies": {
98
+
"create-react-class": "^15.6.3",
99
+
"enzyme": "^3.3.0",
100
+
"enzyme-adapter-react-15.4": "^1.0.6",
101
+
"jest": "^23.4.2",
102
+
"react": "15.4",
103
+
"react-dom": "15.4",
104
+
"react-test-renderer": "15.4"
105
+
},
106
+
"jest": {
107
+
"testURL": "http://localhost",
108
+
"collectCoverage": true,
109
+
"coverageDirectory": "./coverage"
110
+
},
111
+
"scripts": {
112
+
"test": "jest"
113
+
}
114
+
}
115
+
```
116
+
117
+
`getTestDeps.js` should load the version-specific enzyme adapter and
118
+
test renderer (all versions newer than 0.14 use `react-test-renderer`,
119
+
0.14 uses `react-addons-test-utils`):
120
+
121
+
```js
122
+
importenzymefrom'enzyme'
123
+
importTestRendererfrom'react-test-renderer'
124
+
importAdapterfrom'enzyme-adapter-react-15.4'
125
+
126
+
enzyme.configure({ adapter:newAdapter() })
127
+
128
+
export { TestRenderer, enzyme }
129
+
```
130
+
131
+
Then you can run tests against this version with:
132
+
133
+
```
134
+
REACT=15.4 npm run test
135
+
```
136
+
137
+
and the new version will also be automatically included in
138
+
139
+
```
140
+
REACT=all npm run test
141
+
```
142
+
143
+
In addition, the new version should be added to the .travis.yml matrix list:
144
+
145
+
```yaml
146
+
language: node_js
147
+
node_js:
148
+
- "8"
149
+
before_install:
150
+
- 'nvm install-latest-npm'
151
+
env:
152
+
matrix:
153
+
- REACT=0.14
154
+
- REACT=15
155
+
- REACT=15.4
156
+
- REACT=16.2
157
+
- REACT=16.3
158
+
- REACT=16.4
159
+
sudo: false
160
+
script:
161
+
- npm run lint
162
+
- npm run test
163
+
after_success:
164
+
- npm run coverage
165
+
```
166
+
53
167
### New Features
54
168
55
169
Please open an issue with a proposal for a new feature or refactoring before starting on the work. We don't want you to waste your efforts on a pull request that we won't want to accept.
0 commit comments