@angular-ru/jest
v14.1.0
Published
Angular-RU package
Downloads
264
Readme
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: '<rootDir>/tsconfig.spec.json',
jestConfig: {
rootDir: __dirname, // or another path
testMatch: ['<rootDir>/tests/**/*.spec.ts'],
coverageDirectory: '<rootDir>/coverage/my-app',
setupFilesAfterEnv: ['<rootDir>/tests/setup-jest.ts'],
modulePathIgnorePatterns: ['<rootDir>/dist/@my-scope'],
cacheDirectory: '<rootDir>/node_modules/.cache/jest',
collectCoverageFrom: ['<rootDir>/**/*.ts', '!<rootDir>/**/*.spec.ts']
}
});
$ jest --config jest.config.js
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']
}
});