0
Hello, I have a project built in Typescript and in it I am using Jest (ts-jest) to do the tests. While running jest with the command --coverage
realized that it is passing over lines of code that represent only interfaces, ex:
src/Presentation/protocols/controller.ts
import {IHttpRequest, IHttpResponse} from './http';
export interface IController {
handle(httpRequest: IHttpRequest): Promise<IHttpResponse>;
}
In Coverage he is searching for these files and saying that there is no coverage on the lines 1 to 5 but an interface is not a "testable" code so there really would be no coverage of it.
What I need to do so jest doesn’t cover interfaces or similar elements like enums and types?
What command are you running to run the tests? You can pass an argument with a regex. For example
jest '**/tests/**/*.test.ts'
will run tests that are found in files with extension.test.ts
and on their way have a foldertests
.– dfvc
The problem is not in the test file but coverage. There is no coverage to be made on an interface of this, it is not tractable code... It would be the same thing if I wanted to cover a comment
– LeandroLuk