{"uid":"cap_euGT_36GtsQHZvmnrdEyr","slug":"test-generator-for-code-snippets-3f0f3c6f","name":"Test Generator for Code Snippets","description":"Generate tests for a code snippet (matches file's existing test framework).","url":"https://linked-aimed-reproduced-changing.trycloudflare.com/v1/coder/test-gen?utm_source=zero.xyz","method":"POST","headers":{},"bodySchema":{"type":"object","properties":{"usage":{"type":"object"},"choices":{"type":"array"}}},"responseSchema":null,"example":null,"exampleRequest":null,"tags":["x402"],"displayCostAmount":"0.03","displayCostAsset":"USDC","priceDynamic":false,"priceHint":null,"priceStatus":"priced","priceSource":"probe","requiresHandshake":false,"reviewCount":0,"rating":{"score":"0.00","successRate":"0.00","reviews":0,"stars":null,"state":"unrated"},"availabilityStatus":"unknown","priceObserved":null,"sessionDeposit":null,"pricing":{"kind":"static","summary":"$0.03/call","primary":{"kind":"static","protocol":"x402","network":"base","amountUsd":"0.03","per":"call","confidence":"exact"},"accepted":[{"kind":"static","protocol":"x402","network":"base","amountUsd":"0.03","per":"call","confidence":"exact"}]},"paymentMethods":[{"uid":"pm_fG1rGL-8B6tQ-vDphWOKh","protocol":"x402","methodType":"crypto","chain":"base","mode":"charge","costAmount":"0.03","costPer":"request","priority":0,"asset":"0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913","unit":"request","depositMicros":null,"planRef":null}],"brandName":null,"brandSlug":null,"brandBaseUrl":null,"brandDocsUrl":null,"whatItDoes":"Generates unit tests for a given code snippet, automatically matching the file's existing test framework.","exampleAgentPrompt":"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; }`?","exampleUseCases":[{"title":"Scaffold pytest tests for Python function","prompt":"Here's a Python function I just wrote — can you generate pytest unit tests for it that match my existing test file style?\n\n```python\ndef calculate_discount(price, percent):\n    return price - (price * percent / 100)\n```"},{"title":"Generate Jest tests for React component","prompt":"I have a React component and my project uses Jest with React Testing Library — can you write unit tests for this snippet that fit that framework?\n\n```jsx\nfunction Button({ label, onClick }) { return <button onClick={onClick}>{label}</button>; }\n```"},{"title":"Auto-generate Go tests for utility function","prompt":"Can you generate Go unit tests for this utility function? My project uses the standard `testing` package, so make sure the tests match that style.\n\n```go\nfunc Clamp(val, min, max int) int { if val < min { return min }; if val > max { return max }; return val }\n```"}],"resultDescription":"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.","failureModes":["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"],"whenToPreferThis":"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.","instructions":null,"reviewSummary":null,"reviewSummaryHighlights":null,"reviewSummaryConcerns":null,"reviewSummaryGeneratedAt":null,"activationCount":0,"lastUsedAt":null,"lastSuccessfullyRanAt":null,"lastHealthCheckAt":"2026-10-12T18:43:47.696Z","isFirstParty":false,"canonicalSlug":"test-generator-for-code-snippets-3f0f3c6f"}