istanbul
istanbul copied to clipboard
"else path not taken" for class in ES6
I hava a problem with the coverage, look:
But, written in this way, it works:
- Maybe, this way is not correct. Maybe, no best practice.
Any update on that?
Actually, I had the same issue and I found this gist https://gist.github.com/pbeshai/7bb7ba4bf257249493de, which I converted to:
// bin/jestPreprocessor.js
var babel = require('babel-core')
var fs = require('fs')
// setup source mapping as per https://github.com/facebook/jest/issues/114
var map_path = function(string) {
return '/tmp/' + require('crypto').createHash('md5').update(string).digest('hex') + '.map'
}
module.exports = {
process: function(src, filename) {
if (!babel.util.canCompile(filename)) {
return ''
}
if (filename.indexOf('node_modules') !== -1) {
return src
}
if (babel.util.canCompile(filename)) {
// Force inclusion of the polyfill, then append regular compiled output.
var compiled = babel.transform(src, { filename: filename, sourceMap: true })
var result = compiled.code
fs.writeFileSync(map_path(filename), JSON.stringify(compiled.map))
return result
}
return src
},
}
Then, in my package.json, I have in the Jest section:
"transform": {
"^.+\\.jsx$": "<rootDir>/node_modules/babel-jest",
".*": "<rootDir>/bin/jestPreprocessor"
}
I hope it will work for you too.
No, doesn't work for me. But thanks anyway :)
What is your configuration ?
Have same strange issue for React and React Native import statements
I'm using Jest for testing. My Jest config looks like:
"jest": {
"preset": "react-native",
"transform": {
"^.+\\.jsx?$": "babel-jest",
"^.+\\.(ts|tsx)$": "typescript-babel-jest"
},
"testRegex": "(/__tests__/.*|\\.(test|spec))\\.(ts|tsx|js)$",
"testPathIgnorePatterns": [
"/node_modules/",
"packager/react-packager/src/Activity/"
],
"globals": {
"__TS_CONFIG__": {
"jsx": "react"
}
},
"setupFiles": [
"<rootDir>/jestconfig.js"
],
"transformIgnorePatterns": [
"<rootDir>/node_modules/(?!(jest-)?react-native|react-navigation|react-clone-referenced-element)"
],
"moduleFileExtensions": [
"ts",
"tsx",
"js"
],
"collectCoverageFrom": [
"**/*.{ts,tsx}"
],
"coverageDirectory": "./reports/coverage",
"coverageReporters": ["lcov", "text-summary"]
}
I'm getting the same results. My code has no logic at this point. I tried removing empty lines and the error showed on different lines.
+1
Have same strange issue for React and React Native import statements
I'm using Jest for testing. My Jest config looks like:
"jest": { "preset": "react-native", "transform": { "^.+\\.jsx?$": "babel-jest", "^.+\\.(ts|tsx)$": "typescript-babel-jest" }, "testRegex": "(/__tests__/.*|\\.(test|spec))\\.(ts|tsx|js)$", "testPathIgnorePatterns": [ "/node_modules/", "packager/react-packager/src/Activity/" ], "globals": { "__TS_CONFIG__": { "jsx": "react" } }, "setupFiles": [ "<rootDir>/jestconfig.js" ], "transformIgnorePatterns": [ "<rootDir>/node_modules/(?!(jest-)?react-native|react-navigation|react-clone-referenced-element)" ], "moduleFileExtensions": [ "ts", "tsx", "js" ], "collectCoverageFrom": [ "**/*.{ts,tsx}" ], "coverageDirectory": "./reports/coverage", "coverageReporters": ["lcov", "text-summary"] }
did you get this to work @olegdeezus ?
Have same strange issue for React and React Native import statements
I'm using Jest for testing. My Jest config looks like:
"jest": { "preset": "react-native", "transform": { "^.+\\.jsx?$": "babel-jest", "^.+\\.(ts|tsx)$": "typescript-babel-jest" }, "testRegex": "(/__tests__/.*|\\.(test|spec))\\.(ts|tsx|js)$", "testPathIgnorePatterns": [ "/node_modules/", "packager/react-packager/src/Activity/" ], "globals": { "__TS_CONFIG__": { "jsx": "react" } }, "setupFiles": [ "<rootDir>/jestconfig.js" ], "transformIgnorePatterns": [ "<rootDir>/node_modules/(?!(jest-)?react-native|react-navigation|react-clone-referenced-element)" ], "moduleFileExtensions": [ "ts", "tsx", "js" ], "collectCoverageFrom": [ "**/*.{ts,tsx}" ], "coverageDirectory": "./reports/coverage", "coverageReporters": ["lcov", "text-summary"] }
almost four years now...any solution?