Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Define matchers on InverseAsymmetricMatchers for expect.not #385

Closed
dharkness opened this issue Nov 13, 2021 · 0 comments
Closed

Define matchers on InverseAsymmetricMatchers for expect.not #385

dharkness opened this issue Nov 13, 2021 · 0 comments

Comments

@dharkness
Copy link
Contributor

dharkness commented Nov 13, 2021

The matchers are not visible in auto-completion when used with expect.not. They work, but WebStorm reports them as a problem.

const value = {
  name: 'foobar',
};
expect(value).toEqual({
  name: expect.not.toStartWith('bar')
                   ^^^^^^^^^^^
                   Unresolved function or method
});

The simplest way to expose them is by declaring the asymmetric forms in a new interface, AsymmetricMatchers, and having both Expect and InverseAsymmetricMatchers extend it. However, this may cause issues with TypeScript projects. In that case, I think we'd have to declare the matchers a third time.

Here's how I do it for my own custom matchers:

interface AsymmetricMatchers {
  ... custom matchers ...
}

interface Expect extends AsymmetricMatchers {}
interface InverseAsymmetricMatchers extends AsymmetricMatchers {}
dharkness pushed a commit to dharkness/jest-extended that referenced this issue Nov 13, 2021
keeganwitt pushed a commit to dharkness/jest-extended that referenced this issue Jul 19, 2022
keeganwitt pushed a commit to dharkness/jest-extended that referenced this issue Jul 19, 2022
keeganwitt pushed a commit that referenced this issue Jul 19, 2022
Co-authored-by: David Harkness <david.harkness@realogy.com>
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

No branches or pull requests

2 participants