JavaScript Testing Basics
Write unit tests for JavaScript with Vitest: assertions, mocks and test-driven fixes.
What you'll learn
- Write tests with describe, it and expect
- Test async functions and errors
- Mock modules and timers
- Measure coverage and read the report
About this course
You add tests to a small utility library and a DOM widget. You learn test structure, matchers, mocks and how to test async code. The project is a tested library you can reuse.
Course curriculum
4 modules and 12 lessons over 4 weeks. Plan for about 12 learning hours.
01First testsWeek 1 · 3 lessons
- Installing Vitest
- Assertions
- Test structure
02Harder casesWeek 2 · 3 lessons
- Async code
- Errors
- Parameterized tests
03MocksWeek 3 · 3 lessons
- Mock functions
- Module mocks
- Fake timers
04Tested libraryWeek 4 · 3 lessons
- Testing utilities
- Testing a DOM widget
- Coverage report
Project
Tested utility library. A small JavaScript utility library with unit tests and a coverage report.
Who this course is for
JavaScript learners who have never written tests.
Prerequisites
You write JavaScript functions and modules.
What's included
- 180-day course access
- Project brief
- Starter repository
- Coding labs
- Reference solutions
- One written project review
- A digital completion certificate
Learning format
Project-based online course, part of our guided project courses. One written project review.
Access and delivery
- Course access is delivered within 15 minutes after payment.
- Written project review is returned within 2 business days of submission.
- Completion materials are issued within 2 business days after the project is approved.
Certificate
You receive a digital completion certificate. Completion materials are issued within 2 business days after the project is approved.
Frequently asked questions
When does access start?
Course access is delivered within 15 minutes after payment.
Is payment taken on this website?
No. After you submit your enrollment request, we reply by email with payment details and enrollment confirmation.
Does this course guarantee a job or income?
No. It is an education and training service and does not include employment, income or placement guarantees.
Can I cancel?
Our Refund and Cancellation Policy lists the terms for project-based programs.