I bump into the problem when the mocha shows 100% code coverage but sonar show that some lines not covered by tests. For example, the code block:
constructor(login: string, password: string, options: any = {}) {
this._webService = new WebService(login, password)
this._webStorageUrl = options.webStorageUrl || STAGING_WEB_STORAGE_URL
this._serviceUrl = options.serviceUrl || STAGING_SERVICE_URL
this._clientId = options.clientId || STAGING_CLIENT_ID
this._userPoolId = options.userPoolId || STAGING_USER_POOL_ID
const { walletUrl, paymentUrl, verificationUrl } = options
this._api = new API(walletUrl, paymentUrl, verificationUrl)
}
sonar shows that I should cover these lines with test :
const { walletUrl, paymentUrl, verificationUrl } = options
this._api = new API(walletUrl, paymentUrl, verificationUrl)
To transfer the results I use: nyc —reporter=lcov —reporter=text-summary mocha
Could someone tell me how can I solve the problem of code coverage mismatch or disable code coverage verification of a certain line in SonarQube?
P.S. I use:
- SonaQube v. 8.3.1.34397
- “mocha”: “^7.0.0”,
- “nyc”: “^15.0.1”,