update ci test configuration

This commit is contained in:
ShenWen Yin 2021-09-22 18:59:50 +08:00 committed by Sczlog
parent 18fc31e7a7
commit 06d8f66f7e
14 changed files with 207 additions and 63 deletions

View File

@ -1,7 +0,0 @@
// only for jest
module.exports = {
presets: [
['@babel/preset-env', { targets: { node: 'current' } }],
'@babel/preset-typescript',
],
};

View File

@ -0,0 +1,7 @@
module.exports = {
presets: [
['@babel/preset-env', { targets: 'defaults' }],
'@babel/preset-typescript',
'@babel/preset-react',
],
};

View File

@ -0,0 +1,3 @@
module.exports = {
presets: ['@babel/preset-env', '@babel/preset-typescript'],
};

17
config/jest.ci.config.js Normal file
View File

@ -0,0 +1,17 @@
module.exports = {
rootDir: process.cwd(),
projects: ['<rootDir>/packages/core', '<rootDir>/packages/runtime'],
collectCoverage: true,
collectCoverageFrom: ['**/src/**/*.[jt]s?(x)'],
coveragePathIgnorePatterns: [],
coverageReporters: ['text-summary', 'lcov'],
coverageThreshold: {
global: {
//FIXME: increase the threshold after add unit test
branches: 0,
functions: 0,
lines: 0,
// statements: -5,
},
},
};

View File

@ -1,28 +0,0 @@
const path = require('path');
module.exports = {
moduleFileExtensions: ['ts', 'js'],
testEnvironment: 'node',
maxWorkers: '50%',
rootDir: process.cwd(),
// The UI and server packages should follow its jest config
projects: ['<rootDir>/packages/core', '<rootDir>/packages/runtime'],
collectCoverage: true,
collectCoverageFrom: ['**/src/**/*.ts'],
coveragePathIgnorePatterns: [],
coverageReporters: ['text-summary', 'lcov'],
coverageThreshold: {
global: {
//FIXME: increase the threshold to
branches: 0,
functions: 0,
lines: 0,
// statements: -5,
},
},
reporters:
process.env.CI_COMMIT_REF_NAME === 'master' ||
process.env.CI_BUILD_REF_NAME === 'master'
? ['default', '<rootDir>/config/testrail-reporter.js']
: undefined,
};

View File

@ -1,8 +1,8 @@
module.exports = {
moduleFileExtensions: ["ts", "js"],
testMatch: ["<rootDir>/__tests__/**/**.spec.ts"],
testPathIgnorePatterns: ["/node_modules/", "/lib/", "<rootDir>/lib/"],
maxWorkers: '50%',
testMatch: ['<rootDir>/__tests__/**/**.spec.[jt]s?(x)'],
testPathIgnorePatterns: ['/node_modules/', '/lib/', '<rootDir>/lib/'],
collectCoverage: Boolean(process.env.COVERAGE),
collectCoverageFrom: ["<rootDir>/src/**/*.ts"],
coveragePathIgnorePatterns: ["generated"],
collectCoverageFrom: ['<rootDir>/src/**/*.ts?(x)'],
coveragePathIgnorePatterns: ['generated'],
};

View File

@ -3,8 +3,8 @@
"private": true,
"scripts": {
"lerna": "lerna",
"prepublish:ci": "lerna run prepublish",
"test:ci": "jest -c config/jest.ci.js",
"prepublish": "lerna run prepublish",
"test:ci": "jest -c config/jest.ci.config.js",
"lint": "eslint packages --ext .ts --ext .tsx",
"fix-lint": "eslint --fix packages --ext .ts --ext .tsx"
},

View File

@ -1,7 +0,0 @@
// only for jest
module.exports = {
presets: [
['@babel/preset-env', { targets: { node: 'current' } }],
'@babel/preset-typescript',
],
};

View File

@ -1,3 +1,17 @@
const path = require('path');
module.exports = {
...require("../../config/jest.config"),
...require('../../config/jest.config'),
moduleFileExtensions: ['ts', 'js'],
testEnvironment: 'node',
transform: {
'^.+\\.[jt]sx?$': [
'babel-jest',
{
configFile: path.resolve(
__dirname,
'../../config/babel.ts.config.js'
),
},
],
},
};

View File

@ -0,0 +1,32 @@
import { render } from '@testing-library/react';
import Text from '../../src/components/_internal/Text';
import React from 'react';
describe('Text component', () => {
it('should render plain text', () => {
const { queryByText } = render(
<Text
value={{
raw: 'plain text',
format: 'plain',
}}></Text>
);
const ele = queryByText(/text/i);
expect(ele).toBeTruthy();
expect(ele.innerHTML).toMatchInlineSnapshot(`"plain text"`);
});
it('should render markdown text', () => {
const { queryByText } = render(
<Text
value={{
raw: '**plain** text',
format: 'md',
}}></Text>
);
const ele = queryByText(/text/i);
expect(ele).toBeTruthy();
expect(ele.innerHTML).toMatchInlineSnapshot(
`"<strong>plain</strong> text"`
);
});
});

View File

@ -1,7 +0,0 @@
// only for jest
module.exports = {
presets: [
['@babel/preset-env', { targets: { node: 'current' } }],
'@babel/preset-typescript',
],
};

View File

@ -1,3 +1,18 @@
const path = require('path');
module.exports = {
...require("../../config/jest.config"),
...require('../../config/jest.config'),
moduleFileExtensions: ['ts', 'js', 'tsx'],
testEnvironment: 'jsdom',
transform: {
'^.+\\.[jt]sx?$': [
'babel-jest',
{
configFile: path.resolve(
__dirname,
'../../config/babel.react.config.js'
),
},
],
},
testEnvironment: 'jsdom',
};

View File

@ -31,7 +31,9 @@
"devDependencies": {
"@babel/core": "^7.15.5",
"@babel/preset-env": "^7.15.4",
"@babel/preset-react": "^7.14.5",
"@babel/preset-typescript": "^7.15.0",
"@testing-library/react": "^12.1.0",
"@types/lodash": "^4.14.170",
"@types/prismjs": "^1.16.6",
"@types/react": "^17.0.0",

113
yarn.lock
View File

@ -9,7 +9,7 @@
dependencies:
"@babel/highlight" "^7.10.4"
"@babel/code-frame@^7.0.0", "@babel/code-frame@^7.12.13", "@babel/code-frame@^7.14.5":
"@babel/code-frame@^7.0.0", "@babel/code-frame@^7.10.4", "@babel/code-frame@^7.12.13", "@babel/code-frame@^7.14.5":
version "7.14.5"
resolved "https://registry.yarnpkg.com/@babel/code-frame/-/code-frame-7.14.5.tgz#23b08d740e83f49c5e59945fbf1b43e80bbf4edb"
integrity sha512-9pzDqyc6OLDaqe+zbACgFkb6fKMNG6CObKpnYXChRsvYGyEdc7CA2BaqeOM+vOtCS5ndmJicPJhKAwYRI6UfFw==
@ -456,7 +456,7 @@
dependencies:
"@babel/helper-plugin-utils" "^7.8.0"
"@babel/plugin-syntax-jsx@^7.12.13":
"@babel/plugin-syntax-jsx@^7.12.13", "@babel/plugin-syntax-jsx@^7.14.5":
version "7.14.5"
resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-jsx/-/plugin-syntax-jsx-7.14.5.tgz#000e2e25d8673cce49300517a3eda44c263e4201"
integrity sha512-ohuFIsOMXJnbOMRfX7/w7LocdR6R7whhuRD4ax8IipLcLPlZGJKkBxgHp++U4N/vKyU16/YDQr2f5seajD3jIw==
@ -709,6 +709,20 @@
dependencies:
"@babel/helper-plugin-utils" "^7.14.5"
"@babel/plugin-transform-react-display-name@^7.14.5":
version "7.15.1"
resolved "https://registry.yarnpkg.com/@babel/plugin-transform-react-display-name/-/plugin-transform-react-display-name-7.15.1.tgz#6aaac6099f1fcf6589d35ae6be1b6e10c8c602b9"
integrity sha512-yQZ/i/pUCJAHI/LbtZr413S3VT26qNrEm0M5RRxQJA947/YNYwbZbBaXGDrq6CG5QsZycI1VIP6d7pQaBfP+8Q==
dependencies:
"@babel/helper-plugin-utils" "^7.14.5"
"@babel/plugin-transform-react-jsx-development@^7.14.5":
version "7.14.5"
resolved "https://registry.yarnpkg.com/@babel/plugin-transform-react-jsx-development/-/plugin-transform-react-jsx-development-7.14.5.tgz#1a6c73e2f7ed2c42eebc3d2ad60b0c7494fcb9af"
integrity sha512-rdwG/9jC6QybWxVe2UVOa7q6cnTpw8JRRHOxntG/h6g/guAOe6AhtQHJuJh5FwmnXIT1bdm5vC2/5huV8ZOorQ==
dependencies:
"@babel/plugin-transform-react-jsx" "^7.14.5"
"@babel/plugin-transform-react-jsx-self@^7.14.5":
version "7.14.9"
resolved "https://registry.yarnpkg.com/@babel/plugin-transform-react-jsx-self/-/plugin-transform-react-jsx-self-7.14.9.tgz#33041e665453391eb6ee54a2ecf3ba1d46bd30f4"
@ -723,6 +737,25 @@
dependencies:
"@babel/helper-plugin-utils" "^7.14.5"
"@babel/plugin-transform-react-jsx@^7.14.5":
version "7.14.9"
resolved "https://registry.yarnpkg.com/@babel/plugin-transform-react-jsx/-/plugin-transform-react-jsx-7.14.9.tgz#3314b2163033abac5200a869c4de242cd50a914c"
integrity sha512-30PeETvS+AeD1f58i1OVyoDlVYQhap/K20ZrMjLmmzmC2AYR/G43D4sdJAaDAqCD3MYpSWbmrz3kES158QSLjw==
dependencies:
"@babel/helper-annotate-as-pure" "^7.14.5"
"@babel/helper-module-imports" "^7.14.5"
"@babel/helper-plugin-utils" "^7.14.5"
"@babel/plugin-syntax-jsx" "^7.14.5"
"@babel/types" "^7.14.9"
"@babel/plugin-transform-react-pure-annotations@^7.14.5":
version "7.14.5"
resolved "https://registry.yarnpkg.com/@babel/plugin-transform-react-pure-annotations/-/plugin-transform-react-pure-annotations-7.14.5.tgz#18de612b84021e3a9802cbc212c9d9f46d0d11fc"
integrity sha512-3X4HpBJimNxW4rhUy/SONPyNQHp5YRr0HhJdT2OH1BRp0of7u3Dkirc7x9FRJMKMqTBI079VZ1hzv7Ouuz///g==
dependencies:
"@babel/helper-annotate-as-pure" "^7.14.5"
"@babel/helper-plugin-utils" "^7.14.5"
"@babel/plugin-transform-regenerator@^7.14.5":
version "7.14.5"
resolved "https://registry.yarnpkg.com/@babel/plugin-transform-regenerator/-/plugin-transform-regenerator-7.14.5.tgz#9676fd5707ed28f522727c5b3c0aa8544440b04f"
@ -887,6 +920,18 @@
"@babel/types" "^7.4.4"
esutils "^2.0.2"
"@babel/preset-react@^7.14.5":
version "7.14.5"
resolved "https://registry.yarnpkg.com/@babel/preset-react/-/preset-react-7.14.5.tgz#0fbb769513f899c2c56f3a882fa79673c2d4ab3c"
integrity sha512-XFxBkjyObLvBaAvkx1Ie95Iaq4S/GUEIrejyrntQ/VCMKUYvKLoyKxOBzJ2kjA3b6rC9/KL6KXfDC2GqvLiNqQ==
dependencies:
"@babel/helper-plugin-utils" "^7.14.5"
"@babel/helper-validator-option" "^7.14.5"
"@babel/plugin-transform-react-display-name" "^7.14.5"
"@babel/plugin-transform-react-jsx" "^7.14.5"
"@babel/plugin-transform-react-jsx-development" "^7.14.5"
"@babel/plugin-transform-react-pure-annotations" "^7.14.5"
"@babel/preset-typescript@^7.15.0":
version "7.15.0"
resolved "https://registry.yarnpkg.com/@babel/preset-typescript/-/preset-typescript-7.15.0.tgz#e8fca638a1a0f64f14e1119f7fe4500277840945"
@ -896,7 +941,15 @@
"@babel/helper-validator-option" "^7.14.5"
"@babel/plugin-transform-typescript" "^7.15.0"
"@babel/runtime@^7.0.0", "@babel/runtime@^7.12.13", "@babel/runtime@^7.13.10", "@babel/runtime@^7.7.2", "@babel/runtime@^7.8.4":
"@babel/runtime-corejs3@^7.10.2":
version "7.15.4"
resolved "https://registry.yarnpkg.com/@babel/runtime-corejs3/-/runtime-corejs3-7.15.4.tgz#403139af262b9a6e8f9ba04a6fdcebf8de692bf1"
integrity sha512-lWcAqKeB624/twtTc3w6w/2o9RqJPaNBhPGK6DKLSiwuVWC7WFkypWyNg+CpZoyJH0jVzv1uMtXZ/5/lQOLtCg==
dependencies:
core-js-pure "^3.16.0"
regenerator-runtime "^0.13.4"
"@babel/runtime@^7.0.0", "@babel/runtime@^7.10.2", "@babel/runtime@^7.12.13", "@babel/runtime@^7.12.5", "@babel/runtime@^7.13.10", "@babel/runtime@^7.7.2", "@babel/runtime@^7.8.4":
version "7.15.4"
resolved "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.15.4.tgz#fd17d16bfdf878e6dd02d19753a39fa8a8d9c84a"
integrity sha512-99catp6bHCaxr4sJ/DbTGgHS4+Rs2RVd2g7iOap6SLGPDknRK9ztKNsE/Fg6QhSeh1FGE5f6gHGQmvvn3I3xhw==
@ -927,7 +980,7 @@
debug "^4.1.0"
globals "^11.1.0"
"@babel/types@^7.0.0", "@babel/types@^7.15.4", "@babel/types@^7.15.6", "@babel/types@^7.3.0", "@babel/types@^7.3.3", "@babel/types@^7.4.4":
"@babel/types@^7.0.0", "@babel/types@^7.14.9", "@babel/types@^7.15.4", "@babel/types@^7.15.6", "@babel/types@^7.3.0", "@babel/types@^7.3.3", "@babel/types@^7.4.4":
version "7.15.6"
resolved "https://registry.yarnpkg.com/@babel/types/-/types-7.15.6.tgz#99abdc48218b2881c058dd0a7ab05b99c9be758f"
integrity sha512-BPU+7QhqNjmWyDO0/vitH/CuhpV8ZmK1wpKva8nuyNF5MJfuRNWMc+hc14+u9xT93kvykMdncrJT19h74uB1Ig==
@ -2761,11 +2814,38 @@
dependencies:
"@sinonjs/commons" "^1.7.0"
"@testing-library/dom@^8.0.0":
version "8.5.0"
resolved "https://registry.yarnpkg.com/@testing-library/dom/-/dom-8.5.0.tgz#56e31331015f943a68c6ec27e259fdf16c69ab7d"
integrity sha512-O0fmHFaPlqaYCpa/cBL0cvroMridb9vZsMLacgIqrlxj+fd+bGF8UfAgwsLCHRF84KLBafWlm9CuOvxeNTlodw==
dependencies:
"@babel/code-frame" "^7.10.4"
"@babel/runtime" "^7.12.5"
"@types/aria-query" "^4.2.0"
aria-query "^4.2.2"
chalk "^4.1.0"
dom-accessibility-api "^0.5.6"
lz-string "^1.4.4"
pretty-format "^27.0.2"
"@testing-library/react@^12.1.0":
version "12.1.0"
resolved "https://registry.yarnpkg.com/@testing-library/react/-/react-12.1.0.tgz#3e9a4002b0b8f986a738a2f88fc458b5af319f35"
integrity sha512-Ge3Ht3qXE82Yv9lyPpQ7ZWgzo/HgOcHu569Y4ZGWcZME38iOFiOg87qnu6hTEa8jTJVL7zYovnvD3GE2nsNIoQ==
dependencies:
"@babel/runtime" "^7.12.5"
"@testing-library/dom" "^8.0.0"
"@tootallnate/once@1":
version "1.1.2"
resolved "https://registry.yarnpkg.com/@tootallnate/once/-/once-1.1.2.tgz#ccb91445360179a04e7fe6aff78c00ffc1eeaf82"
integrity sha512-RbzJvlNzmRq5c3O09UipeuXno4tA1FE6ikOjxZK0tuxVv3412l64l5t1W5pj4+rJq9vpkm/kwiR07aZXnsKPxw==
"@types/aria-query@^4.2.0":
version "4.2.2"
resolved "https://registry.yarnpkg.com/@types/aria-query/-/aria-query-4.2.2.tgz#ed4e0ad92306a704f9fb132a0cfcf77486dbe2bc"
integrity sha512-HnYpAE1Y6kRyKM/XkEuiRQhTHvkzMBurTHnpFLYLBGPIylZNPs9jJcuOOYWxPLJCSEtmZT0Y8rHDokKN7rRTig==
"@types/babel__core@^7.0.0", "@types/babel__core@^7.1.14":
version "7.1.16"
resolved "https://registry.yarnpkg.com/@types/babel__core/-/babel__core-7.1.16.tgz#bc12c74b7d65e82d29876b5d0baf5c625ac58702"
@ -3254,6 +3334,14 @@ aria-hidden@^1.1.1:
dependencies:
tslib "^1.0.0"
aria-query@^4.2.2:
version "4.2.2"
resolved "https://registry.yarnpkg.com/aria-query/-/aria-query-4.2.2.tgz#0d2ca6c9aceb56b8977e9fed6aed7e15bbd2f83b"
integrity sha512-o/HelwhuKpTj/frsOsbNLNgnNGVIFsVP/SW2BSF14gVl7kAfMOJ6/8wUAUvG1R1NHKrfG+2sHZTu0yauT1qBrA==
dependencies:
"@babel/runtime" "^7.10.2"
"@babel/runtime-corejs3" "^7.10.2"
array-differ@^3.0.0:
version "3.0.0"
resolved "https://registry.yarnpkg.com/array-differ/-/array-differ-3.0.0.tgz#3cbb3d0f316810eafcc47624734237d6aee4ae6b"
@ -3935,6 +4023,11 @@ core-js-compat@^3.14.0, core-js-compat@^3.16.0:
browserslist "^4.17.0"
semver "7.0.0"
core-js-pure@^3.16.0:
version "3.18.0"
resolved "https://registry.yarnpkg.com/core-js-pure/-/core-js-pure-3.18.0.tgz#e5187347bae66448c9e2d67c01c34c4df3261dc5"
integrity sha512-ZnK+9vyuMhKulIGqT/7RHGRok8RtkHMEX/BGPHkHx+ouDkq+MUvf9mfIgdqhpmPDu8+V5UtRn/CbCRc9I4lX4w==
core-util-is@1.0.2:
version "1.0.2"
resolved "https://registry.yarnpkg.com/core-util-is/-/core-util-is-1.0.2.tgz#b5fd54220aa2bc5ab57aab7140c940754503c1a7"
@ -4179,6 +4272,11 @@ doctrine@^3.0.0:
dependencies:
esutils "^2.0.2"
dom-accessibility-api@^0.5.6:
version "0.5.7"
resolved "https://registry.yarnpkg.com/dom-accessibility-api/-/dom-accessibility-api-0.5.7.tgz#8c2aa6325968f2933160a0b7dbb380893ddf3e7d"
integrity sha512-ml3lJIq9YjUfM9TUnEPvEYWFSwivwIGBPKpewX7tii7fwCazA8yCioGdqQcNsItPpfFvSJ3VIdMQPj60LJhcQA==
domexception@^2.0.1:
version "2.0.1"
resolved "https://registry.yarnpkg.com/domexception/-/domexception-2.0.1.tgz#fb44aefba793e1574b0af6aed2801d057529f304"
@ -6319,6 +6417,11 @@ lru-cache@^6.0.0:
dependencies:
yallist "^4.0.0"
lz-string@^1.4.4:
version "1.4.4"
resolved "https://registry.yarnpkg.com/lz-string/-/lz-string-1.4.4.tgz#c0d8eaf36059f705796e1e344811cf4c498d3a26"
integrity sha1-wNjq82BZ9wV5bh40SBHPTEmNOiY=
make-dir@^2.1.0:
version "2.1.0"
resolved "https://registry.yarnpkg.com/make-dir/-/make-dir-2.1.0.tgz#5f0310e18b8be898cc07009295a30ae41e91e6f5"
@ -7328,7 +7431,7 @@ pretty-format@^26.0.0, pretty-format@^26.6.2:
ansi-styles "^4.0.0"
react-is "^17.0.1"
pretty-format@^27.2.0:
pretty-format@^27.0.2, pretty-format@^27.2.0:
version "27.2.0"
resolved "https://registry.yarnpkg.com/pretty-format/-/pretty-format-27.2.0.tgz#ee37a94ce2a79765791a8649ae374d468c18ef19"
integrity sha512-KyJdmgBkMscLqo8A7K77omgLx5PWPiXJswtTtFV7XgVZv2+qPk6UivpXXO+5k6ZEbWIbLoKdx1pZ6ldINzbwTA==