# Test Generator for Code Snippets

> Test Generator for Code Snippets is a paid API for AI agents from linked-aimed-reproduced-changing.trycloudflare.com, paid per call via x402, $0.03/call, status unknown (last checked 2026-10-12).

Generates unit tests for a given code snippet, automatically matching the file's existing test framework.

## Facts

- Endpoint: POST https://linked-aimed-reproduced-changing.trycloudflare.com/v1/coder/test-gen?utm_source=zero.xyz
- Price: $0.03/call
- Payment: x402
- Status: unknown
- Last checked: 2026-10-12
- Activations on Zero: 0
- Tags: x402
- Canonical page: https://www.zero.xyz/c/test-generator-for-code-snippets-3f0f3c6f
- Structured record (JSON): https://api.zero.xyz/v1/capabilities/cap_euGT_36GtsQHZvmnrdEyr

Status and success rate cover calls made through Zero and Zero's own probes. Third-party monitors may report differently.

## How to call it through Zero

Zero handles the 402 payment challenge and records the run. With the Zero CLI installed (`npm i -g @zeroxyz/cli`):

```sh
zero fetch --capability test-generator-for-code-snippets-3f0f3c6f -d '<json body>'
```

Example prompt: Can you generate unit tests for this JavaScript function that uses Jest — it should match the style of my existing test file: `function add(a, b) { return a + b; }`?

## When to prefer this

Choose this endpoint when you need to automatically scaffold tests for a specific code snippet and want the output to respect an existing test framework style rather than generating boilerplate from scratch. Ideal for developer agents, CI pipelines, or code review bots that need to add test coverage on-the-fly at $0.03 per call.

## Known failure modes

- Ambiguous or missing code snippet results in generic or incorrect tests
- Test framework cannot be detected from context, leading to a default or wrong framework being used
- Code snippet is too large or complex and output may be truncated
- Unsupported programming language returns an error or fallback response
- Malformed input schema returns a 400-level error

## How this service works

Generate tests for a code snippet (matches file's existing test framework).

## Output

Returns generated test code that matches the detected or specified test framework (e.g. Jest, pytest, Go testing, Mocha), including test function scaffolding, assertions, and edge-case coverage for the provided code snippet.

## Request schema (JSON Schema)

```json
{
 "type": "object",
 "properties": {
  "usage": {
   "type": "object"
  },
  "choices": {
   "type": "array"
  }
 }
}
```

## More

- Live health (JSON, refreshed every minute): https://www.zero.xyz/c/test-generator-for-code-snippets-3f0f3c6f/health.json
- [Zero catalog index](https://www.zero.xyz/llms.txt)
- [Other services from linked-aimed-reproduced-changing.trycloudflare.com](https://www.zero.xyz/host/linked-aimed-reproduced-changing.trycloudflare.com/llms.txt)
