Learn how to measure quality, implement testing, and ensure code coverage in your node.js apps.
Overview
Syllabus
Introduction
- Cleaning your codebase
- What you should know
- Preparing for Node.js development
- Exercise files
- Demo setup and tour
- What is code quality?
- Coding conventions and standards
- Creating and enforcing coding standards
- Unit, integration, and functional testing
- Testing frameworks
- TDD and BDD test specifications
- Assertions for correctness
- Challenge: Organize your tests
- Solution: Organize your tests
- Standardizing with EditorConfig
- Adding EditorConfig to a project and IDE
- Comparing JavaScript linters
- Installing ESLint
- Configuring ESLint
- Extending an ESLint shareable config
- Linting your codebase
- Fixing code in VSC with ESLint
- Challenge: Create a shareable ESLint config
- Solution: Create a shareable ESLint config
- Survey of Node.js testing frameworks
- Install Jest in a Node.js project
- What and where to unit test?
- Writing your first Jest unit test
- Running a test suite with Jest
- Testing asynchronous callbacks with Jest
- Writing callback test suites with Jest
- Testing promises with Jest
- Challenge: Test async/await with Jest
- Solution: Test async/await with Jest
- Replacing code with test doubles
- Mocking functions for test code
- Writing your first Jest mock
- Mock an entire module with Jest
- Mocking module dependencies
- Spying to observe interactions
- Challenge: Mock a successful reservation creation
- Solution: Mock a successful reservation creation
- Why code coverage matters
- Measuring code coverage with Jest
- Functional testing with Jest
- Test doubles and Express apps
- Form submissions with SuperTest
- Fallacies of 100% test coverage
- Coverage with continuous integration
- Challenge: Isolate routes for faster tests
- Solution: Isolate routes for faster tests
- Testing and code quality goals
- Where to go from here?
Taught by
Jon Peck