相关疑难解决方法(0)

How to test custom Repository in Nestjs/TypeORM applications

I am trying to add more testing codes to improve the quality of my sample codes.

Currently, I have a problem when testing UserRepository (not mock UserRepository), there are some custom methods I added in my custom UserRepository like this.

@EntityRepository(UserEntity)
export class UserRepository extends Repository<UserEntity> {
  findByEmail(email: string): Promise<UserEntity> {
    return this.findOne({ email: email });
  }
}
Run Code Online (Sandbox Code Playgroud)

So I want to verify the findOne is called from the parent Repository.

I tried to add the following …

typeorm nestjs

6
推荐指数
1
解决办法
5022
查看次数

标签 统计

nestjs ×1

typeorm ×1