jestjs / jest

Delightful JavaScript Testing.
https://jestjs.io
MIT License
44.03k stars 6.43k forks source link

Ability to add coverageReporter by tools #10960

Open segrey opened 3 years ago

segrey commented 3 years ago

🚀 Feature Proposal

It'd be great to have possibility to add a coverage reporter to coverage reporters configured in Jest configs without changing the configs.

Motivation

IntelliJ Jest integration can visualize coverage collected by Jest. It needs lcov.info generated for that. The problem is that lcov.info might be not configured in user's jest config. Passing --coverageReporters=lcov solves this issue partially, because it overwrites all user's configured reporters, unfortunately. IntelliJ needs to preserve coverage reporters configured by user. So, it'd be great to have a way to add lcov coverage reporter somehow without modifying Jest config files.

IntelliJ runs Jest tests with its own reporter. Is it OK to add a custom coverage reporter via Jest API? If yes, it will work too.

BTW, seems --coverageReporters is an unofficial CLI option, but it works. Could you please clarify that?

I'm a maintainer of IntellJ Jest integration, feel free to ask me any questions regarding it.

Example

A hypothetical CLI-based solution could be like this: --coverageReporters=+lcov

Pitch

Why does this feature belong in the Jest core platform?

This issue relates to coverage and/or to processing of CLI option. Probably it belongs to Jest code platform, but I'm not fully sure.

github-actions[bot] commented 2 years ago

This issue is stale because it has been open for 1 year with no activity. Remove stale label or comment or this will be closed in 14 days.

segrey commented 2 years ago

Not stale!

github-actions[bot] commented 1 year ago

This issue is stale because it has been open for 1 year with no activity. Remove stale label or comment or this will be closed in 30 days.

SimenB commented 1 year ago

We should do this - enabling better IDE integration is important to me (especially as an IntelliJ user myself 😀).

Passing --coverageReporters=lcov solves this issue partially, because it overwrites all user's configured reporters, unfortunately

Is that an issue? Running tests from within your IDE I'd assume you'd not be interested in other reporters?

BTW, seems --coverageReporters is an unofficial CLI option, but it works. Could you please clarify that?

We've just forgotten to document it probably