admin管理员组文章数量:1024674
I have my unit tests setup with vitest and I am looking for a way to ignore specific lines of code from vitest coverage.
Looking for something similar to /* istanbul ignore next */
.
Is there something available for vitest?
I skimmed through the docs and tried googling. Found the solution for jest but not vitest.
I have my unit tests setup with vitest and I am looking for a way to ignore specific lines of code from vitest coverage.
Looking for something similar to /* istanbul ignore next */
.
Is there something available for vitest?
I skimmed through the docs and tried googling. Found the solution for jest but not vitest.
Share Improve this question asked Jun 26, 2024 at 2:54 Mayank Kumar ChaudhariMayank Kumar Chaudhari 18.9k13 gold badges72 silver badges155 bronze badges3 Answers
Reset to default 4Finally, /* v8 ignore next */
worked.
Using coverage-v8
for coverage.
Also, there are more ways as describe in docs
Thanks to @Gab
ignoring the next N lines
const myVariable = 99
/* v8 ignore next 3 */
if (process.platform === 'win32') {
console.info('hello world')
}
ignoring all lines until told
/* v8 ignore start */
function dontMindMe() {
// ...
}
/* v8 ignore stop */
ignoring the same line as the ment
const myVariable = 99
const os = process.platform === 'darwin' ? 'OSXy' /* v8 ignore next */ : 'Windowsy'
It depends if you are using instanbul
or v8
to provide the coverage of your code (default is v8
) (See coverage providers documentation).
You can see the official documentation by Vitest in their link.
Basically, for v8
you can use
/* v8 ignore next */
as well as other described in their documentation like
/* v8 ignore start */
ignored_code()
/* v8 ignore stop */
For Vue templates do:
<!-- /* v8 ignore next 5 */ -->
<template>
<div v-if="someProp">
{{ someProp }}
</div>
</template>
In case you happen to run into this coverage bug:
- https://github./vitejs/vite-plugin-vue/issues/368
I have my unit tests setup with vitest and I am looking for a way to ignore specific lines of code from vitest coverage.
Looking for something similar to /* istanbul ignore next */
.
Is there something available for vitest?
I skimmed through the docs and tried googling. Found the solution for jest but not vitest.
I have my unit tests setup with vitest and I am looking for a way to ignore specific lines of code from vitest coverage.
Looking for something similar to /* istanbul ignore next */
.
Is there something available for vitest?
I skimmed through the docs and tried googling. Found the solution for jest but not vitest.
Share Improve this question asked Jun 26, 2024 at 2:54 Mayank Kumar ChaudhariMayank Kumar Chaudhari 18.9k13 gold badges72 silver badges155 bronze badges3 Answers
Reset to default 4Finally, /* v8 ignore next */
worked.
Using coverage-v8
for coverage.
Also, there are more ways as describe in docs
Thanks to @Gab
ignoring the next N lines
const myVariable = 99
/* v8 ignore next 3 */
if (process.platform === 'win32') {
console.info('hello world')
}
ignoring all lines until told
/* v8 ignore start */
function dontMindMe() {
// ...
}
/* v8 ignore stop */
ignoring the same line as the ment
const myVariable = 99
const os = process.platform === 'darwin' ? 'OSXy' /* v8 ignore next */ : 'Windowsy'
It depends if you are using instanbul
or v8
to provide the coverage of your code (default is v8
) (See coverage providers documentation).
You can see the official documentation by Vitest in their link.
Basically, for v8
you can use
/* v8 ignore next */
as well as other described in their documentation like
/* v8 ignore start */
ignored_code()
/* v8 ignore stop */
For Vue templates do:
<!-- /* v8 ignore next 5 */ -->
<template>
<div v-if="someProp">
{{ someProp }}
</div>
</template>
In case you happen to run into this coverage bug:
- https://github./vitejs/vite-plugin-vue/issues/368
本文标签: javascriptHow to ignore lines of code from coverage in vitestStack Overflow
版权声明:本文标题:javascript - How to ignore lines of code from coverage in vitest? - Stack Overflow 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://it.en369.cn/questions/1745618144a2159414.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论