Code Coverage report stating last closing brace as uncovered
See original GitHub issueš Bug Report
To Reproduce
Steps to reproduce the behavior: Here is my class:
import { container, inject, injectable } from 'tsyringe';
import AppError from '@shared/errors/AppError';
import ILogger from '@shared/infra/logger/interfaces/ILogger';
import User from '../models/User';
import CheckIfUserExists from './CheckIfUserExistsUseCase';
interface IRequest {
requestedUserId: string;
requestingUserId: string;
requestId: string;
}
@injectable()
class ShowUserUseCase {
constructor(
@inject('logger')
private logger: ILogger
) {}
public async execute({
requestedUserId,
requestingUserId,
requestId,
}: IRequest): Promise<User> {
this.logger.log('info', 'Showing a User', {
requestedUserId,
requestingUserId,
requestId,
});
const checkIfUserExists = container.resolve(CheckIfUserExists);
const doesUserExist = await checkIfUserExists.execute({
id: requestedUserId,
});
if (!doesUserExist) {
this.logger.log('info', 'Requested user does not exist.', {
requestedUserId,
requestingUserId,
requestId,
});
throw new AppError('User not found', {}, 404);
}
this.logger.log('info', 'User found.', {
requestedUserId,
requestingUserId,
requestId,
});
return doesUserExist as User;
}
}
export default ShowUserUseCase;
Here is the lcov output alongside jest
This happens to every single class of mine. As you can see, it is the only factor that makes this particular class not 100% on coverage of statements and lines. Also not sure why branches is not 100% covered here.
Expected behavior
I expected to a closing brace be a covered line of code.
envinfo
System:
OS: Linux 4.19 Ubuntu 20.04.1 LTS (Focal Fossa)
CPU: (4) x64 Intel(R) Core(TM) i5-4460 CPU @ 3.20GHz
Binaries:
Node: 12.19.0 - ~/.nvm/versions/node/v12.19.0/bin/node
Yarn: 1.22.5 - /usr/bin/yarn
npm: 6.14.8 - ~/.nvm/versions/node/v12.19.0/bin/npm
npmPackages:
jest: 26.6.1 => 26.6.1
Issue Analytics
- State:
- Created 3 years ago
- Comments:6
Top Results From Across the Web
code coverage issue with brace | Apple Developer Forums
I've got a Swift function for which Xcode is showing 0 passes in code coverage. The line is a closing brace (highlighted in...
Read more >Why is a closing brace showing no code coverage?
The issue boils down to the return statement not allowing it to fall down to the empty else statement, thus indicating the code...
Read more >Code coverage colouring is red highlighting a test method ...
The thing is, it only highlights the closing bracet of the method! Pressumably, it is because the test method throws an exception, thus...
Read more >How to stop reporting uncovered line with only braces?
I have unit tests covering the if and else parts, but SonarQube reports that there's no coverage for the line that has only...
Read more >Closing braces sometimes not being included in code ...
Hi Jim, Unfortunately, there's a known issue with closing braces in dotCover: dotCover considers as uncovered closing braces in methods thatĀ ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Ah no wait! It works on Node 14 correctly, but with node 12 I get the same result as you do. Probably something to do with babelās transform then. I donāt think itās an issue with Jest, tho?
Closing, but if you still think itās a bug in Jest we can reopen
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. Please note this issue tracker is not a help forum. We recommend using StackOverflow or our discord channel for questions.