|
11 | 11 | // See the License for the specific language governing permissions and |
12 | 12 | // limitations under the License. |
13 | 13 |
|
14 | | -import { readFileSync } from 'fs'; |
15 | | -import { resolve, dirname } from 'path'; |
16 | | -import { fileURLToPath } from 'url'; |
17 | 14 | import type { Config } from '@jest/types'; |
18 | | - |
19 | | -const here = dirname(fileURLToPath(import.meta.url)); |
20 | | -const swcrc = JSON.parse(readFileSync(resolve(here, '../.cjs.swcrc'), 'utf-8')); |
| 15 | +import shared from '../jest.shared'; |
21 | 16 |
|
22 | 17 | const jestConfig: Config.InitialOptions = { |
23 | | - testEnvironment: 'jsdom', |
24 | | - roots: ['<rootDir>/src'], |
| 18 | + ...shared, |
| 19 | + |
25 | 20 | moduleNameMapper: { |
26 | | - '^echarts/(.*)$': 'echarts', |
27 | | - '^use-resize-observer$': 'use-resize-observer/polyfilled', |
28 | | - '\\.(css|less)$': '<rootDir>/../stylesMock.js', |
| 21 | + ...(shared.moduleNameMapper ?? {}), |
29 | 22 | '^react$': '<rootDir>/../node_modules/react', |
30 | 23 | '^react-dom$': '<rootDir>/../node_modules/react-dom', |
31 | 24 | '^react/jsx-runtime$': '<rootDir>/../node_modules/react/jsx-runtime', |
32 | 25 | '^react-dom/(.*)$': '<rootDir>/../node_modules/react-dom/$1', |
33 | 26 | }, |
34 | | - transformIgnorePatterns: ['node_modules/(?!(lodash-es|yaml))'], |
35 | | - transform: { |
36 | | - '^.+\\.(ts|tsx|js|jsx)$': ['@swc/jest', { ...swcrc, exclude: [], swcrc: false }], |
37 | | - }, |
38 | | - setupFilesAfterEnv: ['<rootDir>/src/setup-tests.ts'], |
| 27 | + |
| 28 | + setupFilesAfterEnv: [...(shared.setupFilesAfterEnv ?? []), '<rootDir>/src/setup-tests.ts'], |
39 | 29 | }; |
40 | 30 |
|
41 | 31 | export default jestConfig; |
0 commit comments