You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by "hainenber (via GitHub)" <gi...@apache.org> on 2026/03/14 05:51:21 UTC
[PR] chore(build): remove replaceable `jest-mock-console` with native Jest spies [superset]
hainenber opened a new pull request, #38643:
URL: https://github.com/apache/superset/pull/38643
… spies
<!---
Please write the PR title following the conventions at https://www.conventionalcommits.org/en/v1.0.0/
Example:
fix(dashboard): load charts correctly
-->
chore(build): remove replaceable `jest-mock-console` with native Jest spies
### SUMMARY
<!--- Describe the change below, including rationale and design decisions -->
A chore PR to remove replaceable `jest-mock-console` with Jest-native `jest.spyOn` with equivalent functionality.
### BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
<!--- Skip this if not applicable -->
N/A
### TESTING INSTRUCTIONS
<!--- Required! What steps can be taken to manually verify the changes? -->
Green CI
### ADDITIONAL INFORMATION
<!--- Check any relevant boxes with "x" -->
<!--- HINT: Include "Fixes #nnn" if you are fixing an existing issue -->
- [ ] Has associated issue:
- [ ] Required feature flags:
- [ ] Changes UI
- [ ] Includes DB Migration (follow approval process in [SIP-59](https://github.com/apache/superset/issues/13351))
- [ ] Migration is atomic, supports rollback & is backwards-compatible
- [ ] Confirm DB migration upgrade and downgrade tested
- [ ] Runtime estimates and downtime expectations provided
- [ ] Introduces new feature or API
- [ ] Removes existing feature or API
--
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: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] chore(build): replace replaceable `jest-mock-console` with native Jest spies [superset]
Posted by "hainenber (via GitHub)" <gi...@apache.org>.
hainenber merged PR #38643:
URL: https://github.com/apache/superset/pull/38643
--
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: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] chore(build): remove replaceable `jest-mock-console` with native Jest spies [superset]
Posted by "hainenber (via GitHub)" <gi...@apache.org>.
hainenber commented on PR #38643:
URL: https://github.com/apache/superset/pull/38643#issuecomment-4275150503
An ESLint rule should be sufficient IMO and we can use spare tokens for other reasonings ;)
--
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: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] chore(build): remove replaceable `jest-mock-console` with native Jest spies [superset]
Posted by "codeant-ai-for-open-source[bot] (via GitHub)" <gi...@apache.org>.
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: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] chore(build): remove replaceable `jest-mock-console` with native Jest spies [superset]
Posted by "bito-code-review[bot] (via GitHub)" <gi...@apache.org>.
bito-code-review[bot] commented on PR #38643:
URL: https://github.com/apache/superset/pull/38643#issuecomment-4275236600
AI Code Review is in progress (usually takes 3 to 15 minutes unless it's a very large PR).
<details>
<summary>
Bito Usage Guide
</summary>
**Commands**
Type the following command in the pull request comment and save the comment.
- `/review` - Manually triggers a full AI review.
- `/pause` - Pauses automatic reviews on this pull request.
- `/resume` - Resumes automatic reviews.
- `/resolve` - Marks all Bito-posted review comments as resolved.
- `/abort` - Cancels all in-progress reviews.
Refer to the <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent/available-commands" target="_blank" rel="noopener noreferrer">documentation</a> for additional commands.
**Configuration**
This repository uses `Superset` You can customize the agent settings <a href="https://alpha.bito.ai/home/ai-agents/code-review-agent" target="_blank" rel="noopener noreferrer">here</a> or contact your Bito workspace admin at evan@preset.io.
**Documentation & Help**
- <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent/getting-started/install-run-using-bito-cloud/create-or-customize-an-agent-instance" target="_blank" rel="noopener noreferrer">Customize agent settings</a>
- <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent/implementing-custom-code-review-rules" target="_blank" rel="noopener noreferrer">Review rules</a>
- <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent" target="_blank" rel="noopener noreferrer">General documentation</a>
- <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent/faqs" target="_blank" rel="noopener noreferrer">FAQ</a>
</details>
--
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: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] chore(build): remove replaceable `jest-mock-console` with native Jest spies [superset]
Posted by "codecov[bot] (via GitHub)" <gi...@apache.org>.
codecov[bot] commented on PR #38643:
URL: https://github.com/apache/superset/pull/38643#issuecomment-4275170743
## [Codecov](https://app.codecov.io/gh/apache/superset/pull/38643?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) Report
:white_check_mark: All modified and coverable lines are covered by tests.
:white_check_mark: Project coverage is 64.49%. Comparing base ([`03725d1`](https://app.codecov.io/gh/apache/superset/commit/03725d1aaa56a70233574b0167ca6d3431383979?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)) to head ([`a09d60e`](https://app.codecov.io/gh/apache/superset/commit/a09d60e5cf03b8203200408d0902eec6d6330582?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)).
:warning: Report is 1 commits behind head on master.
<details><summary>Additional details and impacted files</summary>
```diff
@@ Coverage Diff @@
## master #38643 +/- ##
=======================================
Coverage 64.49% 64.49%
=======================================
Files 2557 2557
Lines 133191 133191
Branches 30935 30935
=======================================
Hits 85897 85897
Misses 45804 45804
Partials 1490 1490
```
| [Flag](https://app.codecov.io/gh/apache/superset/pull/38643/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | Coverage Δ | |
|---|---|---|
| [javascript](https://app.codecov.io/gh/apache/superset/pull/38643/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `66.32% <ø> (ø)` | |
Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#carryforward-flags-in-the-pull-request-comment) to find out more.
</details>
[:umbrella: View full report in Codecov by Sentry](https://app.codecov.io/gh/apache/superset/pull/38643?dropdown=coverage&src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).
:loudspeaker: Have feedback on the report? [Share it here](https://about.codecov.io/codecov-pr-comment-feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).
<details><summary> :rocket: New features to boost your workflow: </summary>
- :snowflake: [Test Analytics](https://docs.codecov.com/docs/test-analytics): Detect flaky tests, report on failures, and find test suite problems.
- :package: [JS Bundle Analysis](https://docs.codecov.com/docs/javascript-bundle-analysis): Save yourself from yourself by tracking and limiting bundle sizes in JS merges.
</details>
--
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: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] chore(build): remove replaceable `jest-mock-console` with native Jest spies [superset]
Posted by "codeant-ai-for-open-source[bot] (via GitHub)" <gi...@apache.org>.
codeant-ai-for-open-source[bot] commented on PR #38643:
URL: https://github.com/apache/superset/pull/38643#issuecomment-4059665340
## **Sequence Diagram**
This PR replaces the external console mocking helper with Jest native spies across superset-ui-core tests. The core flow now relies on globally created console spies and per-test mock clearing to keep assertions isolated.
```mermaid
sequenceDiagram
participant TestRunner
participant Jest
participant CodeUnderTest
participant Console
TestRunner->>Jest: Create spies for console warn and error
TestRunner->>Jest: Clear spy call history before each test
TestRunner->>CodeUnderTest: Run chart and registry test cases
CodeUnderTest->>Console: Trigger warn or error when needed
TestRunner->>Jest: Assert expected console calls from spies
```
---
*Generated by [CodeAnt AI](https://codeant.ai)*
--
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: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] chore(build): remove replaceable `jest-mock-console` with native Jest spies [superset]
Posted by "bito-code-review[bot] (via GitHub)" <gi...@apache.org>.
bito-code-review[bot] commented on PR #38643:
URL: https://github.com/apache/superset/pull/38643#issuecomment-4059660378
AI Code Review is in progress (usually takes 3 to 15 minutes unless it's a very large PR).
--
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: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org