Run Jest test and collect coverage from all files in a specific directory
Asked Answered
T

1

7

I am using the following code to run Jest test on specific file.

   jest utils.spec.js --collectCoverageFrom=**/utils.js

If i want to test whole directory i use

jest someDirectory --collectCoverageFrom=**/someDirectory

But the code coverage does not work here why is so?

Thanks.

Totten answered 18/6, 2017 at 11:9 Comment(0)
S
10

You need to add this pattern /**/*.js, that match all the files in all sub directories:

jest someDirectory --collectCoverageFrom=**/someDirectory/**/*.js
Spendable answered 19/6, 2017 at 6:43 Comment(1)
Although tests executed for specified directory the coverage is performed on all the available tests.Totten

© 2022 - 2024 — McMap. All rights reserved.