chore: renderer jest config add collectCoverage

This commit is contained in:
liujuping 2022-04-28 14:06:38 +08:00
parent 2dfdba3399
commit 38be3dec83
3 changed files with 22 additions and 5 deletions

View File

@ -1,15 +1,32 @@
module.exports = { const fs = require('fs');
const { join } = require('path');
const esModules = ['zen-logger'].join('|');
const pkgNames = fs.readdirSync(join('..')).filter(pkgName => !pkgName.startsWith('.'));
const jestConfig = {
// transform: { // transform: {
// '^.+\\.[jt]sx?$': 'babel-jest', // '^.+\\.[jt]sx?$': 'babel-jest',
// // '^.+\\.(ts|tsx)$': 'ts-jest', // // '^.+\\.(ts|tsx)$': 'ts-jest',
// // '^.+\\.(js|jsx)$': 'babel-jest', // // '^.+\\.(js|jsx)$': 'babel-jest',
// }, // },
// testMatch: ['**/document/node/node.test.ts'],
// testMatch: ['**/designer/builtin-hotkey.test.ts'],
// testMatch: ['**/plugin/plugin-manager.test.ts'],
// testMatch: ['(/tests?/.*(test))\\.[jt]s$'], // testMatch: ['(/tests?/.*(test))\\.[jt]s$'],
transformIgnorePatterns: [
`/node_modules/(?!${esModules})/`,
],
moduleFileExtensions: ['ts', 'tsx', 'js', 'json'], moduleFileExtensions: ['ts', 'tsx', 'js', 'json'],
collectCoverage: true, collectCoverage: true,
collectCoverageFrom: [ collectCoverageFrom: [
'src/**/*.{ts,tsx}', 'src/**/*.ts',
'!src/**/*.d.ts',
'!**/node_modules/**', '!**/node_modules/**',
'!**/vendor/**',
], ],
}; };
// 只对本仓库内的 pkg 做 mapping
jestConfig.moduleNameMapper = {};
jestConfig.moduleNameMapper[`^@alilc/lowcode\\-(${pkgNames.join('|')})$`] = '<rootDir>/../$1/src';
module.exports = jestConfig;

View File

@ -18,7 +18,7 @@ const jestConfig = {
], ],
setupFiles: ['./test/utils/host.ts'], setupFiles: ['./test/utils/host.ts'],
moduleFileExtensions: ['ts', 'tsx', 'js', 'json'], moduleFileExtensions: ['ts', 'tsx', 'js', 'json'],
collectCoverage: false, collectCoverage: true,
collectCoverageFrom: [ collectCoverageFrom: [
'src/**/*.ts', 'src/**/*.ts',
'!src/**/*.d.ts', '!src/**/*.d.ts',

View File

@ -16,7 +16,7 @@ const jestConfig = {
], ],
setupFiles: ['./tests/fixtures/unhandled-rejection.ts'], setupFiles: ['./tests/fixtures/unhandled-rejection.ts'],
moduleFileExtensions: ['ts', 'tsx', 'js', 'json'], moduleFileExtensions: ['ts', 'tsx', 'js', 'json'],
collectCoverage: false, collectCoverage: true,
collectCoverageFrom: [ collectCoverageFrom: [
'src/**/*.ts', 'src/**/*.ts',
'!src/**/*.d.ts', '!src/**/*.d.ts',