My answer elaborates on @JB_Nizet's.
You can't do test coverage for a report, but there are alternatives:
1. Put your interface in a separate file and specify to ignore it when creating a coverage report. For example, I use the istanbul library for the code test coverage report, and it provides for ignoring files. In order for the file to be ignored, it is enough to specify in it:
/* istanbul ignore file */
2. If it is important for you to monitor the compliance of your types and interfaces, you can write tests for them that will be performed during verification, but at the same time do not affect the coverage report. There are many options on the web for how to do this, but I like the way with assigning the tested interface to a variable the most.:
interface IResponse {
success: boolean;
message: string;
}
describe('IResponse interface', () => {
it('should have a boolean property named success', () => {
const response: IResponse = { success: true, message: 'Test message' };
expect(response.success).toBeDefined();
expect(typeof response.success).toBe('boolean');
});
it('should have a string property named message', () => {
const response: IResponse = { success: true, message: 'Test message' };
expect(response.message).toBeDefined();
expect(typeof response.message).toBe('string');
});
});
karma-typescript
? It may take in to account un-accessible code like that. npmjs.com/package/karma-typescript – Conferee