提交 67fee48c 编写于 作者: W Wei Zhu

Run test against multiple react versions

上级 42e21938
......@@ -3,39 +3,27 @@ sudo: false
language: node_js
node_js:
- "8.5"
- 8
env:
matrix:
- TEST_TYPE=lint
- TEST_TYPE=test:dist
- TEST_TYPE=test:lib
- TEST_TYPE=test:es
- TEST_TYPE=test:dom
- TEST_TYPE=test:node
matrix:
fast_finish: true
include:
- env: TEST_TYPE=lint
- env: REACT=16 TEST_TYPE=test:dist
- env: REACT=16 TEST_TYPE=test:lib
- env: REACT=16 TEST_TYPE=test:es
- env: REACT=16 TEST_TYPE=test:dom
- env: REACT=16 TEST_TYPE=test:node
- env: REACT=15 TEST_TYPE=test:dist
- env: REACT=15 TEST_TYPE=test:lib
- env: REACT=15 TEST_TYPE=test:es
- env: REACT=15 TEST_TYPE=test:dom
- env: REACT=15 TEST_TYPE=test:node
allow_failures:
- env: REACT=16 TEST_TYPE=test:dist
before_script:
- export TZ=China/Beijing
- date
- scripts/install-react.sh
script:
- |
if [ "$TEST_TYPE" = lint ]; then
npm run lint
elif [ "$TEST_TYPE" = test:dist ]; then
npm run dist && \
node ./tests/dekko/dist.test.js && \
LIB_DIR=dist npm test -- -w 2
elif [ "$TEST_TYPE" = test:lib ]; then
npm run compile && \
node ./tests/dekko/lib.test.js && \
LIB_DIR=lib npm test -- -w 2
elif [ "$TEST_TYPE" = test:es ]; then
npm run compile && \
LIB_DIR=es npm test -- -w 2
elif [ "$TEST_TYPE" = test:dom ]; then
npm test -- --coverage -w 2 && \
bash <(curl -s https://codecov.io/bash)
elif [ "$TEST_TYPE" = test:node ]; then
npm run test-node -- -w 2
fi
- scripts/travis-script.sh
......@@ -12,6 +12,9 @@ describe('Form', () => {
describe('wrappedComponentRef', () => {
it('warns on functional component', () => {
if (process.env.REACT === '15') {
return;
}
const spy = jest.spyOn(console, 'error').mockImplementation(() => {});
const TestForm = () => <Form />;
const Wrapped = Form.create()(TestForm);
......
#!/bin/bash
set -x
if [ "$REACT" = 15 ]; then
npm i --no-save react@15 react-dom@15 react-test-renderer@15 enzyme-adapter-react-15
fi
#!/bin/bash
set -x
set -e
run_test() {
if [ "$REACT" != 16 ]; then
npm test -- -w 2 -u $*
else
npm test -- -w 2 $*
fi
}
if [ "$TEST_TYPE" = lint ]; then
npm run lint
elif [ "$TEST_TYPE" = test:dist ]; then
npm run dist
node ./tests/dekko/dist.test.js
LIB_DIR=dist run_test
elif [ "$TEST_TYPE" = test:lib ]; then
npm run compile
node ./tests/dekko/lib.test.js
LIB_DIR=lib run_test
elif [ "$TEST_TYPE" = test:es ]; then
npm run compile
LIB_DIR=es run_test
elif [ "$TEST_TYPE" = test:dom ]; then
run_test --coverage
if [ "$REACT" = 16 ]; then
bash <(curl -s https://codecov.io/bash)
fi
elif [ "$TEST_TYPE" = test:node ]; then
npm run test-node -- -w 2 -u
fi
/* eslint-disable global-require */
import { jsdom } from 'jsdom';
// fixed jsdom miss
......@@ -18,6 +19,12 @@ global.requestAnimationFrame = global.requestAnimationFrame || function (cb) {
};
const Enzyme = require('enzyme');
const Adapter = require('enzyme-adapter-react-16');
let Adapter;
if (process.env.REACT === '15') {
Adapter = require('enzyme-adapter-react-15');
} else {
Adapter = require('enzyme-adapter-react-16');
}
Enzyme.configure({ adapter: new Adapter() });
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册