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 issues #504

Open
SamuelWei opened this issue Oct 21, 2022 · 4 comments
Open

Coverage issues #504

SamuelWei opened this issue Oct 21, 2022 · 4 comments

Comments

@SamuelWei
Copy link

SamuelWei commented Oct 21, 2022

Running the coverage gives me a strange output, missing some code blocks, even if the code should perform exactly the same

Missing coverage in lines 291-305
Bildschirmfoto 2022-10-21 um 16 16 59

Working: Saving promise to an variable and using it for .then and .catch
Bildschirmfoto 2022-10-21 um 16 10 12

Working: Saving promise to an used variable
Bildschirmfoto 2022-10-21 um 16 16 17

Is there something working with the coverage or am I missing something obvious?

I have worked through many issues and recommendations including multiple jest and vue-jest versions.
I also used v8 and the default babel coverage reporter. However both coverage providers cause issues in my vue2 project and none is working really accurate.

My current config:
vue: 2.6.14
@vue/vue2-jest: 29.1.1
jest: 29.2.1

jest.config.js

....
transform: {
    '^.+\\.vue$': '@vue/vue2-jest',
    '^.+\\.js$': 'babel-jest'
},
....
@SamuelWei
Copy link
Author

SamuelWei commented Nov 29, 2022

I traced the issue down to jests pre-processor https://github.com/facebook/jest/blob/6e5b1d60a1214e792b5229993b5475445e9c1a6e/e2e/coverage-transform-instrumented/preprocessor.js#L24

I traced the issue down to babel-jest
https://github.com/facebook/jest/blob/6e5b1d60a1214e792b5229993b5475445e9c1a6e/packages/babel-jest/src/index.ts#L52

If the coverage is set to babel it is adding the /* istanbul ignore next */ to many lines which are therefore ignored in the coverage. Using v8 doen't add this line or /* c8 ignore next */.

In the vue-jest process function a config is passed to babel-jest having the variable instrument true for babel and false for v8

const result = transformer.process(scriptPart.content, filePath, config)

I don't know why this is done and where to change this config value.

@lmiller1990 Do you know why this is happening?
@SimenB Do you know why this istanbul ignore next was added to the preprocessor ?

@lmiller1990
Copy link
Member

In the vue-jest process function a config is passed to babel-jest having the variable instrument true for babel and false for v8

I am not sure why this would be happening. If you play around in node_modules/vue-jest, are you able to get something working? Happy to accept a PR - I'm not working on Vue Jest (other than critical bug fixes/security issues) nowadays. I'm don't expect to be able to spend much time debugging this.

Do you think there's an issue in Jest or this bug is localize to Vue Jest?

@SamuelWei
Copy link
Author

@SimenB
Copy link
Contributor

SimenB commented Nov 30, 2022

@SimenB Do you know why this istanbul ignore next was added to the preprocessor ?

Not sure - it was added back in jestjs/jest#785 before my involvement with the project. However, the issue that PR talks about (babel's helpers) should have been solved by supporting source maps, which we've done for a few years at this point. Happy to take a PR removing it if it doesn't do anything useful anymore 🙂

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants