Skip to content

fix(tests): ensure logger mock isolation in version-check tests#71

Merged
utkarsh232005 merged 1 commit into
KDM-cli:mainfrom
utkarsh232005:fix/test-pollution-version-check
May 17, 2026
Merged

fix(tests): ensure logger mock isolation in version-check tests#71
utkarsh232005 merged 1 commit into
KDM-cli:mainfrom
utkarsh232005:fix/test-pollution-version-check

Conversation

@utkarsh232005
Copy link
Copy Markdown
Member

@utkarsh232005 utkarsh232005 commented May 17, 2026

This PR fixes a test pollution issue where the 'logger.error' mock was not being reset between tests, causing failures when upgrading Vitest. This resolves the CI failures seen in several Dependabot PRs.

Summary by CodeRabbit

  • Tests
    • Improved test isolation in the version check test suite by resetting test fixtures before each test case.

Review Change Stack

Copilot AI review requested due to automatic review settings May 17, 2026 19:26
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 17, 2026

Caution

Review failed

Pull request was closed or merged during review

Note

.coderabbit.yaml has unrecognized properties

CodeRabbit is using all valid settings from your configuration. Unrecognized properties (listed below) have been ignored and may indicate typos or deprecated fields that can be removed.

⚠️ Parsing warnings (1)
Validation error: Unrecognized key(s) in object: 'pre_merge_checks'
⚙️ Configuration instructions
  • Please see the configuration documentation for more information.
  • You can also validate your configuration using the online YAML validator.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json
📝 Walkthrough

Walkthrough

The PR adds a single line to reset the mocked logger.error function before each test in the checkForUpdates describe block. This improves test isolation by clearing the mock's call history and state between test runs, preventing cross-test contamination.

Changes

Logger Error Mock Reset

Layer / File(s) Summary
Mock Reset Setup
src/__tests__/version-check.test.ts
Before each checkForUpdates test, logger.error mock is reset via vi.mocked(logger.error).mockReset() to ensure prior assertions and call counts do not bleed into subsequent tests.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~2 minutes

Possibly related PRs

Poem

🧹 A mock reset between each test,
No cross-test spills, just staying blessed,
One tiny line, so clean and tight,
Isolation glows—tests burn bright! ✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: adding logger mock isolation to version-check tests to fix test pollution issues.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Comment @coderabbitai help to get the list of available commands and usage tips.

@utkarsh232005 utkarsh232005 merged commit 3abef46 into KDM-cli:main May 17, 2026
10 of 12 checks passed
@utkarsh232005 utkarsh232005 deleted the fix/test-pollution-version-check branch May 17, 2026 19:27
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants