Jest: collectCoverageFrom ignored in monorepo

Created on 25 Mar 2019  路  6Comments  路  Source: facebook/jest

馃悰 Bug Report

Migrating from v23 to v24 of jest i have noticed that collectCoverageFrom stopped working for my mono repo.

To Reproduce

Please follow steps in example: https://github.com/RuneKR/bad-performance/tree/fix/jest

Expected behavior

Cover coverage would be collected

Run npx envinfo --preset jest

Paste the results here:

  System:
    OS: macOS High Sierra 10.13.6
    CPU: (4) x64 Intel(R) Core(TM) i5-2500S CPU @ 2.70GHz
  Binaries:
    Node: 8.11.1 - /usr/local/bin/node
    npm: 6.6.0 - /usr/local/bin/npm
  npmPackages:
    jest: ^24.5.0 => 24.5.0 

Bug Report Needs Repro Needs Triage

Most helpful comment

Any update on this? Monorepo support from Jest has been _terrible_ for us, this is one more issue to get around.

All 6 comments

I can reproduce this. Discovered after adding a new file to a monorepo that I expected to break coverage, but it didn't.

I created a test case repo to reproduce: https://github.com/iturgeon/jest-collect-coverage-monorepo

npx: installed 1 in 2.578s

  System:
    OS: macOS 10.14.3
    CPU: (8) x64 Intel(R) Core(TM) i7-3720QM CPU @ 2.60GHz
  Binaries:
    Node: 10.4.1 - ~/.nvm/versions/node/v10.4.1/bin/node
    Yarn: 1.13.0 - ~/.nvm/versions/node/v10.4.1/bin/yarn
    npm: 6.1.0 - ~/.nvm/versions/node/v10.4.1/bin/npm

Any update on this? Monorepo support from Jest has been _terrible_ for us, this is one more issue to get around.

I did seem to find an alternative way of setting up the project that allowed us to collect the coverage. Only thing is that jest has quite a slow performance in a monorepo setup.

Give this thread a comment and i will upload the example

@RuneKR could you please share your solution? We also struggle with jest in a monorepo project 馃槥

Hi,

This is the workaround: https://github.com/RuneKR/bad-performance/tree/fix/test-coverage

It only works if you tests from at least one package for some reason. I really need to deep dive for a proper fix.

Needs Repro (label)

I can give another example of repo to reproduce:
https://github.com/MichalLytek/type-graphql/tree/6afc3d7a3e6df8abb0b881c7961ae862601fa00e

git clone
npm i
npm bootstrap
npx jest --coverage
cd packages/core
npx jest --coverage (it will fail to compile on coverage, check only the coverage table entries)

The workaround of using coverage on seperate folders currently doesn't work with ts-jest 馃槥

I am willing to help if one of the maintainer will point the places to dig 馃槈

Was this page helpful?
0 / 5 - 0 ratings