Mocking Techniques in Vitest
Mocking Techniques in Vitest is a 48-lesson 1 hour 30 minutes self-paced course by Artem Zakharchenko. Let's admit it, mocking can be really confusing.
Course facts
- Lessons
- 48
- Duration
- 1 hour 30 minutes
- Level
- All levels
- Language
- English
- Updated
- Instructor
- Artem Zakharchenko
- Price
- Premium
What you will learn:
In this practical workshop, you will learn:
- The purpose of mocking;
- What and when to mock;
- How to write mocks that are beneficial rather than a maintenance burden;
- How to separate mocks from implementation details;
- How to ensure type safety in mocks;
- And all the mocking techniques you need to test your code!
By solving real-world tasks using the Vitest framework, you will gain a complete understanding of mocking and finally make it a useful tool in your testing arsenal.
Workshop Structure: The workshop consists of 6 blocks of exercises dedicated to different mocking techniques for various data types.
Boundaries
Understand what mocking really is and how it helps create test boundaries. Learn how each mock affects the code being tested with clear examples.
Mocking Functions
Functions are at the core of JavaScript logic. Learn to mock functions for effective testing of input and output data. Create mocks for functions, track their calls, and configure behavior in the code being tested.
Mocking Date and Time
Eliminate side effects of changing date and time in tests. Learn how to “freeze” time and mock time-dependent code to ensure stable test results.
Mocking Global Variables
Explore how to mock implicit dependencies without disruption. Learn to mock global values, methods, and environment variables, creating the perfect testing environment.
Mocking Network Requests
Gain control over network requests and reliably test client-side code. Intercept requests and mock responses using Mock Service Worker, simulating various network scenarios.
Mocking Modules
Understand when to use module mocking and explore alternative techniques. Learn to safely mock modules using Vitest's built-in APIs.
Who this workshop is for: This workshop is intended for all developers, both newcomers to automated testing and those who have been writing tests for years. If you are unsure when to introduce mocks into your test suite or how to do it without having to redo it the next day, this workshop is designed especially for you.
Additional
Who teaches Mocking Techniques in Vitest? Artem Zakharchenko
Artem Zakharchenko is a Ukrainian software engineer best known as the creator of Mock Service Worker (MSW) — the de-facto standard for API mocking in modern JavaScript test suites — and as a lead instructor on the EpicWeb.dev testing track alongside Kent C. Dodds.
His CourseFlix listing carries four Artem Zakharchenko courses: Testing Fundamentals (EpicWeb), Mocking Techniques in Vitest, Advanced Vitest Patterns, and React Component Testing with Vitest. Material is paid and aimed at JavaScript developers who want to make testing a first-class part of their workflow rather than an afterthought.
What lessons are included in Mocking Techniques in Vitest?
| # | Lesson Title | Duration | Access |
|---|---|---|---|
| 1 | Intro to Mocking Techniques in Vitest Demo | 02:48 | |
| 2 | Intro to Boundaries | 00:43 | |
| 3 | Test boundaries _Problem | 01:40 | |
| 4 | Test boundaries _solution | 02:27 | |
| 5 | Recap of Boundaries | 00:18 | |
| 6 | Intro to Functions | 00:42 | |
| 7 | Mock functions _Problem | 01:57 | |
| 8 | Mock functions _solution | 02:52 | |
| 9 | Spies _Problem | 00:54 | |
| 10 | Spies _solution | 02:22 | |
| 11 | Mock implementation _Problem | 01:32 | |
| 12 | Mock implementation _solution | 03:25 | |
| 13 | Recap of Functions | 00:22 | |
| 14 | Intro to Date and time _solution | 00:59 | |
| 15 | Date and time _Problem | 01:04 | |
| 16 | Date and time _solution | 02:15 | |
| 17 | Timers _Problem | 02:01 | |
| 18 | Timers _solution | 02:47 | |
| 19 | Ticks and tasks _Problem | 02:16 | |
| 20 | Ticks and tasks _solution | 02:15 | |
| 21 | Recap of Date and time | 00:19 | |
| 22 | Intro to Globals | 01:16 | |
| 23 | Global methods _Problem | 00:38 | |
| 24 | Global methods _solution | 02:20 | |
| 25 | Global values _Problem | 01:25 | |
| 26 | Global values _solution | 02:28 | |
| 27 | Environment variables _Problem | 01:22 | |
| 28 | Environment variables _solution | 03:49 | |
| 29 | Recap of Globals | 00:25 | |
| 30 | Intro to Network | 02:17 | |
| 31 | Set up MSW _Problem | 05:02 | |
| 32 | Set up MSW _solution | 01:28 | |
| 33 | Mock responses _Problem | 01:05 | |
| 34 | Mock responses _solution | 02:25 | |
| 35 | Error responses _Problem | 01:40 | |
| 36 | Error responses _solution | 02:59 | |
| 37 | Network errors _Problem | 00:59 | |
| 38 | Network errors _solution | 01:49 | |
| 39 | Response delay _Problem | 00:59 | |
| 40 | Response delay _solution | 02:30 | |
| 41 | Recap of Network | 00:41 | |
| 42 | Intro to Modules | 00:57 | |
| 43 | Dependency injection _Problem | 03:28 | |
| 44 | Dependency injection _solution | 03:45 | |
| 45 | Private side effects _Problem | 02:11 | |
| 46 | Private side effects _solution | 05:28 | |
| 47 | Recap of Modules | 00:31 | |
| 48 | Mocking Techniques in Vitest Outro | 00:41 |
Get instant access to all 47 lessons in this course, plus thousands of other premium courses. One subscription, unlimited knowledge.
Learn more about subscriptionWhat courses are similar to Mocking Techniques in Vitest?
-
Updated 2y agoGatling Fundamentals for Stress, Load & Performance Testing
By: UdemyIn this course, you will learn the fundamentals of using the Gatling stress testing tool - an extremely powerful, open-source performance testing tool in heavy4h 42m -
Updated 3y agoREST Assured Fundamentals
By: UdemyThis course on REST Assured assumes that you have some basic knowledge of Java and API testing, and cuts through all the filler of other courses to get you up a3h 22m -
Updated 2y agoTesting Fundamentals [EpicWeb]
By: Artem ZakharchenkoIn this workshop, Artem Zakharchenko, testing expert and creator of the Mock Service Worker API mocking library, will guide you through creating your own versio5h 16m -
FreeUpdated 2y agoWebservices API Testing with Rest Assured API & POSTMAN 2020
By: UdemyWebservices API Automation Testing using Rest Assured API and POSTMAN - Biggest course to cover all levels of API Testing using both Manual and Automation appro37h 51m -
NewHands-On Mocking With Mockito
By: Philip RiecksLearn how to efficiently create and configure mock objects with Mockito. Manage the behavior of your tests and control component interactions.2h 8m -
Updated 8mo agoAdvanced Vitest Patterns
By: Artem ZakharchenkoDo you know that feeling when a tool "clicks"? When you stop perceiving it merely as a means to an end and start using it as a true tool for creating better.1h 43m -
Updated 3y agoTesting JavaScript with Kent C. Dodds
By: Kent C. DoddsThis course will apply the four-layer testing method to a React application, but this foundational strategy can be applied across any JavaScript framework: Angu14h 11m
More courses by Artem Zakharchenko
-
Updated 8mo agoAdvanced Vitest Patterns
Do you know that feeling when a tool "clicks"? When you stop perceiving it merely as a means to an end and start using it as a true tool for creating better.1h 43m -
Updated 1y agoReact Component Testing with Vitest
The closer your tests mimic real-world application usage, the more confidence they provide.1h 38m -
Updated 2y agoTesting Fundamentals [EpicWeb]
In this workshop, Artem Zakharchenko, testing expert and creator of the Mock Service Worker API mocking library, will guide you through creating your own versio5h 16m