1- module . exports = {
2- transform : {
3- '^.+\\.(ts|tsx)$' : 'ts-jest' ,
4- '^.+\\.(js|ts|tsx|jsx)$' : 'babel-jest' ,
5- '^.+\\.(css|less|scss)$' : './test/mock/styleMock.js' ,
6- } ,
7- // testMatch: ['**/bugs/*.test.ts'],
1+ const fs = require ( 'fs' ) ;
2+ const { join } = require ( 'path' ) ;
3+ const esModules = [ 'zen-logger' ] . join ( '|' ) ;
4+ const pkgNames = fs . readdirSync ( join ( '..' ) ) . filter ( pkgName => ! pkgName . startsWith ( '.' ) ) ;
5+
6+ const jestConfig = {
7+ // transform: {
8+ // // '^.+\\.[jt]sx?$': 'babel-jest',
9+ // '^.+\\.(ts|tsx)$': 'ts-jest',
10+ // // '^.+\\.(js|jsx)$': 'babel-jest',
11+ // },
812 // testMatch: ['(/tests?/.*(test))\\.[jt]s$'],
9- // transformIgnorePatterns: [
10- // `/node_modules/(?!${esModules})/`,
11- // ],
12- testEnvironment : 'jsdom' ,
13+ // testMatch: ['**/*/common.test.ts'],
14+ transformIgnorePatterns : [
15+ `/node_modules/(?!${ esModules } )/` ,
16+ ] ,
17+ setupFiles : [ './tests/fixtures/unhandled-rejection.ts' ] ,
1318 moduleFileExtensions : [ 'ts' , 'tsx' , 'js' , 'json' ] ,
1419 collectCoverage : false ,
1520 collectCoverageFrom : [
16- 'src/**/*.{ts,tsx}' ,
17- ] ,
18- moduleNameMapper : {
19- '^.+.(css|styl|less|sass|scss|png|jpg|ttf|woff|woff2)$' : 'jest-transform-stub' ,
20- } ,
21- setupFilesAfterEnv : [
22- './test/setup.ts' ,
21+ 'src/**/*.ts' ,
22+ '!src/**/*.d.ts' ,
23+ '!src/icons/**' ,
24+ '!src/locale/**' ,
25+ '!src/builtin-simulator/utils/**' ,
26+ '!src/plugin/sequencify.ts' ,
27+ '!src/document/node/exclusive-group.ts' ,
28+ '!src/document/node/props/value-to-source.ts' ,
29+ '!src/builtin-simulator/live-editing/live-editing.ts' ,
30+ '!src/designer/offset-observer.ts' ,
31+ '!src/designer/clipboard.ts' ,
32+ '!**/node_modules/**' ,
33+ '!**/vendor/**' ,
2334 ] ,
2435} ;
36+
37+ // 只对本仓库内的 pkg 做 mapping
38+ jestConfig . moduleNameMapper = { } ;
39+ jestConfig . moduleNameMapper [ `^@alilc/lowcode\\-(${ pkgNames . join ( '|' ) } )$` ] = '<rootDir>/../$1/src' ;
40+
41+ module . exports = jestConfig ;
0 commit comments