File tree Expand file tree Collapse file tree 3 files changed +12
-10
lines changed
Expand file tree Collapse file tree 3 files changed +12
-10
lines changed Original file line number Diff line number Diff line change @@ -360,7 +360,7 @@ Manually fixable by
360360| [ padding-around-describe-blocks] ( docs/rules/padding-around-describe-blocks.md ) | Enforce padding around ` describe ` blocks | | | 🔧 | |
361361| [ padding-around-expect-groups] ( docs/rules/padding-around-expect-groups.md ) | Enforce padding around ` expect ` groups | | | 🔧 | |
362362| [ padding-around-test-blocks] ( docs/rules/padding-around-test-blocks.md ) | Enforce padding around ` test ` and ` it ` blocks | | | 🔧 | |
363- | [ prefer-called-with] ( docs/rules/prefer-called-with.md ) | Suggest using ` toBeCalledWith ()` or ` toHaveBeenCalledWith() ` | | | | |
363+ | [ prefer-called-with] ( docs/rules/prefer-called-with.md ) | Suggest using ` toHaveBeenCalledWith ()` | | | | |
364364| [ prefer-comparison-matcher] ( docs/rules/prefer-comparison-matcher.md ) | Suggest using the built-in comparison matchers | | | 🔧 | |
365365| [ prefer-each] ( docs/rules/prefer-each.md ) | Prefer using ` .each ` rather than manual loops | | | | |
366366| [ prefer-ending-with-an-expect] ( docs/rules/prefer-ending-with-an-expect.md ) | Prefer having the last statement in a test be an assertion | | | | |
Original file line number Diff line number Diff line change 1- # Suggest using ` toBeCalledWith() ` or ` toHaveBeenCalledWith() ` (` prefer-called-with ` )
1+ # Suggest using ` toHaveBeenCalledWith() ` (` prefer-called-with ` )
22
33<!-- end auto-generated rule header -->
44
5- The ` toBeCalled ()` matcher is used to assert that a mock function has been
5+ The ` toHaveBeenCalled ()` matcher is used to assert that a mock function has been
66called one or more times, without checking the arguments passed. The assertion
7- is stronger when arguments are also validated using the ` toBeCalledWith ()`
7+ is stronger when arguments are also validated using the ` toHaveBeenCalledWith ()`
88matcher. When some arguments are difficult to check, using generic match like
99` expect.anything() ` at least enforces number and position of arguments.
1010
@@ -24,11 +24,14 @@ expect(someFunction).toHaveBeenCalled();
2424The following patterns are not warnings:
2525
2626``` js
27- expect (noArgsFunction).toBeCalledWith ();
27+ expect (noArgsFunction).toHaveBeenCalledWith ();
2828
29- expect (roughArgsFunction).toBeCalledWith (expect .anything (), expect .any (Date ));
29+ expect (roughArgsFunction).toHaveBeenCalledWith (
30+ expect .anything (),
31+ expect .any (Date ),
32+ );
3033
31- expect (anyArgsFunction).toBeCalledTimes (1 );
34+ expect (anyArgsFunction).toHaveBeenCalledTimes (1 );
3235
33- expect (uncalledFunction).not .toBeCalled ();
36+ expect (uncalledFunction).not .toHaveBeenCalled ();
3437```
Original file line number Diff line number Diff line change @@ -4,8 +4,7 @@ export default createRule({
44 name : __filename ,
55 meta : {
66 docs : {
7- description :
8- 'Suggest using `toBeCalledWith()` or `toHaveBeenCalledWith()`' ,
7+ description : 'Suggest using `toHaveBeenCalledWith()`' ,
98 } ,
109 messages : {
1110 preferCalledWith : 'Prefer {{ matcherName }}With(/* expected args */)' ,
You can’t perform that action at this time.
0 commit comments