Skip to content

[BUG] [v0.1.0] cov-CortexDiffEditor vitest suite fails before tests run because workspace mock omits getProjectPath #60

@Felly-crypto

Description

@Felly-crypto

Project:

  • ide

Description:

  • The isolated Vitest suite for src/components/cortex/editor/__tests__/cov-CortexDiffEditor.test.tsx fails before any tests run because its @/utils/workspace mock omits getProjectPath.
  • SDKContext calls getProjectPath() during initialization, so the suite crashes at import/setup time with 0 test executed.
  • This also contributes to npm run test failing on main because the broken suite aborts the run.

Error Message:

  • [vitest] No "getProjectPath" export is defined on the "@/utils/workspace" mock. Did you forget to return it from "vi.mock"?

Debug Logs:

  • Repro command:
  • npm.cmd run test -- src/components/cortex/editor/__tests__/cov-CortexDiffEditor.test.tsx
  • Relevant excerpt:
> cortex-desktop@0.1.0 test
> vitest run src/components/cortex/editor/__tests__/cov-CortexDiffEditor.test.tsx

FAIL src/components/cortex/editor/__tests__/cov-CortexDiffEditor.test.tsx
Error: [vitest] No "getProjectPath" export is defined on the "@/utils/workspace" mock.
? getInitialCwd src/context/SDKContext.tsx:141:12

System Information:

  • OS: Microsoft Windows 11 Pro (10.0.26200)
  • CPU/RAM: Intel(R) Core(TM) i7-8665U CPU @ 1.90GHz, 15.78 GB RAM
  • GPU (if relevant): Intel(R) UHD Graphics 620 (Driver 31.0.101.2137)
  • Node version: v24.14.0
  • npm version: 11.9.0
  • Rust version: N/A on tested machine (rustc not on PATH; not required for repro)
  • App version: 0.1.0 (package.json), 0.1.0 (src-tauri/tauri.conf.json)
  • Git commit short SHA: c2037f2

Screenshots:

  • Evidence type: Screenshot(s)
  • What to capture:
  • Terminal output showing the isolated Vitest suite failing with the missing getProjectPath mock export.
  • Source evidence showing the incomplete mock in cov-CortexDiffEditor.test.tsx, the real getProjectPath export in workspace.ts, and the call site in SDKContext.tsx.
  • How to capture (include OS steps):
  • Windows: Win+Shift+S for screenshots, Win+Alt+R for video.
  • macOS: Shift+Cmd+4 for screenshots, Shift+Cmd+5 for video.
  • Linux: PrtSc / Shift+PrtSc for screenshots, Ctrl+Alt+Shift+R or OBS for video.
  • When to capture:
  • At step 4 when the Vitest error is visible.
  • At step 5 when the source lines are visible.
  • Attach instructions:
  • Embedded below from a public evidence repo owned by the reporting account.
  • Terminal evidence:
    terminal evidence
  • Code evidence:
    code evidence

Steps to Reproduce:

  1. git clone https://github.com/CortexLM/cortex-ide.git
  2. cd cortex-ide
  3. npm.cmd ci
  4. Run npm.cmd run test -- src/components/cortex/editor/__tests__/cov-CortexDiffEditor.test.tsx
  5. Observe the suite fails before running tests because the mocked @/utils/workspace module does not provide getProjectPath.

Expected Behavior:

  • The isolated cov-CortexDiffEditor suite should load and execute its tests without import-time mock errors.

Actual Behavior:

  • The suite aborts at import/setup time with 0 test executed because SDKContext reaches getProjectPath() and the mocked module does not export it.

Additional Context:

  • Frequency: Always on the tested commit.
  • Workarounds: Local-only fix by adding getProjectPath to the test mock or partially mocking @/utils/workspace with importOriginal.
  • Suspected cause + file(s)/component(s):
  • src/components/cortex/editor/__tests__/cov-CortexDiffEditor.test.tsx:5
  • src/utils/workspace.ts:20
  • src/context/SDKContext.tsx:141
  • Duplicate check: repo issue searches for cov-CortexDiffEditor.test.tsx getProjectPath, No getProjectPath export workspace mock, and vitest workspace mock getProjectPath returned no matches before filing.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions