Jest: --collectCoverageFrom does not appear to work on the command line

Created on 14 Oct 2016  路  6Comments  路  Source: facebook/jest

This appears to be a bug

Command line option --collectCoverageFrom has no effect on the options jest is run with

Tried several things:

$ npm test -- '--collectCoverageFrom=["**/*.js"]' --debug
$ npm test -- '--collectCoverageFrom=**/*.js' --debug

None of these show the collectCoverageFrom key in the config debug output. It's like this command line option is just ignored and I don't see how that happens with yargs.

If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal repository on GitHub that we can npm install and npm test.

Most helpful comment

hey @mark0978!

the correct usage would be like this:

jest --collectCoverageFrom='["packages/**/index.js"]' --coverage

single quotes around json and double quotes inside json.

it's complicated because there's no easy way to pass an array through yargs and we have to pass a serialized json instead :(

All 6 comments

hey @mark0978!

the correct usage would be like this:

jest --collectCoverageFrom='["packages/**/index.js"]' --coverage

single quotes around json and double quotes inside json.

it's complicated because there's no easy way to pass an array through yargs and we have to pass a serialized json instead :(

@dmitriiabramov can we add this here: http://facebook.github.io/jest/docs/api.html#jest-cli-options ?

Having a heckuva time getting this to work in VSCode launch.json args. Trying to escape all the quotes leads to madness. Does this also only work with forward slashes on the paths?

It's a glob, so you should use forward slashes in it. https://github.com/micromatch/micromatch#backslashes

@SimenB, the problem was that VSCode variables don't allow you to either selectively use a POSIX path, or do a regex replace on the value. I ultimately had to use a VSCode extension to get the POSIX path for Jest.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

StephanBijzitter picture StephanBijzitter  路  3Comments

Antho2407 picture Antho2407  路  3Comments

kgowru picture kgowru  路  3Comments

Secretmapper picture Secretmapper  路  3Comments

samzhang111 picture samzhang111  路  3Comments