With testing, mocks are similar to a stunt double on a movie. They are fake pieces of data that stand in for the real thing. In this video, learn to set up mocking with Jest.
Unfortunately, the scenario in front of us, … isn't one in which we write the test first, … because we've already written the code. … This testing scenario is the most commone scenario … for developers. … So we want to test some already existing code. … So the first, most important step … that we took to do that was isolate code … into separate modules. … So the first module we're going to test … is this index.js. … Now this file really has one purpose, … and it's to start our app. … So in order to test this module and make sure it works, … we need to make sure that our call to app.listen works. … So I'm going to go ahead and go into my index.test, … because we don't actually need that function. … I'll even get rid of the it test for that. … And I'm going to call this suite .index.js app entry, … So we'll just write it should call app.listen. … So then we want to make sure it does, so how do we do that? … Well the first thing is we need … which is just a Java script file. … Now if I look at the index.js, …
- 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.