When running npm test using jest with jest configuration
{
...,
"scripts": {
"test": "jest"
},
"jest": {
"collectCoverage": true
},
"devDependencies": {
"eslint": "^4.18.2",
"eslint-config-google": "^0.9.1",
"istanbul": "^0.4.5",
"istanbul-api": "^1.3.1",
"istanbul-lib-report": "^1.1.3",
"jest": "^22.4.2"
}
}
In the package.json and using npm test, I am receiving this error at the end of a test
> [email protected] test /Users/netghost/Projects/js/newsirc
> jest
PASS __tests__/RSS_IO_test.js
class RSS_IO
✓ starts construction at initialization (3ms)
✓ has an array of rss_urls (1ms)
-----------|----------|----------|----------|----------|-------------------|
File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s |
-----------|----------|----------|----------|----------|-------------------|
All files | 100 | 100 | 100 | 100 | |
Failed to write coverage reports:
ERROR: TypeError: metrics.isEmpty is not a function
STACK: TypeError: metrics.isEmpty is not a function
at tableRow (/Users/netghost/Projects/js/newsirc/node_modules/istanbul-reports/lib/text/index.js:133:27)
at TextReport.onSummary (/Users/netghost/Projects/js/newsirc/node_modules/istanbul-reports/lib/text/index.js:188:15)
at TextReport.onDetail (/Users/netghost/Projects/js/newsirc/node_modules/istanbul-reports/lib/text/index.js:193:17)
at Visitor.(anonymous function) [as onDetail] (/Users/netghost/Projects/js/newsirc/node_modules/istanbul-api/node_modules/istanbul-lib-report/lib/tree.js:34:30)
at ReportNode.Node.visit (/Users/netghost/Projects/js/newsirc/node_modules/istanbul-api/node_modules/istanbul-lib-report/lib/tree.js:123:17)
at /Users/netghost/Projects/js/newsirc/node_modules/istanbul-api/node_modules/istanbul-lib-report/lib/tree.js:116:23
at Array.forEach (<anonymous>)
at visitChildren (/Users/netghost/Projects/js/newsirc/node_modules/istanbul-api/node_modules/istanbul-lib-report/lib/tree.js:115:32)
at ReportNode.Node.visit (/Users/netghost/Projects/js/newsirc/node_modules/istanbul-api/node_modules/istanbul-lib-report/lib/tree.js:126:5)
at Tree.visit (/Users/netghost/Projects/js/newsirc/node_modules/istanbul-api/node_modules/istanbul-lib-report/lib/tree.js:158:20)
Test Suites: 1 passed, 1 total
Tests: 2 passed, 2 total
Snapshots: 0 total
Time: 1.039s
Ran all test suites.
With a test ./__tests__/RSS_IO_test.js
describe('class RSS_IO', () => {
const rssobj = new RSS_IO(localConfig.RSSUrls);
it('starts construction at initialization', () => {
expect(typeof rssobj).toBe('object');
});
it('has an array of rss_urls', () => {
expect(typeof rssobj.rss_urls.length).toBe('number');
});
});
of a class RSS_IO
class RSS_IO {
constructor(rss_urls) {
this.rss_urls = rss_urls;
}
}
module.exports = RSS_IO;
Looking at the file ./node_modules/istanbul-reports/lib/text/index.js around Line 133
function tableRow(node, context, colorizer, maxNameCols, level, skipEmpty) {
var name = nodeName(node),
metrics = node.getCoverageSummary(),
isEmpty = metrics.isEmpty();
if (skipEmpty && isEmpty) { return ''; }
...;
}
There seems to be a metrics object calling isEmpty either incorrectly by name/reference or not defined.
Is there any reason to why isEmpty() of the metrics object not be defined? Missing library? Missing install library?
Thank you
facebook/jest#5772
@dazip I don't know how or where to implement --skip-empty through the jest settings in package.json
@ryan-lang I have made my package.json
"devDependencies": {
"eslint": "^4.18.2",
"eslint-config-google": "^0.9.1",
"istanbul": "^0.4.5",
"istanbul-api": "^1.3.1",
"istanbul-lib-report": "^1.1.3",
"istanbul-reports": "1.1.4",
"jest": "^22.4.2"
}
but no fix
@risingsunomi My workaround was to pin the following versions, delete node_modules and reinstall fresh. Although, this is shaky because you may have another dependency pulling in the newer broken version.
"istanbul-api": "1.2.2",
"istanbul-reports": "1.1.4",
@ryan-lang ok thank you - trying that now
@ryan-lang that worked! Thank you very much. Apprectiate it.
Delete your local node_modules
Put in your package.json
"devDependencies": {
"eslint": "^4.18.2",
"eslint-config-google": "^0.9.1",
"istanbul": "^0.4.5",
"istanbul-api": "1.2.2",
"istanbul-reports": "1.1.4",
"jest": "^22.4.2"
},
With
"istanbul-api": "1.2.2",
"istanbul-reports": "1.1.4"
Most helpful comment
@ryan-lang that worked! Thank you very much. Apprectiate it.
Fix in package.json
Delete your local node_modules
Put in your package.json
With