jest
# typescript
npm i -D jest ts-node ts-jest @types/jest
npx ts-jest config:init
# js
npx jest --init
配置
jest.config.js
const { pathsToModuleNameMapper } = require('ts-jest/utils');
const { compilerOptions } = require('./tsconfig');
module.exports = {
setupFiles: ['<rootDir>/jest.setup.js'],
transform: {
'^.+\\.(ts|tsx)$': 'ts-jest',
},
globals: {
'ts-jest': {
// tsConfig: 'tsconfig.jest.json',
tsConfig: 'tsconfig.json',
},
},
moduleNameMapper: pathsToModuleNameMapper(compilerOptions.paths, { prefix: '<rootDir>/' }),
};
jest.setup.js
require('dotenv').config();
jest.config.ts
import { InitialOptionsTsJest } from 'ts-jest/dist/types';
export default {
preset: 'ts-jest',
testEnvironment: 'node',
} as InitialOptionsTsJest;
majestic
- Raathigesh/majestic
- Zero config GUI for Jest
npx majestic