source: frontend/node_modules/eslint-plugin-jest/docs/rules/no-alias-methods.md

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

Fix frontend appearance

  • Property mode set to 100644
File size: 1.3 KB
Line 
1# Disallow alias methods (`no-alias-methods`)
2
3Several Jest methods have alias names, such as `toThrow` having the alias of
4`toThrowError`. This rule ensures that only the canonical name as used in the
5Jest documentation is used in the code. This makes it easier to search for all
6occurrences of the method within code, and it ensures consistency among the
7method names used.
8
9## Rule details
10
11This rule triggers a warning if the alias name, rather than the canonical name,
12of a method is used.
13
14### Default configuration
15
16The following patterns are considered warnings:
17
18```js
19expect(a).toBeCalled();
20expect(a).toBeCalledTimes();
21expect(a).toBeCalledWith();
22expect(a).lastCalledWith();
23expect(a).nthCalledWith();
24expect(a).toReturn();
25expect(a).toReturnTimes();
26expect(a).toReturnWith();
27expect(a).lastReturnedWith();
28expect(a).nthReturnedWith();
29expect(a).toThrowError();
30```
31
32The following patterns are not considered warnings:
33
34```js
35expect(a).toHaveBeenCalled();
36expect(a).toHaveBeenCalledTimes();
37expect(a).toHaveBeenCalledWith();
38expect(a).toHaveBeenLastCalledWith();
39expect(a).toHaveBeenNthCalledWith();
40expect(a).toHaveReturned();
41expect(a).toHaveReturnedTimes();
42expect(a).toHaveReturnedWith();
43expect(a).toHaveLastReturnedWith();
44expect(a).toHaveNthReturnedWith();
45expect(a).toThrow();
46```
Note: See TracBrowser for help on using the repository browser.