Browse Source

chore: React 18 test case (#34781)

* chore: add 18 test

* chore: update test flow

* chore: fail fast

* chore: foce ci

* chore: more if

* chore: test it

* chore: back of it

* chore: master only

* chore: fix spell

* chore: force install

* test: comment 16 tmp

* chore: use react 17

* chore: install 18

* chore: back of 16 & 17
pull/34791/head
二货机器人 3 years ago
committed by GitHub
parent
commit
2733977245
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 34
      .github/workflows/test.yml
  2. 5
      components/carousel/__tests__/index.test.js
  3. 2
      components/space/__tests__/index.test.js
  4. 9
      package.json

34
.github/workflows/test.yml

@ -23,7 +23,7 @@ jobs:
key: lock-${{ github.sha }}
- name: create package-lock.json
run: npm i --package-lock-only --ignore-scripts
run: npm i --package-lock-only --ignore-scripts --force
- name: hack for single file
run: |
@ -40,7 +40,7 @@ jobs:
- name: install
if: steps.node_modules_cache_id.outputs.cache-hit != 'true'
run: npm ci
run: npm ci --force
lint:
runs-on: ubuntu-latest
@ -232,6 +232,7 @@ jobs:
strategy:
matrix:
react: ['16', '17']
# react: ['17', '18']
module: ['dom', 'node', 'dist']
env:
REACT: ${{ matrix.react }}
@ -256,6 +257,14 @@ jobs:
if: ${{ matrix.react == '16' }}
run: npm run install-react-16
- name: install react 17
if: ${{ matrix.react == '17' }}
run: npm run install-react-17
- name: install react 18
if: ${{ matrix.react == '18' }}
run: npm run install-react-18
- name: restore cache from dist
if: ${{ matrix.module == 'dist' }}
uses: actions/cache@v3
@ -341,36 +350,55 @@ jobs:
strategy:
matrix:
react: ['16', '17']
# react: ['17', '18']
module: [lib, es]
env:
REACT: ${{ matrix.react }}
steps:
- name: checkout
# lib only run in master branch not in pull request
if: ${{ github.event_name != 'pull_request' || matrix.module != 'lib' }}
uses: actions/checkout@v3
- name: restore cache from package-lock.json
# lib only run in master branch not in pull request
if: ${{ github.event_name != 'pull_request' || matrix.module != 'lib' }}
uses: actions/cache@v3
with:
path: package-temp-dir
key: lock-${{ github.sha }}
- name: restore cache from node_modules
# lib only run in master branch not in pull request
if: ${{ github.event_name != 'pull_request' || matrix.module != 'lib' }}
uses: actions/cache@v3
with:
path: node_modules
key: node_modules-${{ hashFiles('**/package-temp-dir/package-lock.json') }}
- name: restore cache from ${{ matrix.module }}
# lib only run in master branch not in pull request
if: ${{ github.event_name != 'pull_request' || matrix.module != 'lib' }}
uses: actions/cache@v3
with:
path: ${{ matrix.module }}
key: ${{ matrix.module }}-${{ github.sha }}
- name: install react 16
if: ${{ matrix.react == '16' }}
if: ${{ matrix.react == '16' && (github.event_name != 'pull_request' || matrix.module != 'lib') }}
run: npm run install-react-16
- name: install react 17
if: ${{ matrix.react == '17' && (github.event_name != 'pull_request' || matrix.module != 'lib') }}
run: npm run install-react-17
- name: install react 18
if: ${{ matrix.react == '18' && (github.event_name != 'pull_request' || matrix.module != 'lib') }}
run: npm run install-react-18
- name: test
# lib only run in master branch not in pull request
if: ${{ github.event_name != 'pull_request' || matrix.module != 'lib' }}
run: npm test
env:
LIB_DIR: ${{ matrix.module }}

5
components/carousel/__tests__/index.test.js

@ -108,11 +108,6 @@ describe('Carousel', () => {
});
it('should keep initialSlide', () => {
// react unsafe lifecycle don't works in React 15
// https://github.com/akiran/react-slick/commit/97988e897750e1d8f7b10a86b655f50d75d38298
if (process.env.REACT === '15') {
return;
}
const wrapper = mount(<Carousel initialSlide={1} />);
wrapper.setProps({
children: [<div key="1" />, <div key="2" />, <div key="3" />],

2
components/space/__tests__/index.test.js

@ -1,6 +1,6 @@
import React, { useState } from 'react';
import { render, mount } from 'enzyme';
import { act } from 'react-test-renderer';
import { act } from 'react-dom/test-utils';
import Space from '..';
import ConfigProvider from '../../config-provider';
import mountTest from '../../../tests/shared/mountTest';

9
package.json

@ -99,7 +99,9 @@
"site:test": "jest --config .jest.site.js --cache=false --force-exit",
"test-image": "npm run dist && docker-compose run tests",
"version": "node ./scripts/generate-version",
"install-react-16": "npm i --no-save --legacy-peer-deps react@16 react-dom@16 react-test-renderer@16 enzyme-adapter-react-16",
"install-react-16": "npm i --no-save --legacy-peer-deps react@16 react-dom@16 enzyme-adapter-react-16",
"install-react-17": "npm i --no-save --legacy-peer-deps react@17 react-dom@17",
"install-react-18": "npm i --no-save --legacy-peer-deps react@18 react-dom@18",
"argos": "argos upload imageSnapshots"
},
"browserslist": [
@ -247,12 +249,12 @@
"rc-footer": "^0.6.6",
"rc-tween-one": "^3.0.3",
"rc-virtual-list": "^3.4.2",
"react": "^17.0.1",
"react": "^17.0.0",
"react-color": "^2.17.3",
"react-copy-to-clipboard": "^5.0.1",
"react-dnd": "^15.0.0",
"react-dnd-html5-backend": "^15.0.0",
"react-dom": "^17.0.1",
"react-dom": "^17.0.0",
"react-draggable": "^4.4.3",
"react-fast-marquee": "^1.2.1",
"react-github-button": "^0.1.11",
@ -264,7 +266,6 @@
"react-router-dom": "^6.0.2",
"react-sortable-hoc": "^2.0.0",
"react-sticky": "^6.0.3",
"react-test-renderer": "^17.0.1",
"react-text-loop-next": "0.0.3",
"react-window": "^1.8.5",
"remark": "^14.0.1",

Loading…
Cancel
Save