I'm fairly new to jest testing and thought I'd write a simple test for one of my controls that simply sends an array of user objects, or a simple string statement if the array is empty. So this test should just pass the text "No users found".
Here is the simple test I wrote:
test('Should return a string statment *No users found*', () => {
expect(getAllUsers().toBe('No users found'));
});
Not sure what I'm doing wrong here...
Here is the error I'm getting:
TypeError: Cannot read properties of undefined (reading 'send')
6 |
7 | export const getAllUsers = (req, res) => {
> 8 | if(users.length === 0) res.send('No users found');
| ^
9 | res.send(users);
10 | };
11 |