When I run code coverage, code inside the root directory containing jest config works perfectly but for the code outside the root directory test cases passes but in the coverage report it shows zero percentage for all the test files outside the root directory.
jest.config.js file is inside explorebook folder.
directory structure:
|---core
| |--components
| |--test
| |--jest.setup.suites.js
|---explorebook
| |--components
| | |--test
| |--package.json
| |--jest.config.js
| |--jest.setup.suites.js
|---framework
| |--commons
| |--test
| |--jest.setup.suites.js
|
jest.config.js
const TEST_FILES_REGEX = '(/test/.*|(\\.|/)(test|spec))\\.js$';
module.exports = {
verbose: false,
roots: [
'<rootDir>/',
'<rootDir>/../core/',
'<rootDir>/../framework/commons/'
],
collectCoverage: true,
collectCoverageFrom: [
'components/**/*.js',
'<rootDir>/../core/components/**/*.js'
'<rootDir>/../framework/commons/*.js'
],
coverageDirectory: 'reports/coverage',
coverageReporters: [
'lcov',
'text'
],
setupFiles: [ '<rootDir>/jest.setup.suites.js',
'<rootDir>/../core/jest.setup.suites.js',
'<rootDir>/../framework/jest.setup.suites.js' ],
setupTestFrameworkScriptFile: path.join(__dirname, 'jest.setup.tests.js'),
testEnvironment: 'jsdom',
testRegex: TEST_FILES_REGEX
};
Even if all the outside the rootDir passes, report does not show that.
I would expect the coverage values for files outside also to be correct in the report.