Skip to content

Commit dca3448

Browse files
liujupingJackLian
authored andcommitted
chore(editor-core): init test
1 parent 0e65f02 commit dca3448

File tree

4 files changed

+55
-2
lines changed

4 files changed

+55
-2
lines changed

.github/workflows/test packages.yml

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,4 +105,20 @@ jobs:
105105
run: npm i && npm run setup:skip-build
106106

107107
- name: test
108-
run: cd packages/utils && npm test
108+
run: cd packages/utils && npm test
109+
110+
test-editor-core:
111+
runs-on: ubuntu-latest
112+
steps:
113+
- name: checkout
114+
uses: actions/checkout@v2
115+
116+
- uses: actions/setup-node@v2
117+
with:
118+
node-version: '14'
119+
120+
- name: install
121+
run: npm i && npm run setup:skip-build
122+
123+
- name: test
124+
run: cd packages/editor-core && npm test
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"plugins": [
3+
"@alilc/build-plugin-lce",
4+
"@alilc/lowcode-test-mate/plugin/index.ts"
5+
],
6+
"babelPlugins": [
7+
["@babel/plugin-proposal-private-property-in-object", { "loose": true }]
8+
]
9+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
const fs = require('fs');
2+
const { join } = require('path');
3+
const esModules = [].join('|');
4+
const pkgNames = fs.readdirSync(join('..')).filter(pkgName => !pkgName.startsWith('.'));
5+
6+
const jestConfig = {
7+
transformIgnorePatterns: [
8+
`/node_modules/(?!${esModules})/`,
9+
],
10+
moduleFileExtensions: ['ts', 'tsx', 'js', 'json'],
11+
collectCoverage: false,
12+
collectCoverageFrom: [
13+
'src/**/*.ts',
14+
'!src/**/*.d.ts',
15+
'!src/icons/**',
16+
'!src/locale/**',
17+
'!**/node_modules/**',
18+
'!**/vendor/**',
19+
],
20+
};
21+
22+
// 只对本仓库内的 pkg 做 mapping
23+
jestConfig.moduleNameMapper = {};
24+
jestConfig.moduleNameMapper[`^@alilc/lowcode\\-(${pkgNames.join('|')})$`] = '<rootDir>/../$1/src';
25+
26+
module.exports = jestConfig;

packages/editor-core/package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@
1010
"es"
1111
],
1212
"scripts": {
13-
"build": "build-scripts build"
13+
"build": "build-scripts build",
14+
"test": "build-scripts test --config build.test.json",
15+
"test:cov": "build-scripts test --config build.test.json --jest-coverage"
1416
},
1517
"dependencies": {
1618
"@alifd/next": "^1.19.16",

0 commit comments

Comments
 (0)