From the course: Learning Node.js

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Introduction to test first development

Introduction to test first development - Node.js Tutorial

From the course: Learning Node.js

Start my 1-month free trial

Introduction to test first development

- [Narrator] In this video, we'll add a new feature using test-driven development. So we'll add a test first, we'll make it fail and then we'll implement the feature to make the test pass. The new feature we'll add is a new messages get call, or endpoint that will allow us to get the messages from a specific owner, by checking the name. And we'll get that name through a URL parameter. So let's begin by creating a test. We'll start running new describe. And these tests will revolve around getting messages from a specific user. The first test will be the standard, it should return a 200 okay, so I'll just copy this from above from line 10 through line 15 and paste it in our new describe. Next, I'll need to supply a user name at the end of the Url and I'll just use Tim. Let's save that and give it a try. We'll use npm test. We can see there were four specs that were run and one that failed. Our get messages from user should return 200 okay and we got a 404, not found that we expected, to…

Contents