There's a @VisibleForTesting annotation available in Java through the Google Guava library to indicate that the visibility of a type or member has been relaxed to make the code testable: annotation to make a private method public only for test classes . Subsequently there are also plugins which ensure that the methods which are annotated with @VisibleForTesting are actually being used only in the test classes.
I currently have a typescript interface where I have to add some methods to the interface just for testing purposes. For example:
interface ProcessorInterface {
process(data: Readonly<Data>): Promise<Result>;
// these 2 methods are only added here so that they are
// callable from the implementation while writing tests.
processBatch(data: Readonly<Data>): Promise<Result>;
validate(data: Readonly<Data>): Promise<Error[]>;
}
I was wondering if there is a standard way in Typescript to indicate the same.
Any help would be appreciated. Thanks.
Aucun commentaire:
Enregistrer un commentaire