I've seen this error being solved in primitive types but I am not sure how I would solve it in this example
const newUser: UserEntity = {
user_id: 'f3bea6de-fb24-4441-b75b-d7642ca573d7',
name: 'Test User',
};
jest.spyOn(repo, 'create').mockResolvedValueOnce([newUser]); // error here on [newUser] - 'UserEntity' is not assignable to type 'never'
user.entity.ts
@Entity('users')
export class UserEntity {
@PrimaryGeneratedColumn('uuid') user_id: string;
@Column('text') name: string;
}
repo.create is a synchronous function, but mockResolvedValue is for asynchronous functions that return promises. Instead, use mockReturnValueOnce and you'll have no problems.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With