Level up your Mocking Techniques in Vitest

Get access to all lessons in this workshop.

Includes all 2 workshops:
Testing Fundamentals workshopMocking Techniques in Vitest workshop

Mocking Techniques in Vitest Bundle

Mocking Techniques in Vitest Bundle

Loading price
Mocking Techniques in Vitest Bundle
30-Day Money-Back Guarantee
Money Back Guarantee
includes
Workshops
  • Testing Fundamentals

  • Mocking Techniques in Vitest

Features
  • 2 Self-Paced Workshop

  • Lifetime Access

  • Customizable invoice

  • Streaming 4K Video

  • 52 Interactive Exercises

  • English Transcripts & Subtitles

  • Progress Tracking

  • Completion Certificate

Current section: Modules 4 exercises
lesson

Intro to Modules

This lesson is part of Mocking Techniques in Vitest and can be unlocked immediately after purchase. Already purchased? Log in here.

Transcript

00:00 Mocking a module should be your last resort, because it's the most intrusive technique out there. It's the highest place where you can draw the test boundary. Remember how we covered that mocking basically comes down to gaining control over values, or behaviors, or both.

00:16 But when you mock a module, you're not just gaining control, you're actually throwing away those two. And now suddenly you become in charge to make sure that that module you mocked functions correctly. In practice, mocking modules harms more than it helps, because it exposes your test to way much of implementation details of what you're mocking.

00:35 You need to make sure that the exports are now correct, that the internals are fine, and you're basically covering different things that may change when you upgrade a dependency, for example. That being said, there are legitimate use cases to do module mocking, and we're going to cover them in this exercise block. But before we do that, let's explore some of the alternative techniques you may use

00:54 before you resort to module mocking.