diff --git a/.travis.yml b/.travis.yml index e055aede9f02d5eee1366f036fa3087f8fe28ab4..a118d4887a3531f9480aa3b6c92edc5e5b9f04c9 100644 --- a/.travis.yml +++ b/.travis.yml @@ -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 diff --git a/components/form/__tests__/index.test.js b/components/form/__tests__/index.test.js index 6acc500733337f15fdf7bd10772d0350fd931448..746a848123417897c1f8f99d308bcd0ff3fafb4d 100644 --- a/components/form/__tests__/index.test.js +++ b/components/form/__tests__/index.test.js @@ -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 = () =>
; const Wrapped = Form.create()(TestForm); diff --git a/package.json b/package.json index b46bf080b2993ada8984947488a5b5d26c9da631..b6c969a38fa57c4903810502418c6c65a298ad91 100644 --- a/package.json +++ b/package.json @@ -142,7 +142,6 @@ "react-infinite-scroller": "^1.0.15", "react-intl": "^2.0.1", "react-sublime-video": "^0.2.0", - "react-test-renderer": "^16.0.0", "react-virtualized": "^9.10.1", "remark-frontmatter": "^1.1.0", "remark-parse": "^4.0.0", diff --git a/scripts/install-react.sh b/scripts/install-react.sh new file mode 100755 index 0000000000000000000000000000000000000000..9f0e4d5e2e7bf1f90ebae2ac283694a14e43e455 --- /dev/null +++ b/scripts/install-react.sh @@ -0,0 +1,7 @@ +#!/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 diff --git a/scripts/travis-script.sh b/scripts/travis-script.sh new file mode 100755 index 0000000000000000000000000000000000000000..277bd3d2d070cca82d5bc56227ef7954fc561737 --- /dev/null +++ b/scripts/travis-script.sh @@ -0,0 +1,34 @@ +#!/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 diff --git a/tests/setup.js b/tests/setup.js index a8d7cb37d0b8987dbd2a1b158a0dea603dbb5c90..fa3a247a0bfe55cba575da4b3d414ae482c3ef02 100644 --- a/tests/setup.js +++ b/tests/setup.js @@ -1,3 +1,4 @@ +/* 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() });