Testing is one of the most complicated things as a developer. Today, we’re going to make that easy.
In this session, you’ll learn how to test, when to test, how to write tests. And you’ll learn be able to test your application in a way that make sense — and not use TDD (and other non-working, time-consuming methods).
Note
We went a bit too fast when we covered how to test middlewares in this lesson. If you feel don’t get it, don’t worry. Watch the next lesson because we’ll slow down and explain everything step by step.
Source Code
Here’s a link to the Github Repository.
Timestamps
- 00:00 Introduction of Testing Frameworks
- 01:00 Installing Vitest
- 02:00 Running Vitest
- 03:30 Understanding how Vitest works
- 04:00 Writing the first test file
- 05:30 Creating a npm script for easier testing
- 06.30 Understanding
expectandtoBe - 09:00 Thoughts on TDD
- 10:46 Figuring out what to test for
- 13:45 Setting up database for testing
- 17:22 Testing the createUser function
- 18:51 Debugging an error
- 21:20 Figuring out what to test for in createUser
- 24:00 Checking whether the user is populated into the Database
- 28:45 Fixing an error in our createUser code
- 34:00 Testing the login function
- 38:00 Using Describe to create test a group of functionality
- 39:00 Naming tests
- 40:00 Testing for errors
- 44:00 Checklist mindset for testing
- 46:00 Summary of what to test
- 49:00 Testing middlewares
- 53:00 Building requests, response, and next functions for testing
- 54:35 Understanding Mocks
- 55:15 Resetting mocks
- 56:55 Building a user for testing
- 59:10 Testing a duplicated user
- 1:01:09 Fixing another bug in the createUser function
- 1:09:11 Recap what the bug was about
- 1:10:01 Testing for a second user
- 1:11:15 Using Faker to generate fake data for testing
- 1:15:18 Questions and Answers
Welcome! Unfortunately, you don’t have access to this lesson. To get access, please purchase the workshop or enroll in Magical Dev School.
Unlock this lesson