MetaMask / MetaMask/metamask-design-system
Fix Jest worker process cleanup in design-system-react-native tests
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 37
- Forks
- 14
- Avg merge
- 1d 9h
- Merged PRs (30d)
- 60
Description
### **Description**
The Jest tests in the `@metamask/design-system-react-native` package are experiencing worker process cleanup issues, specifically with the `react-native-jazzicon` component in the `AvatarAccount` tests. This is causing tests to fail with the error "A worker process has failed to exit gracefully and has been force exited."
Additionally, the `react-native-jazzicon` package is using the deprecated React lifecycle method `componentWillReceiveProps`, which is contributing to the cleanup issues.
### **Technical Details**
- The issue stems from improper cleanup of the `react-native-jazzicon` component after tests
- The `AvatarAccount` component tests are not properly cleaning up resources after each test case
- Upstream issue: `react-native-jazzicon` package uses deprecated `componentWillReceiveProps` lifecycle method
- Related issue filed in `react-native-jazzicon` repository: https://github.com/stanislaw-glogowski/react-native-jazzicon/issues/3
### **Acceptance Criteria**
- [ ] Implement proper cleanup in `jest.setup.js` for the `react-native-jazzicon` mock
- [ ] Add cleanup after each test in `AvatarAccount.test.tsx`
- [ ] Ensure tests pass without worker process errors
- [ ] Maintain existing test coverage and functionality
- [ ] Verify cleanup works across all test cases
- [ ] Monitor upstream `react-native-jazzicon` issue for updates regarding the deprecated lifecycle method
### **References**
- Related to test cleanup issues in React Native Testing Library
- Affects the `AvatarAccount` component tests
- Current error: "A worker process has failed to exit gracefully and has been force exited"
- Solution involves proper mocking and cleanup of the `react-native-jazzicon` component
- Upstream issue: https://github.com/stanislaw-glogowski/react-native-jazzicon/issues/3
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with jest.setup.js and AvatarAccount.test.tsx, then run the affected Jest tests to reproduce the worker process cleanup error. Implement the specified mock and per-test cleanup, and verify that all AvatarAccount tests pass without worker-process errors while preserving existing coverage and functionality.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- react-native, typescript
- Domain
- mobile, testing-qa
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100