Test case – should not find user

In this case, we're going to follow a very similar format as in case of should find user, creating the userId variable and setting it equal to a user ID that does not exist inside of our built-in users; something like 99 would get the job done:

it('should not find user', () => {  var userId = '99';});

Next up, we'll be making a user variable, once again to store the return result from getUser, users.getUser, passing in our userId:

it('should not find user', () => {  var userId = '99';  var user = users.getUser(userId);});

Now in this case, we would expect that undefined comes back, filter should return nothing and if you try to fetch the first item in an empty array, you're going to get undefined. We can prove ...

Get Advanced Node.js Development now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.