I have an project written in Javascript. My project is structured with this format:
.
./src
./tests
./tests/api/[folders]/[name].test.js
But Sonar only show the coverage, not the unit tests, like the image:
The code of sonar properties:
# Project settings.
sonar.projectKey=xxx
sonar.projectName=xxx
sonar.projectDescription=xxx
# Scan settings.
sonar.language=js
sonar.projectBaseDir=.
# Define the directories that should be scanned. Comma separated.
sonar.sources=src/
sonar.tests=tests/api
sonar.test.inclusions=**/*.test.js
sonar.javascript.lcov.reportPaths=coverage/lcov.info
sonar.sourceEncoding=UTF-8
sonar.exclusions=build/**,node_modules/**,coverage/**,tests/**,config/**,src/admin/**,src/extensions/**,src/services/**,**.config.js,providers/**
# Fail CI pipeline if Sonar fails.
sonar.qualitygate.wait=true
sonar.scm.disabled=true
sonar.dependencyCheck.jsonReportPath=reports/dependency-check/dependency-check-report.json
sonar.dependencyCheck.htmlReportPath=reports/dependency-check/dependency-check-report.html
sonar.dependencyCheck.summarize=true
sonar.dependencyCheck.severity.blocker=9.0
sonar.dependencyCheck.severity.critical=7.0
sonar.dependencyCheck.severity.major=4.0
sonar.dependencyCheck.severity.minor=0.0
My jest.config file:
module.exports = {
testPathIgnorePatterns: [
"/node_modules/",
".tmp",
".cache",
"./src/index.js",
],
testEnvironment: "node",
coverageReporters: [
"html",
"text",
"text-summary",
"cobertura",
"json",
"lcov",
],
collectCoverage: true,
collectCoverageFrom: ["src/**/*.js"],
// An array of regexp pattern strings used to skip coverage collection
coveragePathIgnorePatterns: [
"/node_modules/",
"/src/admin",
"/src/extensions/",
"/src/components/",
"/src/services/kafka",
"./src/index.js",
],
// An object that configures minimum threshold enforcement for coverage results
coverageThreshold: {
global: {
branches: 90,
functions: 90,
lines: 90,
statements: 90,
},
},
modulePaths: ["<rootDir>/src/", "<rootDir>/.jest"],
globalSetup: "./tests/setup.js",
globalTeardown: "./tests/teardown.js",
};
I have an total of 87 tests:
How can I solve this?