Commit 2b1841c
Enable
## Explanation
<!--
Thanks for your contribution! Take a moment to answer these questions so
that reviewers have the information they need to properly understand
your changes:
* What is the current state of things and why does it need to change?
* What is the solution your changes offer and how does it work?
* Are there any changes whose purpose might not obvious to those
unfamiliar with the domain?
* If your primary goal was to update one package but you found you had
to update another one along the way, why did you do so?
* If you had to upgrade a dependency, why did you do so?
-->
Jest has a configuration option `resetMocks`. Equivalent to calling
`jest.resetAllMocks()` before each test, it helps to ensure that tests
are run in isolation by removing fake implementations for each
registered mock function, thereby resetting its state.
This option is enabled by default for new Jest projects but has been
disabled in this repo for a very long time. For some test suites,
`jest.resetAllMocks()` (or some variant) has been added to a
`beforeEach` or `afterEach` to simulate this option, but overall this is
not the case, and some tests were written which assumed that mock
functions were not being reset between tests.
This commit enables the aforementioned configuration option, fixes tests
that fail as a result of this, and removes manual calls to
`jest.resetAllMocks()` (or the like).
## References
<!--
Are there any issues that this pull request is tied to? Are there other
links that reviewers should consult to understand these changes better?
For example:
* Fixes #12345
* Related to #67890
-->
Fixes #745.
## Changelog
<!--
If you're making any consumer-facing changes, list those changes here as
if you were updating a changelog, using the template below as a guide.
(CATEGORY is one of BREAKING, ADDED, CHANGED, DEPRECATED, REMOVED, or
FIXED. For security-related issues, follow the Security Advisory
process.)
Please take care to name the exact pieces of the API you've added or
changed (e.g. types, interfaces, functions, or methods).
If there are any breaking changes, make sure to offer a solution for
consumers to follow once they upgrade to the changes.
Finally, if you're only making changes to development scripts or tests,
you may replace the template below with "None".
-->
(N/A)
## Checklist
- [x] I've updated the test suite for new or updated code as appropriate
- [x] I've updated documentation (JSDoc, Markdown, etc.) for new or
updated code as appropriate
- [x] I've highlighted breaking changes using the "BREAKING" category
above as appropriate
---------
Co-authored-by: jiexi <[email protected]>
Co-authored-by: Alex Donesky <[email protected]>
Co-authored-by: Prithpal Sooriya <[email protected]>
Co-authored-by: Shane <[email protected]>
Co-authored-by: Derek Brans <[email protected]>
Co-authored-by: Monte Lai <[email protected]>resetMocks Jest configuration option (#4417)1 parent ca683e8 commit 2b1841c
File tree
40 files changed
+232
-181
lines changed- packages
- accounts-controller/src
- approval-controller/src
- assets-controllers/src
- RatesController
- gas-fee-controller/src
- logging-controller/src
- name-controller/src
- providers
- network-controller/tests
- permission-controller/src
- selected-network-controller/tests
- signature-controller/src
- transaction-controller/src
- gas-flows
- helpers
- utils
- user-operation-controller/src
- helpers
- utils
- scripts/create-package
40 files changed
+232
-181
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
108 | 108 | | |
109 | 109 | | |
110 | 110 | | |
111 | | - | |
112 | | - | |
| 111 | + | |
113 | 112 | | |
114 | 113 | | |
115 | 114 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
50 | 50 | | |
51 | 51 | | |
52 | 52 | | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
53 | 57 | | |
54 | 58 | | |
55 | 59 | | |
| |||
Lines changed: 0 additions & 11 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
315 | 315 | | |
316 | 316 | | |
317 | 317 | | |
318 | | - | |
319 | | - | |
320 | | - | |
321 | | - | |
322 | 318 | | |
323 | 319 | | |
324 | 320 | | |
| |||
449 | 445 | | |
450 | 446 | | |
451 | 447 | | |
452 | | - | |
453 | | - | |
454 | | - | |
455 | 448 | | |
456 | 449 | | |
457 | 450 | | |
| |||
1304 | 1297 | | |
1305 | 1298 | | |
1306 | 1299 | | |
1307 | | - | |
1308 | | - | |
1309 | | - | |
1310 | | - | |
1311 | 1300 | | |
1312 | 1301 | | |
1313 | 1302 | | |
| |||
Lines changed: 5 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| 5 | + | |
5 | 6 | | |
6 | 7 | | |
7 | 8 | | |
| |||
24 | 25 | | |
25 | 26 | | |
26 | 27 | | |
27 | | - | |
28 | | - | |
29 | | - | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
30 | 31 | | |
31 | 32 | | |
32 | 33 | | |
| |||
243 | 244 | | |
244 | 245 | | |
245 | 246 | | |
| 247 | + | |
246 | 248 | | |
247 | 249 | | |
248 | 250 | | |
| |||
Lines changed: 0 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
75 | 75 | | |
76 | 76 | | |
77 | 77 | | |
78 | | - | |
79 | 78 | | |
80 | 79 | | |
81 | 80 | | |
| |||
Lines changed: 0 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
90 | 90 | | |
91 | 91 | | |
92 | 92 | | |
93 | | - | |
94 | | - | |
95 | | - | |
96 | | - | |
97 | 93 | | |
98 | 94 | | |
99 | 95 | | |
| |||
116 | 112 | | |
117 | 113 | | |
118 | 114 | | |
119 | | - | |
120 | 115 | | |
121 | 116 | | |
122 | 117 | | |
| |||
249 | 244 | | |
250 | 245 | | |
251 | 246 | | |
252 | | - | |
253 | 247 | | |
254 | 248 | | |
255 | 249 | | |
| |||
Lines changed: 0 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
517 | 517 | | |
518 | 518 | | |
519 | 519 | | |
520 | | - | |
521 | 520 | | |
522 | 521 | | |
523 | 522 | | |
| |||
Lines changed: 0 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
81 | 81 | | |
82 | 82 | | |
83 | 83 | | |
84 | | - | |
85 | | - | |
86 | | - | |
87 | | - | |
88 | 84 | | |
89 | 85 | | |
90 | 86 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
77 | 77 | | |
78 | 78 | | |
79 | 79 | | |
80 | | - | |
81 | 80 | | |
82 | 81 | | |
83 | 82 | | |
| |||
0 commit comments