|
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 |
|
|---|
| 3 | This rule bans specific matchers & modifiers from being used, and can suggest
|
|---|
| 4 | alternatives.
|
|---|
| 5 |
|
|---|
| 6 | ## Rule Details
|
|---|
| 7 |
|
|---|
| 8 | Bans are expressed in the form of a map, with the value being either a string
|
|---|
| 9 | message to be shown, or `null` if the default rule message should be used.
|
|---|
| 10 |
|
|---|
| 11 | Both matchers, modifiers, and chains of the two are checked, allowing for
|
|---|
| 12 | specific variations of a matcher to be banned if desired.
|
|---|
| 13 |
|
|---|
| 14 | By default, this map is empty, meaning no matchers or modifiers are banned.
|
|---|
| 15 |
|
|---|
| 16 | For 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 |
|
|---|
| 31 | Examples of **incorrect** code for this rule with the above configuration
|
|---|
| 32 |
|
|---|
| 33 | ```js
|
|---|
| 34 | it('is false', () => {
|
|---|
| 35 | expect(a).toBeFalsy();
|
|---|
| 36 | });
|
|---|
| 37 |
|
|---|
| 38 | it('resolves', async () => {
|
|---|
| 39 | await expect(myPromise()).resolves.toBe(true);
|
|---|
| 40 | });
|
|---|
| 41 |
|
|---|
| 42 | describe('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.