Skip to content

Conversation

@oiagorodrigues
Copy link
Contributor

@oiagorodrigues oiagorodrigues commented Aug 28, 2025

Update the custom matchers augmentation with the new Vitest interface 3.2 called Matchers that adds type inference and runtime logic for the custom matchers. Previously, we needed to extend the Assertion and MatchersDeclaration (or AsymmetricMatchersContaining).

- `Assertion<T>`, which controls the matchers returned by calling `expect()`;
- `MatchersDeclaration`, which annotates the matcher declarations passed to `expect.extend()`.

<callout-info>Since Vitest 3.2, you can extend the `Matchers` interface to have type-safe assertions in `expect.extend`, `expect().*` and `expect.*` methods at the same time.</callout-info>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The exercise text was written before Vitest 3.2 was released. Let's update the text to reflect the proper way of extending the matchers.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense. It would require multiple changes, as other exercises are still referencing the old vitest version.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will go through the remaining mentions of this pattern throughout the workshop and fix them!

Copy link
Member

@kettanaito kettanaito left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for pointing this out and helping me fix the issue, @oiagorodrigues! 🚀

@kettanaito kettanaito merged commit 3a761ae into epicweb-dev:main Aug 28, 2025
2 of 4 checks passed
@oiagorodrigues oiagorodrigues deleted the patch-1 branch August 28, 2025 20:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants