Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Coverage breaks sourcemaps #917

Closed
Bartosz-D3V opened this issue Dec 19, 2018 · 11 comments
Closed

Coverage breaks sourcemaps #917

Bartosz-D3V opened this issue Dec 19, 2018 · 11 comments

Comments

@Bartosz-D3V
Copy link

Bartosz-D3V commented Dec 19, 2018

Issue :

If user enables test coverage with Jest then the sourcemaps are not correct.

Expected behavior :

Lines should be shown correctly, even if developer enables coverage report with Jest.

Minimal repo :

Github project: https://github.com/maxpolski/ts-react-jest/ Please kindly note that this is NOT my repository
Run jest with coverage option.
You will notice that the sourcemaps are not working correctly. To make sure, you can add console.log() in any React component and compare the line where console.log occured with the one displayed in the jest output.
Interestingly, sourcemaps work absolutely fine in test files, but not in source files.

@dgreene1
Copy link

I confirmed that this was the cause of my inability to debug tests via vscode-jest. Turning off code coverage allowed the sourcemaps to be built properly.

@bfsmith
Copy link

bfsmith commented Mar 21, 2019

Any thoughts on the cause/fix? I started seeing this today. My index.ts file has around 100 lines but jest is reporting console.log calls on lines > 1000.

leosingleton added a commit to leosingleton/fim that referenced this issue Apr 1, 2019
Code coverage breaks sourcemaps in ts-jest which makes the debugger
mostly unusable. This is documented as an open issue here:
kulshekhar/ts-jest#917
@CoderCoco
Copy link

I can confirm that this is an issue for me as well.

It was driving me crazy because it also prevented debuggers from stepping through the code. Glad I found that I was not the only one experiencing this.

@ericrini
Copy link

ericrini commented May 22, 2019

Can confirm, VSCode debugger reports line numbers >6000 in file with 300 lines and fails to hit breakpoints when using the ts-jest interpreter and jest test runner. Disabling code coverage appears to reduce or resolve the problem(s).

@atifsyedali
Copy link

I am getting this problem as well when I turn on coverage. Looking through similar issues I found #484 which has some commits to fix this same issue though, and I am using the latest build, so I am kind of confused...

@wesleygrimes
Copy link

Hi all,

I am having the same issue. I took some time and created a small repository that reproduces the issue: https://github.com/wesleygrimes/ts-jest-coverage-incorrect-line-numbers

I am seeing this issue as well with jest: 24.8.0 and ts-jest: 24.0.2.

jest.config.js:

module.exports = {
  testMatch: ['**/+(*.)+(spec|test).+(ts|js)?(x)'],
  transform: {
    '^.+\\.(ts|js|html)$': 'ts-jest'
  },
  roots: ['<rootDir>/src'],
  moduleFileExtensions: ['ts', 'js', 'html'],
  collectCoverage: true,
  coverageReporters: ['html']
};

We need collectCoverage enabled. Is there a fix planned for this? Would be happy to help with a PR if someone can point me in the right direction.

Thanks!

@antonovicha
Copy link

Was fixed in 23.1.2, see . But reproducible in:
jest 24.9.0 + ts-jest 24.0.2
jest 23.6.0 + ts-jest 23.10.5 (latest 23.* versions as of today)

Workaround for debugging:

  • remove collectCoverage from config
  • add --coverage to jest cli in test script of package.json:
"test": "jest --config ./jestConfig.json --coverage"

@davidcoleman007
Copy link

davidcoleman007 commented Sep 30, 2019

any news on when this may be fixed? Being locked on v 23.1.2 is making moving to jest 24 a painful experience.

@Prior99
Copy link

Prior99 commented Dec 18, 2019

In order to get debugging to work, I removed "collectCoverage" from my jest configuration and instead changed my npm script to jest --coverage. Then, in VSCode's launch configuration I did not add that flag. Who needs coverage during debugging anyways? It also makes the test execution slower.

Of course, this is just a workaround until this is fixed.

@markcarroll
Copy link

markcarroll commented Jan 1, 2020

I found a fix that works well for me. If you add --coverage false to the command line when the jest debugger is run, it works just fine. The solution is to add this block to your launch configuration in .vscode/launch.json:

    {
      "type": "node",
      "request": "launch",
      "name": "vscode-jest-tests",
      "cwd": "${workspaceFolder}",
      "args": ["--inspect-brk", "${workspaceRoot}/node_modules/.bin/jest", "--runInBand",
               "--config", "--coverage", "false"],
      "console": "integratedTerminal",
      "internalConsoleOptions": "neverOpen"
    },

reedrosenbluth added a commit to stacks-archive/stacks-transactions-js that referenced this issue Mar 18, 2020
reedrosenbluth added a commit to stacks-archive/stacks-transactions-js that referenced this issue Mar 18, 2020
reedrosenbluth added a commit to stacks-archive/stacks-transactions-js that referenced this issue Mar 19, 2020
* remove collectCoverage from jest.config.js and move to package.json test script kulshekhar/ts-jest#917

* add lodash dependency (for cloneDeep function)

* reorder ContractCall and SmartContract values in PayloadType enum

* contract deploy and contract-call tests

* implement intoInitialSighashAuth() and clear() functions

* fix signBegin function (should clone the transaction before clearing its Auth)

* npm audit fix
@ahnpnl
Copy link
Collaborator

ahnpnl commented Mar 29, 2020

This is not ts-jest issue. Please check related discussion in jestjs/jest#5739

@ahnpnl ahnpnl closed this as completed Mar 29, 2020
johnmartel added a commit to johnmartel/organization-membership-action that referenced this issue Apr 30, 2020
This is a workaround since enabling coverage breaks sourceMaps.

See: kulshekhar/ts-jest#917
See: jestjs/jest#5739
johnmartel added a commit to johnmartel/organization-membership-action that referenced this issue May 1, 2020
This is a workaround since enabling coverage breaks sourceMaps.

See: kulshekhar/ts-jest#917
See: jestjs/jest#5739
johnmartel added a commit to johnmartel/organization-membership-action that referenced this issue May 10, 2020
This is a workaround since enabling coverage breaks sourceMaps.

See: kulshekhar/ts-jest#917
See: jestjs/jest#5739
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests