Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

testing

jestjs

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.

like image 462
Alexander Gorelik Avatar asked Jun 18 '17 11:06

Alexander Gorelik


1 Answers

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

jest someDirectory --collectCoverageFrom=**/someDirectory/**/*.js
like image 163
Andreas Köberle Avatar answered Oct 18 '22 11:10

Andreas Köberle