Skip to content

test(cli): add list command tests and validate target edge cases - #7616

Merged
mldangelo merged 5 commits into
promptfoo:mainfrom
bishnubista:test/cli-list-and-validate-commands
Feb 12, 2026
Merged

mldangelo merged 5 commits into
promptfoo:mainfrom
bishnubista:test/cli-list-and-validate-commands

Conversation

@bishnubista

Copy link
Copy Markdown
Contributor

Summary

  • Add comprehensive test suite for the list command covering all three subcommands (evals, prompts, datasets)
  • Add edge case tests for the validate target command (missing args, config load failure, empty providers)

Test plan

  • TypeScript type checking passes
  • All 27 tests pass across both files
  • Biome lint clean
  • Full project build succeeds

🤖 Generated with Claude Code

Add comprehensive test coverage for the `list` command (evals, prompts,
datasets subcommands) and edge case tests for `validate target` command.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
@bishnubista
bishnubista marked this pull request as ready for review February 11, 2026 03:37

@promptfoo-scanner promptfoo-scanner Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

👍 All Clear

This PR adds test files for CLI list and validation commands. The changes are purely test code with mocked dependencies and no LLM-related functionality or data flows.

Minimum severity threshold: 🟡 Medium | To re-scan after changes, comment @promptfoo-scanner
Learn more


Was this helpful?  👍 Yes  |  👎 No 

@coderabbitai

coderabbitai Bot commented Feb 11, 2026

Copy link
Copy Markdown
Contributor
📝 Walkthrough

Walkthrough

Two test files are added to the codebase. The first introduces a comprehensive test suite for the list command, covering evals, prompts, and datasets subcommands across multiple modes including ids-only, non-interactive, and interactive with pagination. Extensive mocking is configured for logging, data models, UI components, and database utilities. The second file adds edge-case tests for the validate-provider-tests command, covering scenarios where target or config is missing, config loading fails, or no providers are present. Together, these additions contribute 472 lines of new test coverage without modifying production code.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the main changes: adding test suites for the list command and validate target edge cases.
Description check ✅ Passed The description clearly relates to the changeset, detailing test additions for list command subcommands and validate target edge cases.

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

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

No actionable comments were generated in the recent review. 🎉

🧹 Recent nitpick comments
test/commands/list.test.ts (1)

105-120: Add afterEach with vi.resetAllMocks() per coding guidelines.

The guideline requires mock cleanup in afterEach, not only in beforeEach. While vi.resetAllMocks() in beforeEach achieves similar isolation, adding an afterEach block ensures mocks are torn down immediately after each test — preventing stale state from leaking if a test is added later that relies on inter-test ordering.

Proposed fix

Add after the beforeEach block:

+  afterEach(() => {
+    vi.resetAllMocks();
+  });

And update the import on line 2:

-import { beforeEach, describe, expect, it, type Mock, vi } from 'vitest';
+import { afterEach, beforeEach, describe, expect, it, type Mock, vi } from 'vitest';

As per coding guidelines: "ALWAYS clean up mocks in afterEach using vi.resetAllMocks()".


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

bishnubista and others added 3 commits February 10, 2026 19:56
Add afterEach cleanup, error handling tests, and clarifying comments.
Simplify redundant mock factory defaults that were overridden in beforeEach.

Co-Authored-By: Claude Opus 4.6 <[email protected]>

@mldangelo mldangelo left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thank you for helping improve the test coverage @bishnubista!

@mldangelo
mldangelo merged commit bf798b8 into promptfoo:main Feb 12, 2026
37 checks passed
@bishnubista
bishnubista deleted the test/cli-list-and-validate-commands branch February 12, 2026 02:13
meSingh pushed a commit to meSingh/promptfoo that referenced this pull request Sep 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants