I have a NestJS App that has GET routes. One of them, for instance, is the FindAll() which simply gets all the users from Prisma. The FindAll() method looks like this:
findAll(): Promise<Users[]> {
return prisma.users.findMany();
}
And in my service.spec.ts I have this:
const usersMany = [
{
username: 'user1',
name: 'User One',
password: '123',
email: 'user1@test.com',
tasks: [],
},
{
username: 'user2',
name: 'User Two',
password: '456',
email: 'user2@test.com',
tasks: [],
},
]
describe('findAll', () => {
it('should return all users', async () => {
const usersAll = service.findAll();
expect(usersAll).resolves.toEqual(usersMany);
});
});
How would I go about running this test case if I am also encrypting the passwords using bcrypt? In a running application, this would result in me getting all the users currently made with their passwords hashed instead of plain string.