{"id":"3cda9895-9fa2-44fb-8050-427e89935197","shortId":"krtZgp","kind":"skill","title":"generate-tests","tagline":"Generate complete test coverage for any file, component, or module. Covers unit tests, integration tests, edge cases, error handling, and mocking — adapted to whatever testing framework the project uses.","description":"# Generate Tests — Comprehensive Test Suite Generator\n\nGenerate complete test coverage for any file, component, or module. Covers unit tests, integration tests, edge cases, error handling, and mocking — adapted to whatever testing framework the project uses.\n\n**Use when**: you want tests generated for a file or component, need to improve test coverage, want edge case coverage, need mocks for external dependencies, or want to bootstrap a test suite for untested code.\n\n---\n\n## When This Skill Is Activated\n\nFollow every step below. Do NOT generate tests without first analyzing the project's testing setup and the target code.\n\n---\n\n## Step 1: Detect the Testing Setup\n\nBefore writing any tests, discover the project's testing conventions:\n\n1. **Find the test framework** — Check `package.json` (dependencies/scripts), or config files:\n   - `jest.config.*` / `jest` key in `package.json` → Jest\n   - `vitest.config.*` → Vitest\n   - `cypress.config.*` → Cypress\n   - `playwright.config.*` → Playwright\n   - `pytest.ini` / `pyproject.toml` [tool.pytest] → pytest\n   - `go.mod` → Go testing\n   - `Cargo.toml` → Rust (#[cfg(test)])\n\n2. **Find existing test files** — Search for `*.test.*`, `*.spec.*`, `test_*.py`, `*_test.go` to understand naming conventions and patterns already in use.\n\n3. **Check for test utilities** — Look for shared helpers, factories, custom matchers, or mock setups the project already provides (e.g., `test/utils.ts`, `__mocks__/`, `conftest.py`).\n\n4. **Check the test script** — Read the `test` script in `package.json` (or equivalent) to understand how tests are run, what flags are used, and what coverage tool is configured.\n\n**Match the project's existing conventions exactly.** File naming, import style, assertion style, describe/it vs test, etc.\n\n---\n\n## Step 2: Analyze the Target Code\n\nRead the file or component the user wants tested. Identify:\n\n- All exported functions, classes, methods, and components\n- Input types and return types (or infer them)\n- External dependencies (API calls, database, file system, third-party libs)\n- Side effects (mutations, network calls, timers, DOM manipulation)\n- Error paths (throw statements, catch blocks, error returns)\n- Edge cases (null/undefined inputs, empty arrays, boundary values, large inputs)\n- Async behavior (promises, callbacks, streams)\n\n---\n\n## Step 3: Plan the Test Suite\n\nBefore writing code, outline what you'll test:\n\n### Unit Tests\n- Every exported function with representative inputs\n- Return values for happy path\n- Error handling for invalid inputs\n- Boundary values (0, -1, empty string, null, max int, etc.)\n- Type coercion edge cases if applicable\n\n### Integration Tests (if the code interacts with other modules)\n- Component interactions and data flow\n- API calls with mocked responses (success + failure)\n- Service layer with mocked dependencies\n- State management side effects\n\n### Edge Cases and Error Handling\n- Null, undefined, empty inputs\n- Malformed data\n- Network failures / timeouts\n- Concurrent access / race conditions\n- Extremely large inputs\n\n---\n\n## Step 4: Write the Tests\n\nFollow these principles:\n\n### Structure\n\n```\ndescribe(\"[ModuleName]\", () => {\n  describe(\"[functionName]\", () => {\n    it(\"should [expected behavior] when [condition]\", () => {\n      // Arrange\n      // Act\n      // Assert\n    });\n  });\n});\n```\n\n- **Descriptive test names** — Read like documentation: \"should return empty array when input is null\"\n- **AAA pattern** — Arrange (setup), Act (execute), Assert (verify). Separate each visually.\n- **One assertion per concept** — Multiple `expect()` calls are fine if they assert one logical thing\n- **Group with `describe`** — One block per function/method/component behavior\n- **Setup/teardown** — Use `beforeEach`/`afterEach` for test isolation. Clean up subscriptions, timers, mocks.\n\n### Mocking Strategy\n\n- Mock **external dependencies only** — Don't mock the code under test\n- Use the project's existing mock patterns (e.g., `jest.mock()`, `vi.mock()`, `unittest.mock`)\n- Create **test data factories** for complex objects instead of inline literals\n- Mock timers (`jest.useFakeTimers()` / `vi.useFakeTimers()`) for time-dependent code\n- Mock dates for deterministic snapshots\n- Always **restore mocks** in `afterEach` to prevent test pollution\n\n### Async Testing\n\n- Always `await` async functions or return the promise\n- Test both resolve and reject paths\n- Use `waitFor` / `findBy` for async UI updates (React Testing Library)\n- Test loading, success, and error states\n\n### Framework-Specific Guidance\n\n| Framework | Component Testing | Key Patterns |\n|-----------|------------------|--------------|\n| **React** | React Testing Library | `render()`, `screen.getByRole()`, `userEvent`, `waitFor` |\n| **Vue** | Vue Test Utils | `mount()`, `shallowMount()`, `wrapper.find()`, `trigger()` |\n| **Angular** | TestBed | `TestBed.configureTestingModule()`, `fixture.detectChanges()` |\n| **Node.js** | Supertest | `request(app).get(\"/api/...\").expect(200)` |\n| **Python** | pytest | `@pytest.fixture`, `monkeypatch`, parametrize |\n| **Go** | testing | `t.Run()`, table-driven tests, `t.Parallel()` |\n\n---\n\n## Step 5: Verify and Improve\n\nAfter generating the tests:\n\n1. **Run the tests** — Execute the test suite to make sure they pass\n2. **Check coverage** — Identify untested lines or branches\n3. **Add missing cases** — Fill gaps in coverage, especially error paths\n4. **Review test quality** — Tests should fail when the code breaks, not just when the tests break\n\n### Coverage Goals\n\n| Priority | Coverage Target |\n|----------|----------------|\n| Critical business logic | 90%+ |\n| Utility functions | 85%+ |\n| UI components | 80%+ |\n| Configuration/glue code | 60%+ |\n\nFocus on **branch coverage** over line coverage — untested `else` and `catch` paths are where bugs hide.\n\n---\n\n## Output Checklist\n\nBefore finishing, verify:\n\n- [ ] Tests follow the project's existing naming convention and file location\n- [ ] All exported functions/components have at least one test\n- [ ] Happy path tested for every function\n- [ ] Error/failure path tested for every function that can fail\n- [ ] Edge cases covered (null, empty, boundary values)\n- [ ] External dependencies are mocked (no real API calls, no real DB)\n- [ ] Async code is properly awaited\n- [ ] Mocks are cleaned up in afterEach\n- [ ] Tests are independent — can run in any order\n- [ ] Test names read like documentation","tags":["generate","tests","coco","rkz91","agent-skills","agents-md","ai-agents","claude-code","codex","cursor","developer-tools","llm-tools"],"capabilities":["skill","source-rkz91","skill-generate-tests","topic-agent-skills","topic-agents-md","topic-ai-agents","topic-claude-code","topic-codex","topic-cursor","topic-developer-tools","topic-llm-tools","topic-mcp","topic-pm-tools","topic-product-management","topic-productivity"],"categories":["coco"],"synonyms":[],"warnings":[],"endpointUrl":"https://skills.sh/rkz91/coco/generate-tests","protocol":"skill","transport":"skills-sh","auth":{"type":"none","details":{"cli":"npx skills add rkz91/coco","source_repo":"https://github.com/rkz91/coco","install_from":"skills.sh"}},"qualityScore":"0.453","qualityRationale":"deterministic score 0.45 from registry signals: · indexed on github topic:agent-skills · 7 github stars · SKILL.md body (6,415 chars)","verified":false,"liveness":"unknown","lastLivenessCheck":null,"agentReviews":{"count":0,"score_avg":null,"cost_usd_avg":null,"success_rate":null,"latency_p50_ms":null,"narrative_summary":null,"summary_updated_at":null},"enrichmentModel":"deterministic:skill-github:v1","enrichmentVersion":1,"enrichedAt":"2026-05-18T19:14:07.329Z","embedding":null,"createdAt":"2026-05-18T13:21:39.757Z","updatedAt":"2026-05-18T19:14:07.329Z","lastSeenAt":"2026-05-18T19:14:07.329Z","tsv":"'-1':376 '/api':646 '0':375 '1':129,144,671 '2':178,269,684 '200':648 '3':199,342,692 '4':222,441,703 '5':663 '60':737 '80':734 '85':731 '90':728 'aaa':476 'access':434 'act':460,480 'activ':107 'adapt':25,60 'add':693 'aftereach':513,575,821 'alreadi':196,216 'alway':571,582 'analyz':118,270 'angular':637 'api':301,403,806 'app':644 'applic':388 'arrang':459,478 'array':331,471 'assert':262,461,482,488,498 'async':336,580,584,600,811 'await':583,815 'beforeeach':512 'behavior':337,456,509 'block':323,506 'bootstrap':96 'boundari':332,373,798 'branch':691,740 'break':713,719 'bug':752 'busi':726 'call':302,314,404,493,807 'callback':339 'cargo.toml':174 'case':20,55,86,327,386,420,695,794 'catch':322,748 'cfg':176 'check':149,200,223,685 'checklist':755 'class':287 'clean':517,818 'code':102,127,273,349,393,532,565,712,736,812 'coercion':384 'complet':5,40 'complex':551 'compon':11,46,78,278,290,398,617,733 'comprehens':35 'concept':490 'concurr':433 'condit':436,458 'config':153 'configur':250 'configuration/glue':735 'conftest.py':221 'convent':143,193,256,766 'cover':14,49,795 'coverag':7,42,83,87,247,686,699,720,723,741,744 'creat':546 'critic':725 'custom':209 'cypress':164 'cypress.config':163 'data':401,429,548 'databas':303 'date':567 'db':810 'depend':92,300,414,526,564,801 'dependencies/scripts':151 'describ':449,451,504 'describe/it':264 'descript':462 'detect':130 'determinist':569 'discov':138 'document':467,834 'dom':316 'driven':659 'e.g':218,542 'edg':19,54,85,326,385,419,793 'effect':311,418 'els':746 'empti':330,377,426,470,797 'equival':234 'error':21,56,318,324,368,422,610,701 'error/failure':784 'especi':700 'etc':267,382 'everi':109,357,782,788 'exact':257 'execut':481,675 'exist':180,255,539,764 'expect':455,492,647 'export':285,358,771 'extern':91,299,525,800 'extrem':437 'factori':208,549 'fail':709,792 'failur':409,431 'file':10,45,76,154,182,258,276,304,768 'fill':696 'find':145,179 'findbi':598 'fine':495 'finish':757 'first':117 'fixture.detectchanges':640 'flag':242 'flow':402 'focus':738 'follow':108,445,760 'framework':29,64,148,613,616 'framework-specif':612 'function':286,359,585,730,783,789 'function/method/component':508 'functionnam':452 'functions/components':772 'gap':697 'generat':2,4,33,38,39,73,114,668 'generate-test':1 'get':645 'go':172,654 'go.mod':171 'goal':721 'group':502 'guidanc':615 'handl':22,57,369,423 'happi':366,778 'helper':207 'hide':753 'identifi':283,687 'import':260 'improv':81,666 'independ':824 'infer':297 'inlin':555 'input':291,329,335,362,372,427,439,473 'instead':553 'int':381 'integr':17,52,389 'interact':394,399 'invalid':371 'isol':516 'jest':156,160 'jest.config':155 'jest.mock':543 'jest.usefaketimers':559 'key':157,619 'larg':334,438 'layer':411 'least':775 'lib':309 'librari':605,624 'like':466,833 'line':689,743 'liter':556 'll':353 'load':607 'locat':769 'logic':500,727 'look':204 'make':680 'malform':428 'manag':416 'manipul':317 'match':251 'matcher':210 'max':380 'method':288 'miss':694 'mock':24,59,89,212,220,406,413,521,522,524,530,540,557,566,573,803,816 'modul':13,48,397 'modulenam':450 'monkeypatch':652 'mount':633 'multipl':491 'mutat':312 'name':192,259,464,765,831 'need':79,88 'network':313,430 'node.js':641 'null':379,424,475,796 'null/undefined':328 'object':552 'one':487,499,505,776 'order':829 'outlin':350 'output':754 'package.json':150,159,232 'parametr':653 'parti':308 'pass':683 'path':319,367,595,702,749,779,785 'pattern':195,477,541,620 'per':489,507 'plan':343 'playwright':166 'playwright.config':165 'pollut':579 'prevent':577 'principl':447 'prioriti':722 'project':31,66,120,140,215,253,537,762 'promis':338,589 'proper':814 'provid':217 'py':188 'pyproject.toml':168 'pytest':170,650 'pytest.fixture':651 'pytest.ini':167 'python':649 'qualiti':706 'race':435 'react':603,621,622 'read':227,274,465,832 'real':805,809 'reject':594 'render':625 'repres':361 'request':643 'resolv':592 'respons':407 'restor':572 'return':294,325,363,469,587 'review':704 'run':240,672,826 'rust':175 'screen.getbyrole':626 'script':226,230 'search':183 'separ':484 'servic':410 'setup':123,133,213,479 'setup/teardown':510 'shallowmount':634 'share':206 'side':310,417 'skill':105 'skill-generate-tests' 'snapshot':570 'source-rkz91' 'spec':186 'specif':614 'state':415,611 'statement':321 'step':110,128,268,341,440,662 'strategi':523 'stream':340 'string':378 'structur':448 'style':261,263 'subscript':519 'success':408,608 'suit':37,99,346,678 'supertest':642 'sure':681 'system':305 't.parallel':661 't.run':656 'tabl':658 'table-driven':657 'target':126,272,724 'test':3,6,16,18,28,34,36,41,51,53,63,72,82,98,115,122,132,137,142,147,173,177,181,185,187,202,225,229,238,266,282,345,354,356,390,444,463,515,534,547,578,581,590,604,606,618,623,631,655,660,670,674,677,705,707,718,759,777,780,786,822,830 'test.go':189 'test/utils.ts':219 'testb':638 'testbed.configuretestingmodule':639 'thing':501 'third':307 'third-parti':306 'throw':320 'time':563 'time-depend':562 'timeout':432 'timer':315,520,558 'tool':248 'tool.pytest':169 'topic-agent-skills' 'topic-agents-md' 'topic-ai-agents' 'topic-claude-code' 'topic-codex' 'topic-cursor' 'topic-developer-tools' 'topic-llm-tools' 'topic-mcp' 'topic-pm-tools' 'topic-product-management' 'topic-productivity' 'trigger':636 'type':292,295,383 'ui':601,732 'undefin':425 'understand':191,236 'unit':15,50,355 'unittest.mock':545 'untest':101,688,745 'updat':602 'use':32,67,68,198,244,511,535,596 'user':280 'userev':627 'util':203,632,729 'valu':333,364,374,799 'verifi':483,664,758 'vi.mock':544 'vi.usefaketimers':560 'visual':486 'vitest':162 'vitest.config':161 'vs':265 'vue':629,630 'waitfor':597,628 'want':71,84,94,281 'whatev':27,62 'without':116 'wrapper.find':635 'write':135,348,442","prices":[{"id":"79df21cd-165b-44f6-8f2e-5f314757d2af","listingId":"3cda9895-9fa2-44fb-8050-427e89935197","amountUsd":"0","unit":"free","nativeCurrency":null,"nativeAmount":null,"chain":null,"payTo":null,"paymentMethod":"skill-free","isPrimary":true,"details":{"org":"rkz91","category":"coco","install_from":"skills.sh"},"createdAt":"2026-05-18T13:21:39.757Z"}],"sources":[{"listingId":"3cda9895-9fa2-44fb-8050-427e89935197","source":"github","sourceId":"rkz91/coco/generate-tests","sourceUrl":"https://github.com/rkz91/coco/tree/main/skills/generate-tests","isPrimary":false,"firstSeenAt":"2026-05-18T13:21:39.757Z","lastSeenAt":"2026-05-18T19:14:07.329Z"}],"details":{"listingId":"3cda9895-9fa2-44fb-8050-427e89935197","quickStartSnippet":null,"exampleRequest":null,"exampleResponse":null,"schema":null,"openapiUrl":null,"agentsTxtUrl":null,"citations":[],"useCases":[],"bestFor":[],"notFor":[],"kindDetails":{"org":"rkz91","slug":"generate-tests","github":{"repo":"rkz91/coco","stars":7,"topics":["agent-skills","agents-md","ai","ai-agents","claude-code","codex","cursor","developer-tools","llm-tools","mcp","pm-tools","product-management","productivity","prompt-engineering","workflow-automation"],"license":"mit","html_url":"https://github.com/rkz91/coco","pushed_at":"2026-04-26T01:51:27Z","description":"Open-source library of AI superpowers — 59 skills, 34 commands, 10 agents + 24 GSD subagents, 3 system bundles. An entire team, wherever your AI lives. Vendor-neutral across Claude Code, Cursor, Codex, and any AGENTS.md tool.","skill_md_sha":"932ceb2aa00b295e19cae6a8a0cfc4df9d540bfa","skill_md_path":"skills/generate-tests/SKILL.md","default_branch":"main","skill_tree_url":"https://github.com/rkz91/coco/tree/main/skills/generate-tests"},"layout":"multi","source":"github","category":"coco","frontmatter":{"name":"generate-tests","description":"Generate complete test coverage for any file, component, or module. Covers unit tests, integration tests, edge cases, error handling, and mocking — adapted to whatever testing framework the project uses."},"skills_sh_url":"https://skills.sh/rkz91/coco/generate-tests"},"updatedAt":"2026-05-18T19:14:07.329Z"}}