MetaMask / MetaMask/metamask-extension
Investigate unintentional dependencies between distinct unit tests in metamask-controller.js
- Dominant language
- TypeScript
- Stars
- 13.2k
- Forks
- 5.6k
- Avg merge
- 2d 5h
- Merged PRs (30d)
- 451
Description
These test failures were seen on commit 11f34ccfecd2ebde6a3dbb451be7a77607c17875:
```
Summary of all failing tests
FAIL app/scripts/metamask-controller.test.js (19.351 s)
● MetaMaskController › MetaMaskController Behaviour › getTokenStandardAndDetails › gets token data from the token list if available, and with a balance retrieved by fetchTokenBalance
Internal JSON-RPC error.
at getJsonRpcError (node_modules/@metamask/rpc-errors/src/errors.ts:256:10)
at Object.internal (node_modules/@metamask/rpc-errors/src/errors.ts:71:8)
at parseResponse (node_modules/@metamask/eth-json-rpc-middleware/src/fetch.ts:133:21)
at node_modules/@metamask/eth-json-rpc-middleware/src/fetch.ts:84:31
● MetaMaskController › MetaMaskController Behaviour › getTokenStandardAndDetails › gets token data from the token list if available, and with a balance retrieved by fetchTokenBalance
Internal JSON-RPC error.
at getJsonRpcError (node_modules/@metamask/rpc-errors/src/errors.ts:256:10)
at Object.internal (node_modules/@metamask/rpc-errors/src/errors.ts:71:8)
at parseResponse (node_modules/@metamask/eth-json-rpc-middleware/src/fetch.ts:133:21)
at node_modules/@metamask/eth-json-rpc-middleware/src/fetch.ts:84:31
● MetaMaskController › MetaMaskController Behaviour › getTokenStandardAndDetails › gets token data from the token list if available, and with a balance retrieved by fetchTokenBalance
Internal JSON-RPC error.
at getJsonRpcError (node_modules/@metamask/rpc-errors/src/errors.ts:256:10)
at Object.internal (node_modules/@metamask/rpc-errors/src/errors.ts:71:8)
at parseResponse (node_modules/@metamask/eth-json-rpc-middleware/src/fetch.ts:133:21)
at node_modules/@metamask/eth-json-rpc-middleware/src/fetch.ts:84:31
● MetaMaskController › MetaMaskController Behaviour › getTokenStandardAndDetails › gets token data from the token list if available, and with a balance retrieved by fetchTokenBalance
Internal JSON-RPC error.
at getJsonRpcError (node_modules/@metamask/rpc-errors/src/errors.ts:256:10)
at Object.internal (node_modules/@metamask/rpc-errors/src/errors.ts:71:8)
at parseResponse (node_modules/@metamask/eth-json-rpc-middleware/src/fetch.ts:133:21)
at node_modules/@metamask/eth-json-rpc-middleware/src/fetch.ts:84:31
Test Suites: 1 failed, 97 passed, 98 total
Tests: 1 failed, 762 passed, 763 total
Snapshots: 49 passed, 49 total
Time: 144.485 s
```
They started after 11f34ccfecd2ebde6a3dbb451be7a77607c17875 and f68a5e5ac2aadbd200d87f89ee31cbce37400337 were added merged into the same branch. The failing unit tests were fixed by a1c96fd8e1f3c7e500bee6db38f163f52d7f2874
Somehow changing the metamask controller state in one test broke another test. I didn't think this was possible as new instances of the mm controller are created before each test. We should investigate this problem and improve this test file so that no test run is dependent on the specifics of another test run.
Contributor guide
Research direction
Start with app/scripts/metamask-controller.test.js and run the MetaMaskController test suite, focusing on the getTokenStandardAndDetails failures reported at commit 11f34ccfecd2ebde6a3dbb451be7a77607c17875. Compare the effects of the changes from commits 11f34ccfecd2ebde6a3dbb451be7a77607c17875 and f68a5e5ac2aadbd200d87f89ee31cbce37400337 with the fix in a1c96fd8e1f3c7e500bee6db38f163f52d7f2874. Done means the test file no longer depends on state or execution details from another test.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- testing
- Issue type
- Refactor
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100