ts-jest: Partial code coverage or incorrect mapping

  • Issue

Hi and thanks for all the job done for this library ๐Ÿ‘

I have probably the same issue as https://github.com/kulshekhar/ts-jest/issues/339 but with a single repo. The solution pointed in the issue is not suitable in my case.

I either have an incorrect code mapping on coverage without "mapCoverage": true or missing files when this option is removed + an almost correct mapping.

Incorrect mapping + all files covered

------------------------------|----------|----------|----------|----------|----------------|
File                          |  % Stmts | % Branch |  % Funcs |  % Lines |Uncovered Lines |
------------------------------|----------|----------|----------|----------|----------------|
All files                     |    83.33 |      100 |    66.67 |       75 |                |
 rnTsWithJest                 |      100 |      100 |      100 |      100 |                |
  App.tsx                     |      100 |      100 |      100 |      100 |                |
  Home.tsx                    |      100 |      100 |      100 |      100 |                |
 rnTsWithJest/core/locales    |        0 |      100 |        0 |        0 |                |
  index.ts                    |        0 |      100 |        0 |        0 |              4 |
 rnTsWithJest/core/locales/en |      100 |      100 |      100 |      100 |                |
  common.ts                   |      100 |      100 |      100 |      100 |                |
  index.ts                    |      100 |      100 |      100 |      100 |                |
 rnTsWithJest/core/locales/fr |      100 |      100 |      100 |      100 |                |
  common.ts                   |      100 |      100 |      100 |      100 |                |
  index.ts                    |      100 |      100 |      100 |      100 |                |
------------------------------|----------|----------|----------|----------|----------------|
capture d ecran 2017-11-13 a 10 09 52

(Almost) Correct mapping + missing covered files

---------------------------|----------|----------|----------|----------|----------------|
File                       |  % Stmts | % Branch |  % Funcs |  % Lines |Uncovered Lines |
---------------------------|----------|----------|----------|----------|----------------|
All files                  |    83.33 |      100 |    66.67 |    83.33 |                |
 rnTsWithJest              |      100 |      100 |      100 |      100 |                |
  App.tsx                  |      100 |      100 |      100 |      100 |                |
  Home.tsx                 |      100 |      100 |      100 |      100 |                |
 rnTsWithJest/core/locales |        0 |      100 |        0 |        0 |                |
  index.ts                 |        0 |      100 |        0 |        0 |              5 |
---------------------------|----------|----------|----------|----------|----------------|

capture d ecran 2017-11-13 a 10 10 18
  • Expected behavior

Having correct code mapping on coverage report without missing covered files.

Any help would be greatly appreciated.

  • Minipal repo

https://github.com/momsse/rnTsWithJest

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Reactions: 7
  • Comments: 36 (10 by maintainers)

Most upvoted comments

Looks that after I upgrade to Jest 23.4.2 and ts-jest 23.1.3 the coverage is mapped correctly. Thank you guys!

@kulshekhar thanks for your fast reply ๐Ÿ‘

I just shaved a lot of noise to make your work easier. Screenshots and reports have been updated too. Let me know if you need anything else to solve my issue.

I can confirm the coverage report is now correct with 23.1.2 and skipBabel: false. Thank you for the great work ๐Ÿ˜ƒ

@jscinoz you should test with latest ts-jest 23.1.2. If there is still a problem, please create a new issue with a minimal repo.

I am closing this right now (see https://github.com/kulshekhar/ts-jest/issues/371#issuecomment-408749694)

for me the not executed files during tests are still showing weird coverage mappings.

Tried with jest 22.4.2 and ts-jest 22.4.0

Iโ€™d probably start by checking the babel step, which is in the postprocess file. Reproduce the bug in a repo, and perhaps try comparing it to output manually generated by tsc. To see whether we mess up before sending it to babel somehow or the babel step isnโ€™t configured properly. Itโ€™s not much of a lead to go on, but itโ€™s my best guess.

@jscinoz Iโ€™ve also changed this in jest config (but that doesnโ€™t affect anything anyway):

    "transform": {
      "^.+\\.js$": "babel-jest",
      ".(ts|tsx)": "ts-jest"
    },

Iโ€™m now getting the following error:

  console.error node_modules/fbjs/lib/warning.js:35
    Warning: PropTypes has been moved to a separate package. Accessing React.PropTypes is no longer supported and will be removed completely in React 16. Use the prop-types package on npm instead. (https://fb.me/migrating-from-react-proptypes)

  console.error node_modules/fbjs/lib/warning.js:35
    Warning: checkPropTypes has been moved to a separate package. Accessing React.checkPropTypes is no longer supported and will be removed completely in React 16. Use the prop-types package on npm instead. (https://fb.me/migrating-from-react-proptypes)

  console.error node_modules/fbjs/lib/warning.js:35
    Warning: React.createClass is no longer supported. Use a plain JavaScript class instead. If you're not yet ready to migrate, create-react-class is available on npm as a drop-in replacement. (https://fb.me/migrating-from-react-create-class)

Would it be possible for you to get the linked repo to a state where it shows just the wrong coverage without other errors?