It's very convenient to testing our applications with Angular and Jest now.
$ npm install @angular-ru/jest-utils -D
Create jest.config.js
const { createTsJestConfig } = require('@angular-ru/jest-utils');
const path = require('path');
module.exports = createTsJestConfig({
rootDir: path.resolve('.'),
displayName: 'My Angular App',
testMatch: ['<rootDir>/tests/**/*.spec.ts'],
collectCoverageFrom: ['<rootDir>/src/app/**/*.ts'],
tsConfigRootPath: path.resolve('./tsconfig.json')
});
$ jest --config jest.config.js --coverage
- I have
jest-haste-map: Haste module naming collision
module.exports = createTsJestConfig({
// ...
modulePathIgnorePatterns: ['<rootDir>/dist/']
});
- How can I define other properties that do not exist in
createTsJestConfig
?
// jest.config.js
module.exports = {
...createTsJestConfig({
// ...
}),
watch: true
};
- How can I add setupFilesAfterEnv files?
module.exports = createTsJestConfig({
// ...
setupFilesAfterEnv: ['<rootDir>/setupJest.ts']
});