Node.js: Testing and Code Quality
4h 22mIntermediate2021-06-07
Authors

Jon Peck
Software Architect, Engineer, Consultant, Trainer
Course details
Most software engineers would agree that clean code is easier to maintain than messy code, but what exactly does that look like, and how do go about cleaning up messy code? In this course, Jon Peck shows how to measure quality, implement testing, and measure code coverage in your Node.js apps, using a complete but buggy restaurant booking application to illustrate the concepts. Jon first reviews JavaScript fundamentals and testing and code quality concepts. He then explains how to use linters to find suspicious code; explores different testing frameworks and their components; and shows how to isolate your code for testing using test doubles, then verify with spies and mocks. Jon wraps up the course by showing how to generate reports on code health across your entire codebase. Along the way, he provides challenge and solution videos so you can test your knowledge of each section before moving on.
Skills covered
Node.jsJavaScript FrameworksJavaScriptOracleWeb DevelopmentOpen SourceDeep Dive (X:Y)
Concepts
0. Introduction
- 01 - Cleaning your codebase
- 02 - What you should know
- 03 - Preparing for Node.js development
- 04 - Exercise files
- 05 - Demo setup and tour
1. Testing and Code Quality Fundamentals
- 06 - What is code quality
- 07 - Coding conventions and standards
- 08 - Creating and enforcing coding standards
- 09 - Unit, integration, and functional testing
- 10 - Testing frameworks
- 11 - TDD and BDD test specifications
- 12 - Assertions for correctness
- 13 - Challenge - Organize your tests
- 14 - Solution - Organize your tests
2. Finding Errors with Linting
- 15 - Standardizing with EditorConfig
- 16 - Adding EditorConfig to a project and IDE
- 17 - Comparing JavaScript linters
- 18 - Installing ESLint
- 19 - Configuring ESLint
- 20 - Extending an ESLint shareable config
- 21 - Linting your codebase
- 22 - Fixing code in VSC with ESLint
- 23 - Challenge - Create a shareable ESLint config
- 24 - Solution - Create a shareable ESLint config
3. Validate Correctness with Unit Testing
- 25 - Survey of Node.js testing frameworks
- 26 - Install Jest in a Node.js project
- 27 - What and where to unit test
- 28 - Writing your first Jest unit test
- 29 - Running a test suite with Jest
- 30 - Testing asynchronous callbacks with Jest
- 31 - Writing callback test suites with Jest
- 32 - Testing promises with Jest
- 33 - Challenge - Test async await with Jest
- 34 - Solution - Test async await with Jest
4. Replacing and Inspecting Using Spies, Stubs, and Mocks
- 35 - Replacing code with test doubles
- 36 - Mocking functions for test code
- 37 - Writing your first Jest mock
- 38 - Mock an entire module with Jest
- 39 - Mocking module dependencies
- 40 - Spying to observe interactions
- 41 - Challenge - Mock a successful reservation creation
- 42 - Solution - Mock a successful reservation creation
5. Reporting on Your Entire Codebase
- 43 - Why code coverage matters
- 44 - Measuring code coverage with Jest
- 45 - Functional testing with Jest
- 46 - Test doubles and Express apps
- 47 - Form submissions with SuperTest
- 48 - Fallacies of 100 test coverage
- 49 - Coverage with continuous integration
- 50 - Challenge - Isolate routes for faster tests
- 51 - Solution - Isolate routes for faster tests
Conclusion
- 52 - Testing and code quality goals
- 53 - Where to go from here
Related courses
- Learning Selenium with Node.js
- Node.js: Web Servers, Tests, and Deployment
- Nest.js Developer Lab 2026: Build a Robust API with Authentication, Articles, and User Profiles
- Google Cloud Build: Test, Deploy, and Manage Code
- AWS for Developers: RDS MySQL Database with Lambdas
- Learning End-to-End Testing with Jest
- Learning to Build Alexa Skills
- Building Serverless Apps on AWS