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.

No explanation for jest/no-restricted-matchers

See original GitHub issue

I can’t find any rationale for why these particular matchers are restricted.

d3a48e6a3fade2c8dba6b3adda395fec39365986

The jest/no-restricted-matchers rule can be configured to suggest an alternative to the restricted method. Please add some sort of explanation, even if there’s no alternative.

     {
        "jest/no-restricted-matchers": [
          "error",
          {
            "toMatchSnapshot": "Write a more targeted assertion instead of a snapshot",
            "toMatchInlineSnapshot": "Write a more targeted assertion instead of a snapshot",
            "toThrowErrorMatchingSnapshot": "Write a more targeted assertion instead of a snapshot",
            "toThrowErrorMatchingInlineSnapshot": "Write a more targeted assertion instead of a snapshot",

            "toBeTruthy": "use expect(x == true).toBeTrue() instead",
            "toBeFalsy":  "use expect(x == false).toBeTrue()  instead",
            "toBeDefined": "use .not.toBe(undefined)"
          }
        ]
      }

Or, preferably, remove these rules. Especially the toBeTruthy, toBeFalsy, and toBeDefined ones. IMHO the alternatives are much more error prone.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:1
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
pmcelhaneycommented, Mar 3, 2022

Okay, I’ll add some explanations and leave it at that.

I agree with you about snapshot testing. Didn’t even know the rule existed until I looked at the config. 😃

0reactions
EvgenyOrekhovcommented, Mar 18, 2022

Released in v24.4.0.

Read more comments on GitHub >

github_iconTop Results From Across the Web

eslint-plugin-jest/no-restricted-matchers.md at main - GitHub
This rule bans specific matchers & modifiers from being used, and can suggest alternatives. Options. Bans are expressed in the form of a...
Read more >
node_modules/eslint-plugin-jest/docs/rules/no-restricted-matchers ...
Disallow specific matchers & modifiers ( no-restricted-matchers ) ... This rule bans specific matchers & modifiers from being used, and can suggest alternatives....
Read more >
Untitled
Jest `version` setting The behaviour of some rules (specifically [`no-deprecated-functions`][]) change depending on the version of Jest being used.
Read more >
eslint-plugin-jest - npm
Start using eslint-plugin-jest in your project by running `npm i eslint-plugin-jest`. ... no-restricted-matchers, Disallow specific matchers & modifiers.
Read more >
eslint-plugin-jest | Yarn - Package Manager
no -mocks-import, Disallow manually importing from __mocks__, ✓ ; no-restricted-jest-methods, Disallow specific jest. methods ; no-restricted-matchers, Disallow ...
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