| module.exports = { |
| testEnvironment: 'jsdom', |
| moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json'], |
| setupFilesAfterEnv: ['<rootDir>/jest.setup.ts'], |
| transform: { |
| '^.+\\.(js|jsx|ts|tsx)$': 'babel-jest', // 使用 babel 处理所有文件 |
| }, |
| moduleNameMapper: { |
| '\\.(css|less|scss|sass)$': 'identity-obj-proxy', |
| '\\.(jpg|jpeg|png|gif|svg)$': '<rootDir>/__mocks__/fileMock.js', |
| '^@/(.*)$': '<rootDir>/src/$1', // 如果你用了 path alias |
| '&/(.*)$': '<rootDir>/$1', // 如果你用了 path alias |
| }, |
| testPathIgnorePatterns: ['/node_modules/', '/dist/', '/scripts/'], |
| roots: ['<rootDir>/test'], |
| collectCoverageFrom: [ |
| 'src/**/*.{ts,tsx,js,jsx}', |
| '!src/**/*.d.ts', |
| '!src/**/index.ts', |
| '!src/**/index.tsx', |
| '!src/**/index.js', |
| '!src/**/index.jsx', |
| ], |
| }; |