Skip to content

Conversation

@mcmire
Copy link
Contributor

@mcmire mcmire commented Jun 12, 2024

Explanation

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

Fixes #745.

Changelog

(N/A)

Checklist

  • I've updated the test suite for new or updated code as appropriate
  • I've updated documentation (JSDoc, Markdown, etc.) for new or updated code as appropriate
  • I've highlighted breaking changes using the "BREAKING" category above as appropriate

@mcmire mcmire requested a review from a team as a code owner June 12, 2024 22:24
@mcmire mcmire requested a review from a team June 12, 2024 22:24
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).
@mcmire mcmire force-pushed the enable-reset-mocks branch from 0136db9 to fed305e Compare June 12, 2024 22:34
kanthesha
kanthesha previously approved these changes Jun 14, 2024
Copy link
Contributor

@kanthesha kanthesha left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

Mrtenz
Mrtenz previously approved these changes Jun 14, 2024
mcmire and others added 12 commits June 14, 2024 08:48
Releases `queued-request-controller` methods array constructor param to
callback constructor param update

---------

Co-authored-by: Alex Donesky <adonesky@gmail.com>
## Explanation

it seems we were inconsistent and forgot to correctly handle default
exports and controller exports

## 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
## Explanation

Releases `profile-sync-controller` and from `0.0.0` to `0.1.0`

## References

N/A

## Changelog

### `@metamask/profile-sync-controller`

- **ADDED**: Initial release of SDK; Authentication Controller; User
Storage Controller.

## 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
## Explanation

This was removed as it was blocking publishing of profile sync
controller. Adding here so it unblocks the next release for this
controller: #4438


## 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
## Explanation

Releases `notification-services-controller` from `0.0.0` to `0.1.0`.

## References

N/A

## Changelog

### `@metamask/notification-services-controller`

- **ADDED**: Initial Release of Notification Services Controller;
Notification Services Push Controller.

## 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
Cleans up / fixes some `SelectedNetworkController` specs

Fixes: MetaMask/MetaMask-planning#2626

No consumer facing changes

- [x] I've updated the test suite for new or updated code as appropriate
- [ ] I've updated documentation (JSDoc, Markdown, etc.) for new or
updated code as appropriate
- [ ] I've highlighted breaking changes using the "BREAKING" category
above as appropriate

---------

Co-authored-by: Alex Donesky <adonesky@gmail.com>
## Explanation

Please see MetaMask/MetaMask-planning#2668

## References

See: MetaMask/MetaMask-planning#2668
Unblocks: #4327

## Changelog

No user facing changes

## Checklist

- [ ] I've updated the test suite for new or updated code as appropriate
- [ ] I've updated documentation (JSDoc, Markdown, etc.) for new or
updated code as appropriate
- [ ] I've highlighted breaking changes using the "BREAKING" category
above as appropriate

---------

Co-authored-by: Jiexi Luan <jiexiluan@gmail.com>
Co-authored-by: Derek Brans <dbrans@gmail.com>
## Explanation
Met with @matthewwalsh0 who took the time to explain each status.

## References

## Changelog

## Checklist

- [ ] I've updated the test suite for new or updated code as appropriate
- [ ] I've updated documentation (JSDoc, Markdown, etc.) for new or
updated code as appropriate
- [ ] I've highlighted breaking changes using the "BREAKING" category
above as appropriate
…lectedAddress (#4219)

## Explanation

This PR updates the `selectedAccount` to `selectedAccountId` in the
token controllers

## References

Fixes MetaMask/accounts-planning#381

## Changelog

### `@metamask/assets-controllers`

- **BREAKING**: `TokenBalancesController` update
`PreferencesConrtollerGetStateAction` to
`AccountsControllerGetSelectedAccountAction`
- **BREAKING**: `TokenDetectionController` change `selectedAddress` to
`selectedAccountId`
- **ADDED**: `TokenDetectionController` add `getAccountAction`
- **BREAKING**: `TokenRatesController` change `selectedAddress` to
`selectedAccountId`
- **BREAKING**: `onPreferencesStateChange` arg removed and
`getInternalAccount` and `onSelectedAccountChange` added in
`TokenRatesController`
- **ADDED**: `getAccountAction` added in`TokensController` 
- **BREAKING**: Changed `selectedAddress` to `selectedAccountId` and
`PreferencesControllerStateChangeEvent` to
`AccountsControllerSelectedEvmAccountChangeEvent` in the
`TokensController`
- **ADDED**: `getAccountAction` added in`TokensController` 

## 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
@mcmire mcmire dismissed stale reviews from kanthesha and Mrtenz via 0b17128 June 20, 2024 22:50
@mcmire
Copy link
Contributor Author

mcmire commented Jun 20, 2024

Resolved conflicts.

@mcmire mcmire requested a review from a team June 21, 2024 21:18
Copy link
Member

@Gudahtt Gudahtt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@Gudahtt Gudahtt requested a review from Mrtenz June 24, 2024 14:17
@Gudahtt Gudahtt merged commit 2b1841c into main Jun 24, 2024
@Gudahtt Gudahtt deleted the enable-reset-mocks branch June 24, 2024 14:23
@montelaidev montelaidev mentioned this pull request Jun 25, 2024
3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Update test setup to reset and restore all mocks between each test