Custom matchers with auto definition types
See original GitHub issueFor some custom needs, special matcher are needed.
expect from jest provides an extend method for doing that.
Jasmine is also able to do it.
There is something common between both solutions which Vitest can improve: generate the type definition automatically.
So being able to add our custom matchers, and then, get automatically the type globally either by a definition type file put in the source code or by a type put in cache somewhere in node_modules of Vitest which would be taken in order by typescript on test files.
Issue Analytics
- State:
- Created 2 years ago
- Comments:6 (6 by maintainers)
Top Results From Across the Web
Practical Guide to Custom Jest Matchers - Redd Developer
Custom matchers help you to encapsulate repetitive assertions. ... There are two types of matchers in Jest: symmetric and asymmetric.
Read more >Jasmine custom matcher type definition - Stack Overflow
I am trying to add typescript definition to a jasmine matcher library. I was able to add the matchers for the generic type...
Read more >Custom jest matchers to test the state of the DOM - GitHub
This allows you to check whether the given element has certain classes within its class attribute. You must provide at least one class,...
Read more >Matchers
beEqualTo is one of the many matchers defined by specs2 , it just checks ... The most common type of matcher is beEqualTo...
Read more >Define a custom matcher - RSpec Expectations - Relish
rspec-expectations provides a DSL for defining custom matchers. These are often useful for expressing expectations in the domain of your application.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

Yeah, I think it’s better to manage the extra types yourself (it’s not that long anyway). Automation on this could potentially be a footgun.
I think we might need to document which module and interface to extend. @sheremet-va do you mind checking how it would work on the user lang and maybe sending a PR to docs? Thanks
I think developers should do it themselves. The best we can do is provide documentation. Hope we can close the issue.