In this video, write tests for the dictionary routes in your application. Use the Express router and write tests to ensure that the routes are working correctly. Whenever you write unit tests, you are testing each isolated module of the code. Test the dictionary route module only without affecting other routes.
So we'll say cost, request equal require, … close this screen here, … that we can use with our app, … just go ahead and look for the /dictionary route. … So, we'll do a get request of /dictionary, … and then we're able to get the response. … is that when we make this request … this is going to take some time. … There's going to be some latency. … There's asynchronous code here. … So we're going to make this … callback function an async callback, … meaning that we can ask lines of code … that are going to take time, … like this request app get call, to wait. … And we tell things to wait by putting await in front of it. … So if this function returns a promise, which it does, … means we can wait for this promise to resolve. … So I'm going to go ahead and say const body, … and we'll pull the body out of that response, … equals await app get dictionary. … Great. … So this is actually the response body … from the dictionary request, … and we're just going to expect it … to equal an empty object right now. …
- Making HTTP requests
- Building web and file servers
- Installing packages with npm
- Managing and linking global packages
- Working with Express, the web server framework
- Handling POST and DELETE requests
- Creating WebSockets
- Testing and debugging Node.js code
Skill Level Advanced
Node.js: Real-Time Web with Socket.IOwith Emmanuel Henri1h 24m Intermediate
Work with VSCode1m 59s
1. The HTTP Module
3. Web Servers
5. Node.js Testing
6. Automation and Deployment
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.