golevelup / nestjs

A collection of badass modules and utilities to help you level up your NestJS applications 🚀

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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
 ) {}
 }

image