codeant-ai-for-open-source[bot] commented on code in PR #38308:
URL: https://github.com/apache/superset/pull/38308#discussion_r2867266543
##########
superset-websocket/spec/index.test.ts:
##########
@@ -25,29 +25,29 @@ import {
test,
beforeEach,
afterEach,
- jest,
-} from '@jest/globals';
+ vi,
+ Mock,
Review Comment:
**Suggestion:** `Mock` is a type-only export from Vitest, but it is imported
as a runtime value, which will cause a module load-time error because `vitest`
does not export a `Mock` value; it should be imported as a type-only symbol so
it disappears from the compiled runtime code. [possible bug]
<details>
<summary><b>Severity Level:</b> Critical π¨</summary>
```mdx
- β Websocket Vitest suite fails during module import.
- β CI for `superset-websocket` package cannot pass tests.
- β οΈ Blocks verification of websocket server behavior changes.
```
</details>
```suggestion
type Mock,
```
<details>
<summary><b>Steps of Reproduction β
</b></summary>
```mdx
1. Open `superset-websocket/spec/index.test.ts` and see the Vitest import at
lines 22β30:
`Mock` is imported alongside `describe`, `expect`, `test`, `beforeEach`,
`afterEach`, and
`vi` as a runtime value.
2. Note how `Mock` is only used in type positions in this file: for example
`const wsMock
= WebSocket as unknown as Mock<typeof WebSocket>;` (line 50) and `let
statsdIncrementMock:
Mock<typeof statsd.increment>;` (line 70), so no runtime access to a `Mock`
value is
needed.
3. Run the `superset-websocket` test suite with Vitest (which will load
`spec/index.test.ts` as part of the test run). When the module loader
evaluates the import
`} from 'vitest';` at line 30, it attempts to resolve a runtime export named
`Mock` from
the `vitest` package.
4. Because `Mock` is a type-only export in Vitest's TypeScript typings and
not an actual
runtime export, the compiled JavaScript will still contain the `Mock` named
import; at
runtime this leads to a module loadβtime error complaining that `Mock` is
not exported
from `vitest`, preventing the websocket test suite from executing.
```
</details>
<details>
<summary><b>Prompt for AI Agent π€ </b></summary>
```mdx
This is a comment left during a code review.
**Path:** superset-websocket/spec/index.test.ts
**Line:** 29:29
**Comment:**
*Possible Bug: `Mock` is a type-only export from Vitest, but it is
imported as a runtime value, which will cause a module load-time error because
`vitest` does not export a `Mock` value; it should be imported as a type-only
symbol so it disappears from the compiled runtime code.
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%2F38308&comment_hash=4b8783e29fd6310727bef54c989337c92e92912f29292eba152702085f905fba&reaction=like'>π</a>
| <a
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F38308&comment_hash=4b8783e29fd6310727bef54c989337c92e92912f29292eba152702085f905fba&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]