MetaMask / MetaMask/metamask-design-system

Fix Jest worker process cleanup in design-system-react-native tests

Open
#463 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

team-design-system
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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.