I have a Angular project that is divided in sub-projects, and I'm testing it with jest. The configuration is done in a jest.config.js file and this configuration is exported as module.exports, so when I call test for this project all the tests in the sub-projects are ran.
The problem is that I want some configuration to be of only a sub-project, there is a way to have a jest.config.js in these sub-projects?
For example:
./jest.config.js:
const { compilerOptions } = require('./tsconfig');
module.exports = {
preset: 'jest-preset-angular',
roots: [
'<rootDir>/project1/src/',
'<rootDir>/project2/src/',
],
testMatch: ['**/+(*.)+(spec).+(ts)'],
collectCoverage: true,
coverageReporters: ['text-summary'],
};
./project1/jest.config.js:
const { compilerOptions } = require('./tsconfig');
module.exports = {
coveragePathIgnorePatterns: ['./project1/src/models'],
};
In this case the configuration for ignoring sem path in coverage would take value only in the project1 directory.