简体   繁体   English

SonarQube 在节点 js 应用程序中显示 0% 的代码覆盖率

[英]SonarQube showing 0% code coverage in node js application

I have installed sonar Qube and integrated it with node js application.我已经安装了声纳 Qube 并将其与节点 js 应用程序集成。 Right now I am getting code coverage as zero so I created a sonar properties file as below现在我的代码覆盖率为零,所以我创建了一个声纳属性文件,如下所示

sonar.projectKey=MyApp
sonar.login=[token]

sonar.sources=.

#sonar.exclusions=app/node_modules/*,app/coverage/lcov-report/*

# coverage reporting
sonar.javascript.coveragePlugin=lcov
sonar.javascript.lcov.reportPaths=app/coverage/lcov.info

but still my code coverage is coming as 0 %但我的代码覆盖率仍然是 0 %

Any Idea how can I solve this.任何想法我该如何解决这个问题。

There are some information gaps that we should fill in so that I can help you better, like, when you're trying to get coverage?我们应该填补一些信息空白,以便我可以更好地帮助您,例如,当您试图获得报道时? You're using some kind of CI/CD pipeline?您正在使用某种 CI/CD 管道吗?

Despite this, I had a similar problem a while back and I believe it might help, it turns out that when you use sonarcloud in some pipeline the code that is scanned by the sonar is the difference between the source code and yours.尽管如此,不久前我遇到了类似的问题,我相信它可能会有所帮助,事实证明,当您在某些管道中使用 sonarcloud 时,声纳扫描的代码是源代码和您的代码之间的差异。

So if you add or change code which is not covered by test setup it will show code coverage as no information and if you add or change code covered it will show a percentage just referring to changed code.因此,如果您添加或更改测试设置未涵盖的代码,它将显示代码覆盖率作为无信息,如果您添加或更改已覆盖的代码,它将显示仅指更改代码的百分比。

I will also share with you my sonar setup from a personal project, hope it helps.我还将与您分享我的个人项目中的声纳设置,希望对您有所帮助。

sonar.projectKey=some_organization_algorithms-data-structures
sonar.organization=some_organization
sonar.projectName=Algorithms and Data Structures
sonar.sourceEncoding=UTF-8
sonar.sources=src
sonar.exclusions=**/*.spec.ts
sonar.tests=__tests__
sonar.test.inclusions=**/*.spec.ts
sonar.javascript.lcov.reportPaths=coverage/lcov.info

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM