Skip to content

Commit

Permalink
chore(editor-core): init test
Browse files Browse the repository at this point in the history
  • Loading branch information
liujuping committed Jan 25, 2024
1 parent 0e65f02 commit 0c7b6c5
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 2 deletions.
18 changes: 17 additions & 1 deletion .github/workflows/test packages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -105,4 +105,20 @@ jobs:
run: npm i && npm run setup:skip-build

- name: test
run: cd packages/utils && npm test
run: cd packages/utils && npm test

test-editor-core:
runs-on: ubuntu-latest
steps:
- name: checkout
uses: actions/checkout@v2

- uses: actions/setup-node@v2
with:
node-version: '14'

- name: install
run: npm i && npm run setup:skip-build

- name: test
run: cd packages/editor-core && npm test
9 changes: 9 additions & 0 deletions packages/editor-core/build.test.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"plugins": [
"@alilc/build-plugin-lce",
"@alilc/lowcode-test-mate/plugin/index.ts"
],
"babelPlugins": [
["@babel/plugin-proposal-private-property-in-object", { "loose": true }]
]
}
26 changes: 26 additions & 0 deletions packages/editor-core/jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
const fs = require('fs');
const { join } = require('path');
const esModules = [].join('|');
const pkgNames = fs.readdirSync(join('..')).filter(pkgName => !pkgName.startsWith('.'));

const jestConfig = {
transformIgnorePatterns: [
`/node_modules/(?!${esModules})/`,
],
moduleFileExtensions: ['ts', 'tsx', 'js', 'json'],
collectCoverage: false,
collectCoverageFrom: [
'src/**/*.ts',
'!src/**/*.d.ts',
'!src/icons/**',
'!src/locale/**',
'!**/node_modules/**',
'!**/vendor/**',
],
};

// 只对本仓库内的 pkg 做 mapping
jestConfig.moduleNameMapper = {};
jestConfig.moduleNameMapper[`^@alilc/lowcode\\-(${pkgNames.join('|')})$`] = '<rootDir>/../$1/src';

module.exports = jestConfig;
4 changes: 3 additions & 1 deletion packages/editor-core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@
"es"
],
"scripts": {
"build": "build-scripts build"
"build": "build-scripts build",
"test": "build-scripts test --config build.test.json",
"test:cov": "build-scripts test --config build.test.json --jest-coverage"
},
"dependencies": {
"@alifd/next": "^1.19.16",
Expand Down

0 comments on commit 0c7b6c5

Please sign in to comment.