codeant-ai-for-open-source[bot] commented on code in PR #38643:
URL: https://github.com/apache/superset/pull/38643#discussion_r2934776101
##########
superset-frontend/packages/superset-ui-core/test/models/Registry.test.ts:
##########
@@ -18,11 +18,18 @@
*/
/* eslint no-console: 0 */
-import mockConsole from 'jest-mock-console';
import { Registry, OverwritePolicy } from '@superset-ui/core';
const loader = () => 'testValue';
+const consoleWarnSpy = jest.spyOn(console, 'warn');
+const consoleErrorSpy = jest.spyOn(console, 'error');
Review Comment:
**Suggestion:** These spies currently call through to the real console
methods, so warnings/errors from the tested error paths are still emitted
during test execution. That is not equivalent to the previous console-mocking
behavior and can cause noisy/flaky test runs (for example, async console output
after test completion). Stub the spy implementations to no-op while still
tracking calls. [logic error]
<details>
<summary><b>Severity Level:</b> Major ⚠️</summary>
```mdx
- ⚠️ Registry warning-path tests emit real console output.
- ⚠️ `test-loud` runs get noisy, harder failure inspection.
- ⚠️ Behavior differs from other tests using mocked console implementations.
```
</details>
```suggestion
const consoleWarnSpy = jest
.spyOn(console, 'warn')
.mockImplementation(() => undefined);
const consoleErrorSpy = jest
.spyOn(console, 'error')
.mockImplementation(() => undefined);
```
<details>
<summary><b>Steps of Reproduction ✅ </b></summary>
```mdx
1. Run the test file with non-silent Jest output using the repo script
`test-loud` from
`superset-frontend/package.json:86` (e.g., execute only
`packages/superset-ui-core/test/models/Registry.test.ts`).
2. Jest loads
`superset-frontend/packages/superset-ui-core/test/models/Registry.test.ts`,
where top-level spies are created at lines `25-26` via `jest.spyOn(console,
'warn'|'error')` without `mockImplementation`, so calls pass through to real
console
methods.
3. Execute tests `warns when overwrite` at `Registry.test.ts:339-360`; these
call
`registry.registerValue/registerLoader` with `OverwritePolicy.Warn`, which
invokes
`console.warn` in
`superset-frontend/packages/superset-ui-core/src/models/Registry.ts:124`
and `:150`.
4. Execute test `with a broken listener -> keeps working` at
`Registry.test.ts:439-454`;
it triggers `console.error` from `Registry.ts:281`. Observe real
warning/error log
emission in test output. Tests still pass, but console side effects are not
suppressed.
```
</details>
<details>
<summary><b>Prompt for AI Agent 🤖 </b></summary>
```mdx
This is a comment left during a code review.
**Path:**
superset-frontend/packages/superset-ui-core/test/models/Registry.test.ts
**Line:** 25:26
**Comment:**
*Logic Error: These spies currently call through to the real console
methods, so warnings/errors from the tested error paths are still emitted
during test execution. That is not equivalent to the previous console-mocking
behavior and can cause noisy/flaky test runs (for example, async console output
after test completion). Stub the spy implementations to no-op while still
tracking calls.
Validate the correctness of the flagged issue. If correct, How can I resolve
this? If you propose a fix, implement it and please make it concise.
```
</details>
<a
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F38643&comment_hash=ceb8e00c4b1615ca1258ad371aa8b239b874d5e9892ffd176e55631cc29a9317&reaction=like'>👍</a>
| <a
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F38643&comment_hash=ceb8e00c4b1615ca1258ad371aa8b239b874d5e9892ffd176e55631cc29a9317&reaction=dislike'>👎</a>
--
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]