I am using node 8.11 "ts-jest": "^23.1.3", and "jest": "^23.4.2",. I set "skipBabel": true in jest config file. This cause code coverage to 0%. Removing this flag make coverage correct.
Setting this flag to true should not cause code coverage result.
// skipBabel: true:
=============================== Coverage summary ===============================
Statements : 0% ( 0/1080 )
Branches : 0% ( 0/194 )
Functions : 0% ( 0/211 )
Lines : 0% ( 0/930 )
// without skipBabel:
=============================== Coverage summary ===============================
Statements : 69.81% ( 754/1080 )
Branches : 28.87% ( 56/194 )
Functions : 33.18% ( 70/211 )
Lines : 71.61% ( 666/930 )
Let me know if you want my config files.
Maybe it is not possible to have good code coverage with skipBabel flag?
@Lazarencjusz thanks for reporting the issue. Unfortunately we rely on babel to hoist jest.mock calls and provide coverage.
It might be possible to leverage the instrumentation to jest tho when skipBabel is set to true, we'll investigate and update this issue... In the meantime if you could provide a minimal repo to reproduce that particular issue that would be awesome.
@huafu thanks, I will try to near future :)
@Lazarencjusz you could try the beta version now, see #697
@huafu confirmed beta fixed this issue. 🌷
Want to note that this issue also exists in v22.
Still waiting for https://github.com/facebook/jest/issues/2441 for jest@23 to be really usable.
@unional in ts-jest beta we actually output logs using process.stdxxx directly.
Anyway, not sure if you got to read that jest issue lately, but it seems that setting the env var TERM=dumb "fixes" the issue...
Anyway, ts-jest@next should work with jest 22.
In general if you have issues with the beta, let us know on slack
@huafu I can't confirm it works (beta version you mentioned), test cause many (TS) compile errors like it can't compile TS or can't find module. I will wait for stable version.
@Lazarencjusz those errors are normal since the beta version has diagnostics enabled by default. The beta is pretty stable, we just need more people to test it.
I can help you if you want, come on the new Slack community. Else you can find the (unfinished) documentation about beta there – check the Configuration item in the User Doc. menu (it's not the official link so it'll disappear once beta is merged into master).
the same error with skipBabel: true at v23.1.4
// @ts-check
const { defaults } = require('jest-config')
/**
* @type {import('./types').TsJestConfig}
*/
const tsJestConfig = {
// skipBabel: false
}
/**
* @type {Partial<jest.InitialOptions>}
*/
const config = {
rootDir: '..',
transform: {
'^.+\\.(ts|tsx)$': 'ts-jest',
},
testMatch: [
'<rootDir>/src/**/__tests__/**/*.ts?(x)',
'<rootDir>/src/**/?(*.)+(spec|test).ts?(x)',
],
moduleFileExtensions: [...defaults.moduleFileExtensions, 'ts', 'tsx'],
globals: {
'ts-jest': tsJestConfig,
},
coverageThreshold: {
global: {
branches: 80,
functions: 80,
lines: 80,
statements: 80,
},
},
collectCoverageFrom: ['<rootDir>/src/**/*.ts'],
setupFiles: ['<rootDir>/config/setup-tests.js'],
watchPlugins: [
'jest-watch-typeahead/filename',
'jest-watch-typeahead/testname',
],
}
module.exports = config
@ifmos in your code skipBabel is not set at all.
You should try beta, see #697
Most helpful comment
@huafu confirmed beta fixed this issue. 🌷