排除SonarCloud中React组件的测试文件。

huangapple go评论62阅读模式
英文:

Exclude the test files for React components in sonarcloud

问题

我有一个React应用程序,具有以下文件夹结构

src
    components
        Component1
            Component1.tsx
            Component2.test.tsx
        Component2
            Component2.tsx
            Component2.test.tsx
    utils
    reducers
    pages

我想从sonar云覆盖中排除src文件夹中的*.test.tsx文件。我可以将其移动到一个测试文件夹,然后从覆盖中排除测试文件夹,但这将对整个代码库进行非常大的更改。

我有一个sonar-project.properties文件,其中有一个sonar.coverage.exclusions,但我不确定如何将其添加到这个特定的用例中。

英文:

I have a React application with the following folder structure

src
    components
        Component1
            Component1.tsx
            Component2.test.tsx
        Component2
            Component2.tsx
            Component2.test.tsx
    utils
    reducers
    pages

I would like to exclude the *.test.tsx files in the src folder from the sonar cloud coverage. I could move it to a test folder and then exclude the test folder from the coverage but that would be a very big change for the entire codebase.

I have a sonar-project.properties file that has a sonar.coverage.exclusions but I am not sure how to add it for this particular use-case.

答案1

得分: 1

sonar.coverage.exclusions = src/**/*.test.tsx

英文:

I think, to exclude the *.test.tsx files in the src folder from the SonarCloud coverage, you can add the following line to your sonar-project.properties file:

sonar.coverage.exclusions = src/**/*.test.tsx

huangapple
  • 本文由 发表于 2023年7月10日 16:30:19
  • 转载请务必保留本文链接:https://go.coder-hub.com/76652014.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定