Loading
Current section: Setup 5 exercises
Problem

Multiple Workspaces

Configure Vitest with multiple workspaces to separate unit tests and edge tests, each running in the right environment.

Loading exercise

Transcript

00:00 VTest is a versatile test runner, and you can use it for many things. You can have your unit tests running in VTest, also your integration tests. We've explored how to run your React component tests in the actual browser, straight from VTest using its browser mode feature, and so on. And all of those different use cases have different requirements.

00:18 Your unit test environment might be Node.js, but once you're running your React tests, they will run in the actual browser. Your integration tests may require a different environment as well. So basically, it means you need to approach all of those use cases differently. And VTest helps you do that through the feature called workspaces, or projects.

00:35 In this exercise, you will explore that feature, because the app you have to test has two layers of tests, unit tests, but also integration tests for the edge functions that live in your app. And those edge functions need a special environment to run reliably. So follow the instructions, define two different workspaces for unit tests and for the edge

00:53 integration tests, with their own requirements, and then complete the test cases to have them passing.