source: frontend/node_modules/eslint-plugin-jest/docs/rules/no-restricted-matchers.md

Last change on this file was 9af201e, checked in by MBK <marija.karapandzova@…>, 13 days ago

Fix frontend appearance

  • Property mode set to 100644
File size: 1.1 KB
Line 
1# Disallow specific matchers & modifiers (`no-restricted-matchers`)
2
3This rule bans specific matchers & modifiers from being used, and can suggest
4alternatives.
5
6## Rule Details
7
8Bans are expressed in the form of a map, with the value being either a string
9message to be shown, or `null` if the default rule message should be used.
10
11Both matchers, modifiers, and chains of the two are checked, allowing for
12specific variations of a matcher to be banned if desired.
13
14By default, this map is empty, meaning no matchers or modifiers are banned.
15
16For example:
17
18```json
19{
20 "jest/no-restricted-matchers": [
21 "error",
22 {
23 "toBeFalsy": null,
24 "resolves": "Use `expect(await promise)` instead.",
25 "not.toHaveBeenCalledWith": null
26 }
27 ]
28}
29```
30
31Examples of **incorrect** code for this rule with the above configuration
32
33```js
34it('is false', () => {
35 expect(a).toBeFalsy();
36});
37
38it('resolves', async () => {
39 await expect(myPromise()).resolves.toBe(true);
40});
41
42describe('when an error happens', () => {
43 it('does not upload the file', async () => {
44 expect(uploadFileMock).not.toHaveBeenCalledWith('file.name');
45 });
46});
47```
Note: See TracBrowser for help on using the repository browser.