Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

collectCoverage do nothing when using projects configs #8722

Closed
sanex3339 opened this issue Jul 19, 2019 · 2 comments
Closed

collectCoverage do nothing when using projects configs #8722

sanex3339 opened this issue Jul 19, 2019 · 2 comments

Comments

@sanex3339
Copy link

🐛 Bug Report

collectCoverage do nothing when using projects configs.

global jest.config.js

module.exports = {
	"projects": [
		"<rootDir>/src/client/test/jest.config.js",
		"<rootDir>/src/server/test/jest.config.js"
	]
};

client jest.config.js

module.exports = {
	"displayName": "client",
	"rootDir": "../../../",
	"globals": {
		"__MODE__": "test",
		"ts-jest": {
			"tsConfigFile": "src/client/test/tsconfig.json"
		}
	},
	"transform": {
		".(js|jsx|ts|tsx)": "<rootDir>/node_modules/ts-jest/preprocessor.js"
	},
	"moduleNameMapper": {
		"^.+\\.(css|less|png|svg|jpg)$": "<rootDir>/src/client/test/css-modules-stub.ts"
	},
	"testMatch": [
		"**/src/client/**/?(*.)+(spec|test).[jt]s?(x)",
	],
	"transformIgnorePatterns": [
		"/node_modules/(?!lego-on-react).+\\.js$"
	],
	"moduleFileExtensions": [
		"ts",
		"tsx",
		"js",
		"jsx",
		"json"
	],
	"modulePaths": [
		"<rootDir>/src",
		"<rootDir>/node_modules"
	],
	"setupFiles": [
		"<rootDir>/src/client/test/tests-setup.tsx",
		"jest-localstorage-mock"
	],
	"setupFilesAfterEnv": [
		"jest-extended",
		"<rootDir>/src/client/test/test-framework-setup.ts"
	],
	"collectCoverage": true,
	"collectCoverageFrom": [
		"<rootDir>/src/client/**/*.{ts,tsx}"
	],
	"coveragePathIgnorePatterns": [
		".*\\.d\\.ts",
		"<rootDir>/src/client/**/enums/**/*.ts"
	],
	"coverageDirectory": "<rootDir>/.jest-coverage",
	"coverageReporters": ["jest-html-reporter"]
};

To Reproduce

Code above. Jest run through CLI with command like npm test -- someTests
I was trying to debug the jest and in places where jest uses collectCoverage option it trying to access it from globalConfig that pointed to root jest.config.js

When i moved all coverage options from project config to root config - coverage working.

Expected behavior

collectCoverage option should work.

Link to repl or repo (highly encouraged)

No link, sorry.

Run npx envinfo --preset jest

Paste the results here:

 System:
    OS: macOS Sierra 10.12.6
    CPU: (4) x64 Intel(R) Core(TM) i5-5250U CPU @ 1.60GHz
  Binaries:
    Node: 10.11.0 - ~/.nvm/versions/node/v10.11.0/bin/node
    npm: 6.9.0 - ~/.nvm/versions/node/v10.11.0/bin/npm
  npmPackages:
    jest: ^24.8.0 => 24.8.0 
@SimenB
Copy link
Member

SimenB commented Jul 19, 2019

Yeah, collectCoverage is a global config option, so setting it in a project does nothing... https://github.com/facebook/jest/blob/33e2d5ce454554363198c8d8a673793222955dbc/packages/jest-types/src/Config.ts#L294

That probably should be a project one (and setting the flag from the CLI would just set it to true for every project).

We'll be revisiting config and its validation as part of Jest 25 where we'll either fix this somehow or at the very least provide good error messages if fields are added where they don't belong (#7185 is a tracking issue for this work)

@github-actions
Copy link

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Please note this issue tracker is not a help forum. We recommend using StackOverflow or our discord channel for questions.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 11, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants