Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement testing in React 0.14, 15, 16, add wallaby.js, use enzyme #984

Merged
merged 27 commits into from Aug 3, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
a84f1e9
begin work
cellog Jul 25, 2018
a2efb5d
Fix tests in 0.14, 15, and 16
cellog Jul 25, 2018
ab6f165
remove 15.4, not really necessary and it requires a tweak to the inst…
cellog Jul 26, 2018
cf436c9
fix 2 major potential issues
cellog Jul 26, 2018
c974795
update contributing docs and add missing test:watch
cellog Jul 26, 2018
bfd167e
re-work to use subdirectories for testing specific react versions
cellog Jul 30, 2018
85f9a27
fully working! with merged coverage!
cellog Jul 30, 2018
4aef279
fix linting, remove unnecessary file
cellog Jul 31, 2018
9173e32
fix test:watch
cellog Jul 31, 2018
90388aa
fix travis tests to run in parallel for each version
cellog Jul 31, 2018
2a4fe9d
oops, didn't make travis run the CI test
cellog Jul 31, 2018
35ddbd5
sigh... npm syntax error
cellog Jul 31, 2018
a8249a8
speed up test suites by only installing the specific version needed
cellog Jul 31, 2018
283e12e
remove unused plugin
cellog Aug 1, 2018
2deaefc
simplify test script options in package.json
cellog Aug 1, 2018
9a9c7ff
simpler gitignore
cellog Aug 1, 2018
44e94f6
remove unnecessary coverage merging, codecov does that automagically
cellog Aug 1, 2018
e52b97b
simplify test running
cellog Aug 1, 2018
232030a
new docs on testing specific React versions
cellog Aug 1, 2018
94d0f3c
move scripts to test/, remove unused dep
cellog Aug 1, 2018
c2c62a3
revert unintentional cosmetic changes
cellog Aug 1, 2018
8a778a8
add default version for "npm test"
cellog Aug 1, 2018
42c4cd8
revert unintentional cosmetic changes to test import order
cellog Aug 1, 2018
1a6550a
restore the correct test renderer version
cellog Aug 1, 2018
6e38790
fix travis, add a note about the matrix needing update on adding a Re…
cellog Aug 1, 2018
dfe68f1
Add cross-spawn dependency
markerikson Aug 3, 2018
dc75723
Use cross-spawn for consistent NPM installations cross-platform
markerikson Aug 3, 2018
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 0 additions & 1 deletion .babelrc
Expand Up @@ -25,7 +25,6 @@
"env": {
"test": {
"plugins": [
"istanbul",
["transform-es2015-modules-commonjs", { "loose": true }]
]
},
Expand Down
5 changes: 5 additions & 0 deletions .gitignore
Expand Up @@ -6,3 +6,8 @@ lib
.nyc_output
coverage
es
test/**/lcov.info
test/**/lcov-report
test/react/*/test/**/*.spec.js
test/react/**/src
lcov.info
12 changes: 11 additions & 1 deletion .travis.yml
@@ -1,8 +1,18 @@
language: node_js
node_js:
- "8"
before_install:
- 'nvm install-latest-npm'
env:
matrix:
- REACT=0.14
- REACT=15
- REACT=16.2
- REACT=16.3
- REACT=16.4
sudo: false
script:
- npm run lint
- npm test
- npm run test
after_success:
- npm run coverage
118 changes: 116 additions & 2 deletions CONTRIBUTING.md
Expand Up @@ -35,21 +35,135 @@ npm run build:umd:min

### Testing and Linting

To run the tests:
To run the tests in the latest React version:
```
npm run test
```

To run in explicit React versions (the number is the version, so `test:16.3` will run in React version `16.3`):
```
REACT=16.4 npm run test:ci
```

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

To continuously watch and run tests, run the following:
```
npm run test:watch
npm run test -- --watch
```

To perform linting with `eslint`, run the following:
```
npm run lint
```

#### Adding a new React version for testing

To add a new version of React to test react-redux against, create a directory structure
in this format for React version `XX`:

```
test/
react/
XX/
package.json
test/
getTestDeps.js
```

So, for example, to test against React 15.4:


```
test/
react/
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:

```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"
}
}
```

`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:

```
REACT=15.4 npm run test
```

and the new version will also be automatically included in

```
REACT=all npm run test
```

In addition, the new version should be added to the .travis.yml matrix list:

```yaml
language: node_js
node_js:
- "8"
before_install:
- 'nvm install-latest-npm'
env:
matrix:
- REACT=0.14
- REACT=15
- REACT=15.4
- REACT=16.2
- REACT=16.3
- REACT=16.4
sudo: false
script:
- npm run lint
- npm run test
after_success:
- npm run coverage
```

### New Features

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.
Expand Down