Skip to content

Commit 2093fbb

Browse files
Andaristtimdorr
authored andcommitted
Upgrade to babel@7 (#1043)
* Upgrade to babel@7 * Run tests for all versions of React in a single jest process * Add tests against [email protected] * Simplify test script * Remove unused getTestDeps.js files & adjusted CONTRIBUTING.md info * Create test directories if they are missing
1 parent bc7b6a9 commit 2093fbb

27 files changed

+10528
-34738
lines changed

.babelrc

-42
This file was deleted.

.babelrc.js

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
const { NODE_ENV, BABEL_ENV } = process.env
2+
const cjs = NODE_ENV === 'test' || BABEL_ENV === 'commonjs'
3+
const loose = true
4+
5+
module.exports = {
6+
presets: [['@babel/env', { loose, modules: false }]],
7+
plugins: [
8+
['@babel/proposal-decorators', { legacy: true }],
9+
['@babel/proposal-object-rest-spread', { loose }],
10+
'@babel/transform-react-jsx',
11+
cjs && ['@babel/transform-modules-commonjs', { loose }],
12+
['@babel/transform-runtime', { useESModules: !cjs }],
13+
].filter(Boolean),
14+
}

.travis.yml

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ env:
88
- REACT=16.2
99
- REACT=16.3
1010
- REACT=16.4
11+
- REACT=16.5
1112
sudo: false
1213
script:
1314
- npm run lint

CONTRIBUTING.md

+6-35
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,10 @@ To run in explicit React versions (the number is the version, so `test:16.3` wil
4545
REACT=16.4 npm run test:ci
4646
```
4747

48-
To run tests in all supported React versions, `0.14`, `15`, `16.2`, `16.3`, `16.4`,
48+
To run tests in all supported React versions, `0.14`, `15`, `16.2`, `16.3`, `16.4`, 16.5`,
4949
```
5050
REACT=all npm run test:ci
51-
```
51+
```
5252

5353
To continuously watch and run tests, run the following:
5454
```
@@ -71,7 +71,6 @@ test/
7171
XX/
7272
package.json
7373
test/
74-
getTestDeps.js
7574
```
7675

7776
So, for example, to test against React 15.4:
@@ -83,51 +82,22 @@ test/
8382
15.4/
8483
package.json
8584
test/
86-
getTestDeps.js
8785
```
8886

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:
87+
The package.json must include the correct versions of `react` & `react-dom`
88+
as well as the needed `create-react-class` like this:
9389

9490
```json
9591
{
9692
"private": true,
9793
"devDependencies": {
9894
"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",
10295
"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"
96+
"react-dom": "15.4"
11397
}
11498
}
11599
```
116100

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-
import enzyme from 'enzyme'
123-
import TestRenderer from 'react-test-renderer'
124-
import Adapter from 'enzyme-adapter-react-15.4'
125-
126-
enzyme.configure({ adapter: new Adapter() })
127-
128-
export { TestRenderer, enzyme }
129-
```
130-
131101
Then you can run tests against this version with:
132102

133103
```
@@ -156,6 +126,7 @@ env:
156126
- REACT=16.2
157127
- REACT=16.3
158128
- REACT=16.4
129+
- REACT=16.5
159130
sudo: false
160131
script:
161132
- npm run lint

0 commit comments

Comments
 (0)