ts-jest: Cannot create mock of a class which has private dependencies in constructor
vc-bhanudatsinh opened this issue · comments
Error: Argument of type 'typeof PermissionGuard' is not assignable to parameter of type 'PartialFuncReturn<{ prototype: { readonly reflector: ...; readonly rolePermissionService: ...; canActivate: ...; }; }>'.
Types of property 'prototype' are incompatible.
Type 'PermissionGuard' is not assignable to type 'DeepPartial<{ readonly reflector: Reflector; readonly rolePermissionService: RolePermissionService; canActivate: (context: ExecutionContext) => Promise<...>; }>'.
Property 'reflector' is private in type 'PermissionGuard' but not in type 'DeepPartial<{ readonly reflector: Reflector; readonly rolePermissionService: RolePermissionService; canActivate: (context: ExecutionContext) => Promise<...>; }>'
@Injectable()
export class PermissionGuard implements CanActivate {
constructor(
private readonly reflector: Reflector,
private readonly rolePermissionService: RolePermissionService
) {}
}