Skip to content

Commit

Permalink
Upgrade to babel@7 (#1043)
Browse files Browse the repository at this point in the history
* Upgrade to babel@7

* Run tests for all versions of React in a single jest process

* Add tests against react@16.5

* Simplify test script

* Remove unused getTestDeps.js files & adjusted CONTRIBUTING.md info

* Create test directories if they are missing
  • Loading branch information
Andarist authored and timdorr committed Oct 24, 2018
1 parent bc7b6a9 commit 2093fbb
Show file tree
Hide file tree
Showing 27 changed files with 10,528 additions and 34,738 deletions.
42 changes: 0 additions & 42 deletions .babelrc

This file was deleted.

14 changes: 14 additions & 0 deletions .babelrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
const { NODE_ENV, BABEL_ENV } = process.env
const cjs = NODE_ENV === 'test' || BABEL_ENV === 'commonjs'
const loose = true

module.exports = {
presets: [['@babel/env', { loose, modules: false }]],
plugins: [
['@babel/proposal-decorators', { legacy: true }],
['@babel/proposal-object-rest-spread', { loose }],
'@babel/transform-react-jsx',
cjs && ['@babel/transform-modules-commonjs', { loose }],
['@babel/transform-runtime', { useESModules: !cjs }],
].filter(Boolean),
}
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ env:
- REACT=16.2
- REACT=16.3
- REACT=16.4
- REACT=16.5
sudo: false
script:
- npm run lint
Expand Down
41 changes: 6 additions & 35 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,10 @@ To run in explicit React versions (the number is the version, so `test:16.3` wil
REACT=16.4 npm run test:ci
```

To run tests in all supported React versions, `0.14`, `15`, `16.2`, `16.3`, `16.4`,
To run tests in all supported React versions, `0.14`, `15`, `16.2`, `16.3`, `16.4`, 16.5`,
```
REACT=all npm run test:ci
```
```

To continuously watch and run tests, run the following:
```
Expand All @@ -71,7 +71,6 @@ test/
XX/
package.json
test/
getTestDeps.js
```

So, for example, to test against React 15.4:
Expand All @@ -83,51 +82,22 @@ test/
15.4/
package.json
test/
getTestDeps.js
```

The package.json must include the correct versions of `react`, `react-dom`,
`react-test-renderer` and the correct enzyme adapter for the React version
being used, as well as the needed `create-react-class`, `jest`, `enzyme` versions
and the `jest` and `scripts` sections copied verbatim like this:
The package.json must include the correct versions of `react` & `react-dom`
as well as the needed `create-react-class` like this:

```json
{
"private": true,
"devDependencies": {
"create-react-class": "^15.6.3",
"enzyme": "^3.3.0",
"enzyme-adapter-react-15.4": "^1.0.6",
"jest": "^23.4.2",
"react": "15.4",
"react-dom": "15.4",
"react-test-renderer": "15.4"
},
"jest": {
"testURL": "http://localhost",
"collectCoverage": true,
"coverageDirectory": "./coverage"
},
"scripts": {
"test": "jest"
"react-dom": "15.4"
}
}
```

`getTestDeps.js` should load the version-specific enzyme adapter and
test renderer (all versions newer than 0.14 use `react-test-renderer`,
0.14 uses `react-addons-test-utils`):

```js
import enzyme from 'enzyme'
import TestRenderer from 'react-test-renderer'
import Adapter from 'enzyme-adapter-react-15.4'

enzyme.configure({ adapter: new Adapter() })

export { TestRenderer, enzyme }
```

Then you can run tests against this version with:

```
Expand Down Expand Up @@ -156,6 +126,7 @@ env:
- REACT=16.2
- REACT=16.3
- REACT=16.4
- REACT=16.5
sudo: false
script:
- npm run lint
Expand Down
Loading

0 comments on commit 2093fbb

Please sign in to comment.