Automatic create Jest config for Angular projects
It's very convenient to testing our applications with Angular and Jest now.
Quick start
$ npm install @angular-ru/jest -D
Create jest.config.js
const { createTsJestConfig } = require('@angular-ru/jest');
module.exports = createTsJestConfig({
tsConfig: './tsconfig.json',
jestConfig: {
rootDir: '.',
displayName: 'My Angular App',
testMatch: ['<rootDir>/tests/**/*.spec.ts'],
collectCoverageFrom: ['<rootDir>/src/app/**/*.ts']
}
});
$ jest --config jest.config.js --coverage
FAQ
- I have
jest-haste-map: Haste module naming collision
module.exports = createTsJestConfig({
jestConfig: {
modulePathIgnorePatterns: ['<rootDir>/dist/']
}
});
- How can I add setupFilesAfterEnv files?
module.exports = createTsJestConfig({
jestConfig: {
setupFilesAfterEnv: ['<rootDir>/setup-jest.ts']
}
});