codeant-ai-for-open-source[bot] commented on code in PR #44042:
URL: https://github.com/apache/superset/pull/44042#discussion_r3964731153
##########
superset-frontend/plugins/plugin-chart-point-cluster-map/test/MapLibre.test.tsx:
##########
@@ -70,6 +70,23 @@ jest.mock('@apache-superset/core/theme', () => ({
jest.mock('maplibre-gl/dist/maplibre-gl.css', () => ({}));
jest.mock('../src/MapLibre.css', () => ({}));
+// maplibre-gl 6 is an ESM-only package with no "require"/"default" export
+// condition, so jest's (CJS-based) resolver can't locate the real module to
+// mock over it by name; { virtual: true } skips that resolution step.
+//
+// The mock jest.fn() is created inline (not hoisted out to a `const`)
+// because MapLibre.tsx calls maplibregl.setWorkerUrl() synchronously at
+// import time, and `import`/jest.mock() calls are themselves hoisted above
+// this file's plain `const` declarations — a `const` referenced here would
+// still be in its temporal dead zone when that import-time call fires.
+jest.mock(
+ 'maplibre-gl',
+ () => ({ __esModule: true, setWorkerUrl: jest.fn() }),
+ { virtual: true },
+);
Review Comment:
✅ **Customized review instruction saved!**
**Instruction:**
> Do not require unit tests to validate webpack build outputs, copied worker
assets, MIME handling, or real Worker loading; cover those concerns with build
or end-to-end tests instead.
**Applied to:**
- `**/test/**`
- `**/tests/**`
- `**/*test*.tsx`
---
💡 *To manage or update this instruction, visit: [CodeAnt AI
Settings](https://app.codeant.ai/org/settings/learnings)*
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]