Skip to content

Conversation

@abimaelmartell
Copy link
Member

@abimaelmartell abimaelmartell commented Jan 8, 2026

Summary

Adds comprehensive unit tests for CLI commands using Vitest. Tests verify that commands generate valid API calls and properly handle responses without making real API calls.

Changes

  • Added Vitest testing framework with configuration for Node.js environment
  • Created test utilities (src/__tests__/utils/mock-client.ts) for mocking the Firecrawl client
  • Added tests for scrape command covering:
    • API call parameter generation (formats, options, filters)
    • Response handling (success and error cases)
    • Type safety validation
  • Added tests for credit-usage command covering:
    • Fetch API call generation
    • Response parsing and error handling
    • Edge cases (null values, invalid JSON, etc.)

Key Features

No real API calls - All tests mock the Firecrawl client or fetch API
API call validation - Tests verify commands generate correct API parameters
Response handling - Tests ensure proper handling of success and error responses
Type safety - TypeScript ensures type correctness throughout

Testing

Run tests with:

Run tests once

pnpm test

Run tests in watch mode

pnpm test:watch

Run tests with UI

pnpm test:ui

@abimaelmartell abimaelmartell merged commit 2cde0ac into main Jan 8, 2026
1 check passed
@abimaelmartell abimaelmartell deleted the tests branch January 8, 2026 19:52
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