MetaMask / MetaMask/core

Improve unit tests

Open
#413 0 comments 3 reactions 0 assignees View on GitHub
team-wallet-framework wf-test-quality-improvement
Dominant language
TypeScript
Stars
413
Forks
308
Avg merge
1d 4h
Merged PRs (30d)
253

Description

This is a tracking issue for improving unit tests in various ways.

Related issues:

- #1
- #744
- #745
- #746
- #748
- #493
- #749
- #750
- #743

Some general advice: writing unit tests should be easy. They may be verbose and time consuming to write, but they should be easy. If it's not easy, change the API under test to make it easy.

Many of the APIs in this repository make unit testing difficult. Your time is better spent improving the API first and writing simple unit tests, rather than struggling to write complex tests for a complex API. Consider ways to reduce the API surface, reduce dependencies, inject dependencies to simplify stubbing, and move complex functionality into separate modules.

Tracker by module:

Check off each module as they are audited for each of the criteria outlined above.

- [ ] ./src/announcement/AnnouncementController.test.ts
- [ ] ./src/permissions/Caveat.test.ts
- [ ] ./src/permissions/PermissionController.test.ts
- [ ] ./src/permissions/rpc-methods/requestPermissions.test.ts
- [ ] ./src/permissions/rpc-methods/getPermissions.test.ts
- [ ] ./src/permissions/errors.test.ts
- [ ] ./src/permissions/Permission.test.ts
- [ ] ./src/keyring/KeyringController.test.ts
- [ ] ./src/notification/NotificationController.test.ts
- [ ] ./src/third-party/EnsController.test.ts
- [ ] ./src/third-party/PhishingController.test.ts
- [ ] ./src/BaseControllerV2.test.ts
- [ ] ./src/message-manager/MessageManager.test.ts
- [ ] ./src/message-manager/AbstractMessageManager.test.ts
- [ ] ./src/message-manager/PersonalMessageManager.test.ts
- [ ] ./src/message-manager/TypedMessageManager.test.ts
- [ ] ./src/assets/AccountTrackerController.test.ts
- [ ] ./src/assets/AssetsContractController.test.ts
- [ ] ./src/assets/NftController.test.ts
- [ ] ./src/assets/assetsUtil.test.ts
- [ ] ./src/assets/CurrencyRateController.test.ts
- [ ] ./src/assets/TokenBalancesController.test.ts
- [ ] ./src/assets/TokenListController.test.ts
- [ ] ./src/assets/TokenDetectionController.test.ts
- [ ] ./src/assets/NftDetectionController.test.ts
- [ ] ./src/assets/TokensController.test.ts
- [ ] ./src/assets/TokenRatesController.test.ts
- [ ] ./src/assets/Standards/NftStandards/ERC721/ERC721Standard.test.ts
- [ ] ./src/assets/Standards/NftStandards/ERC1155/ERC1155Standard.test.ts
- [ ] ./src/assets/Standards/ERC20Standard.test.ts
- [ ] ./src/user/AddressBookController.test.ts
- [ ] ./src/user/PreferencesController.test.ts
- [ ] ./src/subject-metadata/SubjectMetadataController.test.ts
- [ ] ./src/network/NetworkController.test.ts
- [ ] ./src/ControllerMessenger.test.ts
- [ ] ./src/ratelimit/RateLimitController.test.ts
- [ ] ./src/gas/fetchGasEstimatesViaEthFeeHistory.test.ts
- [ ] ./src/gas/fetchGasEstimatesViaEthFeeHistory/calculateGasFeeEstimatesForPriorityLevels.test.ts
- [ ] ./src/gas/gas-util.test.ts
- [ ] ./src/gas/determineGasFeeCalculations.test.ts
- [ ] ./src/gas/fetchBlockFeeHistory.test.ts
- [ ] ./src/gas/GasFeeController.test.ts
- [ ] ./src/BaseController.test.ts
- [ ] ./src/ComposableController.test.ts
- [ ] ./src/transaction/TransactionController.test.ts
- [ ] ./src/util.test.ts
- [ ] ./src/apis/crypto-compare.test.ts
- [ ] ./src/apis/token-service.test.ts
- [ ] ./src/approval/ApprovalController.test.ts

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by choosing one unchecked test file from the module tracker, such as src/announcement/AnnouncementController.test.ts, and audit its API, dependencies, stubbing, and test complexity against the issue guidance. Read the related issues for scope before changing anything; done means the selected module is audited and its checkbox can be marked complete.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
testing-qa
Issue type
Refactor
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
20/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.