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.

Async test with Jasmine

Async test with Jasmine - Node.js Tutorial

From the course: Learning Node.js

Start my 1-month free trial

Async test with Jasmine

- [Instructor] So back in our server spec let's fix our calculator test and change it's to be to four. Now let's describe another set of tests. This time it'll be specific to get messages. So all the test part of this group will test various features of our get messages endpoint. So let's create our first test or specification. It should return 200 ok. So we expect that the status code of get messages will be 200 ok not 500 if there is a server error not 401 for not found, etc and then let's add a call back. So inside here we actually need to make an HTTP get request. Natively we can't do that so we'll have to use a library called request. So let's install that with npm install - - save - dev request and at the top let's require it in. Then we'll use request.get and we'll specify our URL and then a call back. The call back will contain an error and the response. For now we'll console log the response to make sure we're actually getting a response. At this point we'll have to start our…

Contents