Testing Frameworks in CLI-Anything: Pytest and Jest Configuration Guide

CLI-Anything uses pytest for Python components and Jest for JavaScript/TypeScript modules, with configuration files located in QGIS/agent-harness/ and sketch/agent-harness/ respectively.

The HKUDS/CLI-Anything repository employs a polyglot testing strategy that aligns with its multilingual codebase architecture. When examining which testing frameworks CLI-Anything relies on, the source code reveals a clean separation: pytest handles all Python-based agent harnesses and utilities, while Jest manages the JavaScript and TypeScript extension modules. This dual-framework approach ensures comprehensive coverage across the project's diverse technology stack.

Python Testing with Pytest

CLI-Anything leverages pytest as the exclusive testing framework for Python components. The repository follows standard Python testing conventions, utilizing configuration files and conventional test_ prefixed functions for discovery.

Configuration and Setup

The Python test configuration resides in QGIS/agent-harness/pytest.ini. This configuration file establishes test discovery patterns, execution parameters, and environment settings specific to the QGIS agent harness component. Pytest uses this file to identify which directories contain test modules and how to handle import paths.

Example Test Implementation

Python test modules follow pytest's standard naming conventions with def test_* functions. In macrocli/agent-harness/cli_anything/macrocli/tests/test_core.py, utility functions are validated through simple assertion patterns:


# macrocli/agent-harness/cli_anything/macrocli/tests/test_core.py

def test_expand_repl_aliases():
    """Verify that REPL alias expansion works as expected."""
    from cli_anything.macrocli.utils.repl_skin import expand_aliases

    assert expand_aliases("!!") == "history -n 10"
    assert expand_aliases("!ls") == "ls -la"

Running Python Tests

Execute the Python test suite by invoking pytest from the repository root and specifying the target test file or directory:

pytest macrocli/agent-harness/cli_anything/macrocli/tests/test_core.py

This command runs the specific test module containing REPL alias validation logic.

JavaScript and TypeScript Testing with Jest

For Node.js components and browser extensions, CLI-Anything utilizes Jest as its test runner. The framework handles TypeScript compilation and provides coverage for sketch modules and VS Code extensions.

Package Configuration

Jest configuration lives within sketch/agent-harness/package.json, where "jest" appears explicitly in devDependencies. The scripts section defines a "test" entry that executes Jest with verbose output, ensuring consistent test runs across different development environments.

Writing Jest Tests

TypeScript tests follow Jest's standard test() and expect() syntax patterns. The extension tests in .pi-extension/cli-anything/tests/test_extension.test.ts demonstrate unit testing for mathematical utilities:

// .pi-extension/cli-anything/tests/test_extension.test.ts
import { sum } from '../src/math';

test('adds two numbers correctly', () => {
  expect(sum(2, 3)).toBe(5);
});

Executing Jest Tests

Run the JavaScript/TypeScript test suite using the npm test command from the appropriate directory:

npm test   # Executes: jest --verbose

This command triggers Jest to discover and execute all *.test.ts files within the test directories.

Key Testing Files and Locations

CLI-Anything organizes its testing infrastructure in language-specific directories:

Summary

  • pytest exclusively handles Python testing in CLI-Anything, configured via pytest.ini in the QGIS agent harness directory
  • Jest manages all JavaScript and TypeScript testing through package.json in the sketch agent harness
  • Python tests follow standard test_ naming conventions in macrocli/agent-harness/cli_anything/macrocli/tests/
  • TypeScript extension tests use .test.ts suffixes and reside in .pi-extension/cli-anything/tests/
  • No alternative test runners like Mocha, Nose, or Vitest appear in the repository configuration

Frequently Asked Questions

What testing frameworks does CLI-Anything use?

CLI-Anything uses pytest for Python components and Jest for JavaScript/TypeScript modules. According to the HKUDS/CLI-Anything source code, pytest handles the QGIS and macrocli Python logic, while Jest manages the sketch and extension TypeScript codebases. No other testing frameworks are implemented in the repository.

How do I run the Python tests in CLI-Anything?

Execute Python tests by running pytest from the repository root and specifying the path to the test file. For example, pytest macrocli/agent-harness/cli_anything/macrocli/tests/test_core.py runs the core utility tests. Ensure pytest is installed in your virtual environment and that the pytest.ini configuration file is present in the QGIS/agent-harness/ directory.

Where is the Jest configuration located in CLI-Anything?

The Jest configuration resides in sketch/agent-harness/package.json, which declares Jest as a devDependency and defines the test script command. Individual TypeScript test files use the .test.ts extension and are located in directories like .pi-extension/cli-anything/tests/. Running npm test from the sketch directory executes the Jest suite.

Does CLI-Anything use any other testing frameworks besides pytest and Jest?

No. The repository relies exclusively on pytest for Python testing and Jest for JavaScript/TypeScript testing. Source code analysis of the configuration files reveals no evidence of Mocha, Nose, Vitest, or other alternative test runners in the codebase.

Have a question about this repo?

These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:

Share the following with your agent to get started:
curl -s "https://instagit.com/install.md"

Works with
Claude Codex Cursor VS Code OpenClaw Any MCP Client

Maintain an open-source project? Get it listed too →