feat: 优化源码测试

This commit is contained in:
winixt 2021-08-13 17:58:13 +08:00
parent 67b74367ed
commit 876cac7b9d
12 changed files with 25 additions and 39 deletions

View File

@ -18,9 +18,7 @@ module.exports = {
'no-undefined': 'off', 'no-undefined': 'off',
'vue/valid-template-root': 'off' 'vue/valid-template-root': 'off'
}, },
parserOptions: { env: {
babelOptions: { jest: true
presets: ['@babel/preset-env']
}
} }
}; };

View File

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

View File

@ -1,18 +1,8 @@
module.exports = { module.exports = {
moduleFileExtensions: [ testPathIgnorePatterns: [
'js', '/node_modules/',
'jsx', 'fes-template',
'json' 'fes-template-h5'
],
transform: {
'\\.[jt]sx?$': 'babel-jest'
},
moduleDirectories: [
'node_modules'
],
transformIgnorePatterns: [
'node_modules/(?!lodash-es)',
'fes-template'
] ]
}; };

View File

@ -16,7 +16,7 @@
"release": "node scripts/build.js && lerna publish from-git", "release": "node scripts/build.js && lerna publish from-git",
"docs:dev": "vuepress dev docs --clean-cache", "docs:dev": "vuepress dev docs --clean-cache",
"docs:build": "vuepress build docs --clean-cache", "docs:build": "vuepress build docs --clean-cache",
"test": "yarn jest", "test": "fes test",
"lint": "eslint -c ./.eslintrc.js --ext .js,.jsx,.vue,.ts" "lint": "eslint -c ./.eslintrc.js --ext .js,.jsx,.vue,.ts"
}, },
"license": "MIT", "license": "MIT",
@ -35,11 +35,12 @@
"@babel/preset-env": "^7.15.0", "@babel/preset-env": "^7.15.0",
"@commitlint/cli": "^11.0.0", "@commitlint/cli": "^11.0.0",
"@commitlint/config-conventional": "^11.0.0", "@commitlint/config-conventional": "^11.0.0",
"@fesjs/fes": "^2.0.0",
"@fesjs/plugin-jest": "^2.0.0",
"@vuepress/plugin-docsearch": "^2.0.0-beta.22", "@vuepress/plugin-docsearch": "^2.0.0-beta.22",
"@vuepress/plugin-pwa": "^2.0.0-beta.22", "@vuepress/plugin-pwa": "^2.0.0-beta.22",
"@vuepress/plugin-pwa-popup": "^2.0.0-beta.22", "@vuepress/plugin-pwa-popup": "^2.0.0-beta.22",
"@webank/eslint-config-webank": "0.3.0", "@webank/eslint-config-webank": "0.3.0",
"babel-jest": "^27.0.6",
"chalk": "^4.1.2", "chalk": "^4.1.2",
"chokidar": "^3.5.2", "chokidar": "^3.5.2",
"commitizen": "^4.2.1", "commitizen": "^4.2.1",
@ -47,7 +48,6 @@
"deepmerge": "^4.2.2", "deepmerge": "^4.2.2",
"fs-extra": "^10.0.0", "fs-extra": "^10.0.0",
"husky": "^4.3.0", "husky": "^4.3.0",
"jest": "^27.0.6",
"lint-staged": "^10.4.0", "lint-staged": "^10.4.0",
"postcss": "^8.0.0", "postcss": "^8.0.0",
"postcss-loader": "^5.0.0", "postcss-loader": "^5.0.0",

View File

@ -24,8 +24,8 @@
"access": "public" "access": "public"
}, },
"dependencies": { "dependencies": {
"@babel/preset-env": "^7.12.13", "@babel/preset-env": "^7.15.0",
"@babel/register": "^7.12.13", "@babel/register": "^7.15.3",
"@fesjs/utils": "^2.0.0", "@fesjs/utils": "^2.0.0",
"commander": "^7.0.0", "commander": "^7.0.0",
"dotenv": "8.2.0", "dotenv": "8.2.0",

View File

@ -12,8 +12,8 @@ import {
import { PluginType } from '../enums'; import { PluginType } from '../enums';
const RE = { const RE = {
[PluginType.plugin]: /^(@fesjs\/|@webank\/fes-|fes-)?plugin-/, [PluginType.plugin]: /^(@fesjs\/|@webank\/fes-|fes-)plugin-/,
[PluginType.preset]: /^(@fesjs\/|@webank\/fes-|fes-)?preset-/ [PluginType.preset]: /^(@fesjs\/|@webank\/fes-|fes-)preset-/
}; };
export function isPluginOrPreset(type, name) { export function isPluginOrPreset(type, name) {

View File

@ -0,0 +1,5 @@
test('button disabled', async () => {
expect(1).toBe(1);
});

View File

@ -49,7 +49,6 @@
"core-js": "^3.8.3", "core-js": "^3.8.3",
"css-loader": "^5.0.1", "css-loader": "^5.0.1",
"css-minimizer-webpack-plugin": "^3.0.0", "css-minimizer-webpack-plugin": "^3.0.0",
"deepmerge": "^4.2.2",
"envinfo": "^7.7.3", "envinfo": "^7.7.3",
"file-loader": "^6.2.0", "file-loader": "^6.2.0",
"html-webpack-plugin": "^5.0.0", "html-webpack-plugin": "^5.0.0",

View File

@ -9,7 +9,7 @@
// 根据 entry 进行代码块拆分 // 根据 entry 进行代码块拆分
// 根据 entry 将文件输出到不同的文件夹 // 根据 entry 将文件输出到不同的文件夹
import deepmerge from 'deepmerge'; import { deepmerge } from '@fesjs/utils';
function createRules({ function createRules({
isDev, isDev,

View File

@ -36,7 +36,7 @@ const DEFAULT_EXCLUDE_NODE_MODULES = [
'core-js', 'core-js',
'echarts', 'echarts',
'@babel/runtime', '@babel/runtime',
'lodash', 'lodash-es',
'webpack-dev-server', 'webpack-dev-server',
'ansi-html', 'ansi-html',
'html-entities' 'html-entities'

View File

@ -1,4 +1,4 @@
import deepmerge from 'deepmerge'; import { deepmerge } from '@fesjs/utils';
const defaultTerserOptions = { const defaultTerserOptions = {
compress: { compress: {

View File

@ -1099,10 +1099,10 @@
"@babel/types" "^7.4.4" "@babel/types" "^7.4.4"
esutils "^2.0.2" esutils "^2.0.2"
"@babel/register@^7.12.13": "@babel/register@^7.15.3":
version "7.14.5" version "7.15.3"
resolved "https://registry.npmjs.org/@babel/register/-/register-7.14.5.tgz#d0eac615065d9c2f1995842f85d6e56c345f3233" resolved "https://registry.npmjs.org/@babel/register/-/register-7.15.3.tgz#6b40a549e06ec06c885b2ec42c3dd711f55fe752"
integrity sha512-TjJpGz/aDjFGWsItRBQMOFTrmTI9tr79CHOK+KIvLeCkbxuOAk2M5QHjvruIMGoo9OuccMh5euplPzc5FjAKGg== integrity sha512-mj4IY1ZJkorClxKTImccn4T81+UKTo4Ux0+OFSV9hME1ooqS9UV+pJ6BjD0qXPK4T3XW/KNa79XByjeEMZz+fw==
dependencies: dependencies:
clone-deep "^4.0.1" clone-deep "^4.0.1"
find-cache-dir "^2.0.0" find-cache-dir "^2.0.0"