Skip to content
This repository has been archived by the owner on Jan 26, 2019. It is now read-only.

Failed to write coverage reports: metrics.isEmpty is not a function. #291

Closed
panmona opened this issue Mar 28, 2018 · 2 comments
Closed

Comments

@panmona
Copy link

panmona commented Mar 28, 2018

Is this a bug report?

Yes.

Can you also reproduce the problem with npm 4.x?

No.

Which terms did you search for in User Guide?

  • istanbul
  • metrics.isEmpty
  • coverage

Environment

  1. npm ls react-scripts-ts (if you haven’t ejected): [email protected]
  2. node -v: v9.10.0
  3. npm -v: 5.8.0
  4. yarn --version (if you use Yarn): 1.3.2
  5. npm ls react-scripts-ts (if you haven’t ejected): [email protected]

Then, specify:

  1. Operating system: macOS Version 10.12 / Windows 10

Steps to Reproduce

  1. Install react-scripts-ts in version 2.14 (no issues in version 2.13)
  2. Run npm run test or yarn test (runs jest with --coverage)

Expected Behavior

The tool writes the coverage report.

Actual Behavior

The tool doesn't write the coverage report.
Stacktrace below:

        Failed to write coverage reports:
        ERROR: TypeError: metrics.isEmpty is not a function
        STACK: TypeError: metrics.isEmpty is not a function
    at tableRow (/UserPath/ts-coverage-error/node_modules/istanbul-reports/lib/text/index.js:133:27)
    at TextReport.onSummary (/UserPath/ts-coverage-error/node_modules/istanbul-reports/lib/text/index.js:188:15)
    at TextReport.onDetail (/UserPath/ts-coverage-error/node_modules/istanbul-reports/lib/text/index.js:193:17)
    at Visitor.(anonymous function) [as onDetail] (/UserPath/ts-coverage-error/node_modules/istanbul-lib-report/lib/tree.js:34:30)
    at ReportNode.Node.visit (/UserPath/ts-coverage-error/node_modules/istanbul-lib-report/lib/tree.js:123:17)
    at /UserPath/ts-coverage-error/node_modules/istanbul-lib-report/lib/tree.js:116:23
    at Array.forEach (<anonymous>)
    at visitChildren (/UserPath/ts-coverage-error/node_modules/istanbul-lib-report/lib/tree.js:115:32)
    at ReportNode.Node.visit (/UserPath/ts-coverage-error/node_modules/istanbul-lib-report/lib/tree.js:126:5)
    at /UserPath/ts-coverage-error/node_modules/istanbul-lib-report/lib/tree.js:116:23

Reproducible Demo

Demo Project

  1. clone the project
  2. run yarn
  3. run yarn test / npm run test

If I delete my node_modules rm -rf node_modules then run npm install and npm test/yarn test it works. (at least on my computer, couldn't reproduce this in my CI.)
And if I downgrade to react-scripts-ts 2.13.0 and re-run yarn + yarn test there's also no metrics.isEmpty is not a function error.

Hope you can reproduce this issue and find out why it happens. I find it really weird!

@panmona panmona changed the title Failed to write coverage reports: metrics.isEmpty is not a function. React-Scripts-Ts 2.14 Failed to write coverage reports: metrics.isEmpty is not a function. Mar 28, 2018
@DorianGrey
Copy link
Collaborator

This seems to be caused by the same issue as described here: jestjs/jest#5772

For now, you might just upgrade ts-jest to a more recent version - your yarn.lock mentions 22.0.1, and the most recent is 22.4.2. I can confirm that this error no longer raises after updating.
Just note that it might be required to delete the lock file and generate it again - yarn sometimes behaves curious in terms of transitive depedencies.

@panmona
Copy link
Author

panmona commented Mar 29, 2018

Thanks @DorianGrey this works well.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants