question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Custom matchers with auto definition types

See original GitHub issue

For 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:closed
  • Created 2 years ago
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

2reactions
antfucommented, Dec 13, 2021

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

0reactions
sheremet-vacommented, Jan 5, 2022

I think developers should do it themselves. The best we can do is provide documentation. Hope we can close the issue.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found