Use Chai HTTP to test an Express application, including replacing the Morgan middleware logger with a Sinon stub and using a global proxyquire configuration to override all requires.
- [Instructor] Let's write some functional tests…using an express app.…There are a lot of steps in this, but if you'd like to take…a look at the reference, or just copy over the file,…it can be found in the exercise files.…When you're ready, switch over to Adam.…Right click on the test directory and click new file.…For the path, specify test functional…reservations dot js.…We'll start with the requires like chai.…So const chai equals require chai.…
We're going to require a new module chai http as well.…Const chai http equals…require chai dash http.…Similar to unit tests, we're going to…use proxyquire and signon.…So const proxyquire equals require proxyquire.…Const signon equals require signon.…Now for something completely different.…App dot js uses morgan for a logger, so we're going to…want to silence it.…
We're going to set the constant logger to morgan, which is…the same as Adam dot js.…So const logger equals require morgan.…That's it for the requires, let's configure chai to use…the new plugin.…Chai dot use chai http…
- What is code quality?
- Testing and code quality fundamentals
- Coding conventions and standards
- Creating and enforcing coding standards
- Unit, integration, and functional testing
- Test-driven development test specificatons
- Behavior-driven development test specifications
- Finding errors with linting
- Extending an ESLint shareable config
- Validating correctness with unit testing
- Replacing and inspecting with stubs, spies, and mocks
- Code coverage and why it matters
- Coverage with continuous integration
Skill Level Intermediate
1. Testing and Code Quality Fundamentals
2. Finding Errors with Linting
3. Validating Correctness with Unit Testing
4. Replacing and Inspecting with Stubs, Spies, and Mocks
5. Reporting on Your Entire Codebase
Where to go from here?3m 46s
- 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.