Jest: TypeError: mappedCoverage.addStatement is not a function

Created on 17 Feb 2019  路  2Comments  路  Source: facebook/jest

馃悰 Bug Report

I have one repo after the upgrade to v24.1 im getting this error

TypeError: mappedCoverage.addStatement is not a function as a error if i run jest --coverage

To Reproduce

run npm run test:coverage or jest --coverage at https://github.com/growcss/growcss/tree/alpha

Expected behavior

Getting a test coverage without an error

Link to repl or repo (highly encouraged)

https://travis-ci.org/growcss/growcss/jobs/494372887
https://github.com/growcss/growcss/tree/alpha

Run npx envinfo --preset jest

Paste the results here:

  System:
    OS: Linux 4.20 Manjaro Linux undefined
    CPU: (8) x64 Intel(R) Core(TM) i7-4810MQ CPU @ 2.80GHz
  Binaries:
    Node: 10.14.2 - ~/.nvm/versions/node/v10.14.2/bin/node
    Yarn: 1.12.3 - ~/.yarn/bin/yarn
    npm: 6.5.0 - /GitHub/growcss/growcss/node_modules/.bin/npm
  npmPackages:
    jest: ^24.1.0 => 24.1.0
Bug

Most helpful comment

I also came upon this when upgrading a mono repo codebase. I had to make sure collectCoverageFrom only included my actual source code. It was trying to include files in the node_modules of my individual packages within the mono repo and then hitting this cryptic error it seems. Specifically, this seemed only to occur in packages that had a dependency on another package within the mono repo.

collectCoverageFrom: [ "packages/**/src/*.js"]

did the trick for me but you'll need to tweak that based on your needs.

All 2 comments

I also came upon this when upgrading a mono repo codebase. I had to make sure collectCoverageFrom only included my actual source code. It was trying to include files in the node_modules of my individual packages within the mono repo and then hitting this cryptic error it seems. Specifically, this seemed only to occur in packages that had a dependency on another package within the mono repo.

collectCoverageFrom: [ "packages/**/src/*.js"]

did the trick for me but you'll need to tweak that based on your needs.

@dan-weaver thank you for the help/hint.

Im switching right now to rush so i dont have this problem any more :)

Was this page helpful?
0 / 5 - 0 ratings