fix(tests): Mock MessageChannel to prevent Jest hanging from rc-overflow (#34871)

Co-authored-by: Claude <noreply@anthropic.com>
This commit is contained in:
Joe Li
2025-08-27 22:50:08 -07:00
committed by GitHub
parent b558b34faf
commit 836540e8c9
3 changed files with 28 additions and 0 deletions

View File

@@ -23,6 +23,7 @@ This file documents any backwards-incompatible changes in Superset and
assists people when migrating to a new version.
## Next
- [34871](https://github.com/apache/superset/pull/34871): Fixed Jest test hanging issue from Ant Design v5 upgrade. MessageChannel is now mocked in test environment to prevent rc-overflow from causing Jest to hang. Test environment only - no production impact.
- [34782](https://github.com/apache/superset/pull/34782): Dataset exports now include the dataset ID in their file name (similar to charts and dashboards). If managing assets as code, make sure to rename existing dataset YAMLs to include the ID (and avoid duplicated files).
- [34536](https://github.com/apache/superset/pull/34536): The `ENVIRONMENT_TAG_CONFIG` color values have changed to support only Ant Design semantic colors. Update your `superset_config.py`:
- Change `"error.base"` to just `"error"` after this PR

View File

@@ -747,6 +747,26 @@ To run a single test file:
npm run test -- path/to/file.js
```
#### Known Issues and Workarounds
**Jest Test Hanging (MessageChannel Issue)**
If Jest tests hang with "Jest did not exit one second after the test run has completed", this is likely due to the MessageChannel issue from rc-overflow (Ant Design v5 components).
**Root Cause**: `rc-overflow@1.4.1` creates MessageChannel handles for responsive overflow detection that remain open after test completion.
**Current Workaround**: MessageChannel is mocked as undefined in `spec/helpers/jsDomWithFetchAPI.ts`, forcing rc-overflow to use requestAnimationFrame fallback.
**To verify if still needed**: Remove the MessageChannel mocking lines and run `npm test -- --shard=4/8`. If tests hang, the workaround is still required.
**Future removal conditions**: This workaround can be removed when:
- rc-overflow updates to properly clean up MessagePorts in test environments
- Jest updates to handle MessageChannel/MessagePort cleanup better
- Ant Design switches away from rc-overflow
- We switch away from Ant Design v5
**See**: [PR #34871](https://github.com/apache/superset/pull/34871) for full technical details.
### Debugging Server App
#### Local

View File

@@ -31,5 +31,12 @@ export default class FixJSDOMEnvironment extends JSDOMEnvironment {
this.global.Response = Response;
this.global.AbortSignal = AbortSignal;
this.global.AbortController = AbortController;
// Mock MessageChannel to prevent hanging Jest tests with rc-overflow@1.4.1
// Forces rc-overflow to use requestAnimationFrame fallback instead
// Can be removed when rc-overflow properly cleans up MessagePorts in test environments
// See: https://github.com/apache/superset/pull/34871
delete (this.global as any).MessageChannel;
delete (this.global as any).MessagePort;
}
}