From the course: JavaScript: Test-Driven Development (ES6)

Unlock this course with a free trial

Join today to access over 25,500 courses taught by industry experts.

Solution: Testing "Not Found"

Solution: Testing "Not Found"

(upbeat music) - [Instructor] So I'm going to show you how I chose to solve this challenge. Keep in mind that this is just one possible way of doing so, and if your solution differs a little bit from mine, that definitely doesn't make it wrong. So I started off in the db.test.js file, and inside this empty test that we added, what I did was to set our database data, setDatabaseData users, and I inserted a single record into the database, which I'm just going to copy and paste here. And of course we have to await this function, since it's asynchronous. And then I said, "const actual equals await "getUserByUsername," and I passed a username that I knew wouldn't be in that database. So in this case, def And then for the assertion that we make, all we have to say is, "expect actual.to.be.null". And this just checks if our actual value is null. So if we save that and run our tests, we see that this already passes, and just…

Contents