jest: Coverage Broken: metrics.isEmpty is not a function at tableRow
command run:
jest --forceExit --verbose --bail --useStderr --runInBand --expand --colors --coverage
output:
Failed to write coverage reports: ERROR: TypeError: metrics.isEmpty is not a function STACK: TypeError: metrics.isEmpty is not a function at tableRow (/Users/qtb9604/bmw/packages/http/node_modules/istanbul-reports/lib/text/index.js:133:27) at TextReport.onSummary (/Users/qtb9604/bmw/packages/http/node_modules/istanbul-reports/lib/text/index.js:188:15) at TextReport.onDetail (/Users/qtb9604/bmw/packages/http/node_modules/istanbul-reports/lib/text/index.js:193:17) at Visitor.(anonymous function) [as onDetail] (/Users/qtb9604/bmw/packages/http/node_modules/istanbul-lib-report/lib/tree.js:34:30) at ReportNode.Node.visit (/Users/qtb9604/bmw/packages/http/node_modules/istanbul-lib-report/lib/tree.js:123:17) at /Users/qtb9604/bmw/packages/http/node_modules/istanbul-lib-report/lib/tree.js:116:23 at Array.forEach (native) at visitChildren (/Users/qtb9604/bmw/packages/http/node_modules/istanbul-lib-report/lib/tree.js:115:32) at ReportNode.Node.visit (/Users/qtb9604/bmw/packages/http/node_modules/istanbul-lib-report/lib/tree.js:126:5) at /Users/qtb9604/bmw/packages/http/node_modules/istanbul-lib-report/lib/tree.js:116:23
jest --debug
yields:
{ "configs": [ { "automock": false, "browser": false, "cache": true, "cacheDirectory": "/var/folders/t6/0brzsz0s6v5fqttj19rylpn18r1g3z/T/jest_mm3xxb", "clearMocks": false, "coveragePathIgnorePatterns": [ "index.ts", "locales", "src/controllers", "src/middleware", "src/prototypes", "src/types", "tests/unit/mocks" ], "detectLeaks": false, "forceCoverageMatch": [], "globals": { "ts-jest": { "tsConfigFile": "tsconfig.json" } }, "haste": { "providesModuleNodeModules": [] }, "moduleDirectories": [ "node_modules" ], "moduleFileExtensions": [ "ts", "js" ], "moduleNameMapper": {}, "modulePathIgnorePatterns": [], "name": "3fa0a9dc4bb9d4586ae003b68f15eda0", "resetMocks": false, "resetModules": false, "restoreMocks": false, "rootDir": "/Users/qtb9604/vea-server", "roots": [ "/Users/qtb9604/vea-server" ], "runner": "jest-runner", "setupFiles": [], "snapshotSerializers": [], "testEnvironment": "/Users/qtb9604/vea-server/node_modules/jest-environment-node/build/index.js", "testEnvironmentOptions": {}, "testLocationInResults": false, "testMatch": [ "**/tests/**/*.test.(ts)" ], "testPathIgnorePatterns": [ "/node_modules/" ], "testRegex": "", "testRunner": "/Users/qtb9604/vea-server/node_modules/jest-jasmine2/build/index.js", "testURL": "about:blank", "timers": "real", "transform": [ [ "^.+\\.(ts|tsx)$", "/Users/qtb9604/vea-server/node_modules/ts-jest/preprocessor.js" ] ], "transformIgnorePatterns": [ "/node_modules/" ], "watchPathIgnorePatterns": [] } ], "globalConfig": { "bail": false, "changedFilesWithAncestor": false, "collectCoverageFrom": [ "src/**" ], "coverageDirectory": "/Users/qtb9604/vea-server/coverage", "coverageReporters": [ "json", "text", "lcov", "clover" ], "detectLeaks": false, "expand": false, "globalSetup": null, "globalTeardown": null, "listTests": false, "maxWorkers": 7, "noStackTrace": false, "nonFlagArgs": [], "notify": false, "notifyMode": "always", "passWithNoTests": false, "rootDir": "/Users/qtb9604/vea-server", "runTestsByPath": false, "testFailureExitCode": 1, "testPathPattern": "", "testResultsProcessor": null, "updateSnapshot": "new", "useStderr": false, "verbose": null, "watch": false, "watchman": true }, "version": "22.4.2" }
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Reactions: 5
- Comments: 24 (13 by maintainers)
Commits related to this issue
- Fix test coverage report generation See https://github.com/facebook/jest/issues/5772 — committed to maoberlehner/vuex-map-fields by maoberlehner 6 years ago
- Fixed a regression in `Lexeme.getSortByTwoLemmaFeatures`. Rebuilt package.lock to fix an issue with Jest metrics reporting (see https://github.com/facebook/jest/issues/5772). — committed to alpheios-project/data-models by deleted user 6 years ago
- Recreate yarn.lock to fix broken code coverage Fixes “metrics.isEmpty is not a function” when running Jest code coverage. Make sure Jest dependencies are up to date: https://github.com/facebook/jest/... — committed to gladly-team/tab by kmjennison 6 years ago
- travisci configured to use npm install instead of yarn in order to fix temporarily https://github.com/facebook/jest/issues/5772 — committed to lquixada/boggle by lquixada 6 years ago
- Upgrade jest Had to do this sooner or later: done() signature changed; any argument will be treated as a failure. Note: coverage broken until we/they update istanbul-coverage (https://github.com/fac... — committed to complexdatacollective/Server by bryfox 6 years ago
- Bump istanbul-lib-coverage for jest Can remove from package.json pending https://github.com/facebook/jest/issues/5772 — committed to complexdatacollective/Server by bryfox 6 years ago
- Upgrade jest Had to do this sooner or later: done() signature changed; any argument will be treated as a failure. Note: coverage broken until we/they update istanbul-coverage (https://github.com/fac... — committed to complexdatacollective/Server by bryfox 6 years ago
- Bump istanbul-lib-coverage for jest Can remove from package.json pending https://github.com/facebook/jest/issues/5772 — committed to complexdatacollective/Server by bryfox 6 years ago
- Upgrade jest Had to do this sooner or later: done() signature changed; any argument will be treated as a failure. Note: coverage broken until we/they update istanbul-coverage (https://github.com/fac... — committed to complexdatacollective/Server by bryfox 6 years ago
- Bump istanbul-lib-coverage for jest Can remove from package.json pending https://github.com/facebook/jest/issues/5772 — committed to complexdatacollective/Server by bryfox 6 years ago
- Upgrade jest Had to do this sooner or later: done() signature changed; any argument will be treated as a failure. Note: coverage broken until we/they update istanbul-coverage (https://github.com/fac... — committed to complexdatacollective/Server by bryfox 6 years ago
- Bump istanbul-lib-coverage for jest Can remove from package.json pending https://github.com/facebook/jest/issues/5772 — committed to complexdatacollective/Server by bryfox 6 years ago
- Trying to fix jest Following https://github.com/facebook/jest/issues/5772 — committed to JMPerez/spotify-web-api-js by JMPerez 6 years ago
- Trying to fix jest (#91) Following https://github.com/facebook/jest/issues/5772 — committed to JMPerez/spotify-web-api-js by JMPerez 6 years ago
- Trying to fix jest (#91) Following https://github.com/facebook/jest/issues/5772 — committed to cloughney/spotify-web-api-js by JMPerez 6 years ago
- Fix breaking coverage generation on Travis See https://github.com/facebook/jest/issues/5772 — committed to maoberlehner/css-node-extract by maokarriere 6 years ago
- Fixed a regression in `Lexeme.getSortByTwoLemmaFeatures`. Rebuilt package.lock to fix an issue with Jest metrics reporting (see https://github.com/facebook/jest/issues/5772). — committed to alpheios-project/alpheios-core by deleted user 6 years ago
- Upgrade jest Had to do this sooner or later: done() signature changed; any argument will be treated as a failure. Note: coverage broken until we/they update istanbul-coverage (https://github.com/fac... — committed to complexdatacollective/Server by bryfox 6 years ago
- Bump istanbul-lib-coverage for jest Can remove from package.json pending https://github.com/facebook/jest/issues/5772 — committed to complexdatacollective/Server by bryfox 6 years ago
try
yarn remove jest && yarn add --dev jest
(ornpm
equivalent) to amke sure all of Jest’s dependencies are updated as wellFWIW, I had to manually delete my
yarn.lock
file to get this working. Much thanks to others in this thread that pointed me in the correct direction 🙏 … I was banging my head around for a while.Things tried with no luck (in no particular order):
22.4.0
If you’re using only npm (not yarn), delete node_modules and package-lock.json and run
npm install
again.@dazip @felangel could you try reinstalling, I’m pretty sure the core issue is an incompatible version of
istanbul-reports
andistanbul-lib-coverage
… not quite sure why one would be upgrading and not the other for you (probably lock related).@bcoe suggestion worked for me. I initially just updated the package.json to get the latest version of jest and that’s when I got the error listed by the OP. I uninstalled and then reinstalled jest and it worked. Thanks @bcoe.
You don’t need the jest beta, you need
istanbul-lib-coverage@1.2.0
andistanbul-lib-instrument@1.10.1
, which are within semver range of at least Jest 21 and Jest 22.https://github.com/istanbuljs/istanbuljs/pull/140
When can we see the release with this fix? Or it’s released? I didn’t find this fix in
CHANGELOG.md
I’m open to apply them all 🤪
For sure, it’s just a matter of applying this:
Not sure which of them matters, but that should be enough to bump things up enough.
^got it working. I forgot my lockfile updated as well when I did the upgrade. I also ran an
npm clear cache
just to be sure newer versions were not cached as well. thanks!It worked for me as well now. Not sure what was going on before…thanks!
The pull request referenced appears to break coverage within jest. In cases where my package-lock.json used version 1.1.4 of istanbul-reports, coverage works. Updating, in which Jest pulls in 1.3.0, and the pull request above, breaks.