Skip to content

Commit ccc8401

Browse files
committed
add workshop intro
1 parent d411c75 commit ccc8401

File tree

1 file changed

+61
-1
lines changed

1 file changed

+61
-1
lines changed

exercises/README.mdx

Lines changed: 61 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,63 @@
11
# Advanced Vitest Patterns
22

3-
Hi! Welcome to the Advanced Vitest Patterns workshop! :wave:
3+
Hey! :wave:
4+
5+
Do you know this feeling when a tool “clicks”? When you suddenly become so comfortable with it that it’s no longer just a means to an end but an instrument to craft better experiences for yourself. Over the past decade, that transition has happened with a bunch of tools for me.
6+
7+
Today, I want it to happen for you with Vitest.
8+
9+
In this workshop, my goal is to make you a Vitest superuser. And that means stepping beyond the basics and into the advanced. That means getting so good at Vitest that you would feel confident crafting custom test experiences, understanding the inner works of your test runner, and equipping that knowledge to solve everything from complexity issues to poor test performance.
10+
11+
Welcome to the Advanced Vitest Patterns workshop!
12+
13+
## Exercises
14+
15+
All the material in this workshop is grouped into four exercise blocks.
16+
17+
### Setup
18+
19+
In the first block you are going to learn how to be more productive with Vitest. You will install and explore the _Vitest extension for Visual Studio Code_ and how it can help you write and debug tests more efficiently.
20+
21+
Then, you will learn the difference between _test and code coverage_ so you could configure and visually explore code coverage using the UI mode in Vitest.
22+
23+
And, finally, you will explore how to utilize your test runner to test different code with different requirements by introducing _multiple test projects_.
24+
25+
### Context
26+
27+
The "Context" block marks the beginning of your customization journey. In this one, you will _create your own fixtures_ to offload complexity from your test cases to where it belongs—in the test setup. We will cover the _best practices and common mistakes of fixture design_ so you don't accidentally introduce more complexity while trying to eliminate it.
28+
29+
### Assertions
30+
31+
An assertion is the most important part of any test. Naturally, this exercise block is focused on crafting perfect assertions.
32+
33+
And you will start by writing your _custom matchers_, like `.toMatchSchema()`, learn how to make them type-safe and also explore the practical application of _asymmetric matchers_. Everything to help you be more descriptive in tests.
34+
35+
You will teach Vitest how to compare values that are the same semantically but differ structurally by extending the default `.toEqual()` matcher with _custom equality testers_.
36+
37+
After that, you will explore techniques to get the most out of your assertions. I'm talking about using _soft assertions_ to make test failures more informative and also _retryable assertions_, which is a great and concise way to assert on asynchronous code.
38+
39+
### Performance
40+
41+
Last but not least, **performance**.
42+
43+
In this block, you will _profile a slow test run_ by yourself, using built-in metrics in Vitest in combination with third-party tools. You will see how your tests consume CPU and RAM, and what consumption tells you.
44+
45+
We cannot talk about performance without understanding how Vitest works under the hood. You will take a peek at how Vitest orchestrates your tests, what defaults it has, and how you can customize those defaults to get faster test runs.
46+
47+
Your optimization strategy will be split into three levels:
48+
49+
1. Optimizing test cases;
50+
1. Optimizing test files;
51+
1. Optimizing the test process.
52+
53+
You will learn the difference between _parallel and concurrent tests_ and switch on concurrency to make your test cases faster.
54+
55+
Next, you will disable test isolation in Vitest and see what effect it has on your tests' performance.
56+
57+
And, lastly, you will learn how to tackle _really large test suites_ by splitting them into _multiple shards_ and running them in parallel on CI, using GitHub Actions as an example.
58+
59+
## Going through the workshop
60+
61+
As with every Epic Web workshop, this one is a hands-on experience where you will be working through exercises by yourself and then discussing the solution together with me.
62+
63+
Savour this moment because by the end of this workshop you will become a Vitest superuser. Excited? Let's go!

0 commit comments

Comments
 (0)