Test

From mkurman/zorai · View interactive version

Test is an AI agent skill from the GitHub repository mkurman/zorai. Generate or run tests. Auto-detects test framework, generates comprehensive tests for source files, or runs existing test suites with failure analysis.

How to use this skill

Skill file

<objective>

Generate or run tests for the current project. This skill auto-detects the test framework in use, generates comprehensive tests for source files, or runs existing test suites and analyzes failures.

Accepts optional arguments:

</objective>

<context>

This skill handles test generation and execution across multiple languages and frameworks. It adapts to whatever testing conventions the project already uses rather than imposing new ones.

</context>

<quick_start>

<step_1_detect_framework>

Detect the test framework and conventions before doing anything else.

Check these sources in order:

  1. package.json (Node/JS/TS projects):
  1. Config files:
  1. Existing test files:
  1. Record your findings:

</step_1_detect_framework>

<step_2_handle_arguments>

Route based on the argument provided.

</step_2_handle_arguments>

<generate_tests>

Generate tests for the specified source file.

A. Read and analyze the source file:

B. Read existing test files in the project (1-2 files minimum):

C. Generate tests covering:

  1. Happy paths: Normal expected inputs produce correct outputs
  2. Edge cases:
  1. Error handling:
  1. Async behavior (if the function is async):
  1. Dependencies:

D. Place the test file correctly:

E. Run the generated tests immediately to verify they pass.

</generate_tests>

<run_tests>

Run the existing test suite and analyze results.

A. Determine the test command:

B. Run the tests:

C. Analyze results:

D. Present a summary:

Test Results: X passed, Y failed, Z skipped

Failures:
1. [test name] - [brief diagnosis]
   Fix: [specific suggestion]

2. [test name] - [brief diagnosis]
   Fix: [specific suggestion]

</run_tests>

<suggest_tests>

Suggest what to test when no arguments are given.

A. Check recent changes:

B. Check test coverage gaps:

C. Present suggestions:

Suggested files to test (based on recent changes and coverage gaps):

1. [file path] - modified recently, no test file exists
2. [file path] - modified recently, tests exist but may need updating
3. [file path] - no test coverage found

Run `/test <file path>` to generate tests for any of these.
Run `/test run` to run the existing test suite.

</suggest_tests>

</quick_start>

<critical_rules>

  1. MATCH EXISTING PATTERNS: Never impose a new test style. Always mirror what the project already does.
  2. READ BEFORE WRITING: Always read existing test files before generating new ones.
  3. VERIFY GENERATED TESTS: Always run generated tests. Untested test code is unreliable.
  4. DON'T MODIFY SOURCE CODE: If generated tests fail, fix the tests, not the source. If the source has a real bug, report it to the user.
  5. MOCK EXTERNAL DEPENDENCIES: Never let tests hit real APIs, databases, or file systems unless the project explicitly uses integration tests that way.
  6. ONE FILE AT A TIME: Generate tests for one source file per invocation. Keep scope manageable.
  7. USE PROJECT DEPENDENCIES: Only use test libraries already installed in the project. Do not add new dependencies without asking.

</critical_rules>

<success_criteria>

Before completing:

</success_criteria>

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.