Logo di Generate Tests

Generate Tests

Community
coco-research
generate-tests

Use when asked to generate tests for a file, module or component, to raise coverage, or to bootstrap a suite for untested code. Detects the project's test framework and conventions first, then writes unit, integration and edge-case tests.

Panoramica

Pubblicato dacoco-research
Repositorycoco
Nome della skillgenerate-tests
Stelle
550
Fork
12
File inclusi
Solo istruzioni
Link
  • Istruzioni in Markdown

    Un file SKILL.md che il modello carica quando serve, consumando token solo quando una richiesta è effettivamente pertinente.

  • Funziona con qualsiasi LLM

    Le skill IA sono in semplice Markdown, non in codice specifico di un fornitore, quindi funzionano con GPT, Claude, Gemini, Grok o un modello locale.

  • Tutto nelle istruzioni

    Tutto ciò che serve al modello è nelle istruzioni: nessun file aggiuntivo da sincronizzare.

  • Open source

    Pubblicata da coco-research su GitHub. Leggi i sorgenti prima di installarla.

Installazione

Installa la skill IA Generate Tests in TypingMind per usarla con qualsiasi LLM, oppure copiala in un altro agente in grado di leggere SKILL.md.

1

Installa in TypingMind

TypingMind installa una skill direttamente dalla sua cartella GitHub: legge SKILL.md, raccoglie i file delle risorse e salva il risultato in locale.

  1. Apri l'app e vai su Plugin → Skill.
  2. Scegli "Installa da GitHub".
  3. Incolla l'URL della cartella della skill riportato qui sotto e conferma.
    https://github.com/coco-research/coco/tree/main/skills/generate-tests
  4. Attiva la skill in ogni chat in cui vuoi averla a disposizione.
Plugin → Skill → Aggiungi skill → Da URL GitHub, poi incolla l'URL della cartella e premi Continua.
2

Installa in un altro agente

Qualsiasi agente che legge il formato Agent Skills può usare questa skill: copia la cartella della skill nella directory delle skill di quell'agente.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/coco-research/coco.git /tmp/coco
mkdir -p .claude/skills
cp -r /tmp/coco/skills/generate-tests .claude/skills/generate-tests
Dopo la copia, riavvia Claude Code per caricare la nuova skill.

Usala in TypingMind

Attiva Generate Tests in qualsiasi chat di TypingMind e al resto pensa il modello. Il nome e la descrizione della skill sono nel prompt di sistema e, non appena arriva una richiesta pertinente, il modello carica da solo le istruzioni complete: non devi mai richiamarla manualmente e non consuma token finché non viene effettivamente usata.

Il modello carica automaticamente Generate Tests non appena riceve una richiesta pertinente.

Funziona con qualsiasi modello IA

Le skill IA sono semplici istruzioni in Markdown, non codice specifico di un fornitore, quindi Generate Tests non è vincolata al modello per cui è stata scritta. Installala una sola volta in TypingMind e usala con GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama o un modello locale che esegui tu, sempre con le tue chiavi API.

  • Caricata solo quando serve

    Il prompt di sistema contiene solo il nome e la descrizione. Le istruzioni vengono recuperate alla prima richiesta pertinente, quindi una skill inutilizzata non costa nulla.

  • Cambia modello durante la chat

    Poiché la skill è composta da istruzioni e non da codice, continua a funzionare anche se cambi modello: il nuovo modello legge lo stesso file SKILL.md.

Istruzioni della skill

Questo è il contenuto di SKILL.md che il modello carica. Leggilo prima dell'installazione: una skill è un insieme di istruzioni che il tuo modello seguirà.

Generate Tests — Comprehensive Test Suite Generator

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.

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.


When This Skill Is Activated

Follow every step below. Do NOT generate tests without first analyzing the project's testing setup and the target code.


Step 1: Detect the Testing Setup

Before writing any tests, discover the project's testing conventions:

  1. Find the test framework — Check package.json (dependencies/scripts), or config files:

    • jest.config.* / jest key in package.json → Jest
    • vitest.config.* → Vitest
    • cypress.config.* → Cypress
    • playwright.config.* → Playwright
    • pytest.ini / pyproject.toml [tool.pytest] → pytest
    • go.mod → Go testing
    • Cargo.toml → Rust (#[cfg(test)])
  2. Find existing test files — Search for *.test.*, *.spec.*, test_*.py, *_test.go to understand naming conventions and patterns already in use.

  3. 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).

  4. 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.

Match the project's existing conventions exactly. File naming, import style, assertion style, describe/it vs test, etc.


Step 2: Analyze the Target Code

Read the file or component the user wants tested. Identify:

  • All exported functions, classes, methods, and components
  • Input types and return types (or infer them)
  • External dependencies (API calls, database, file system, third-party libs)
  • Side effects (mutations, network calls, timers, DOM manipulation)
  • Error paths (throw statements, catch blocks, error returns)
  • Edge cases (null/undefined inputs, empty arrays, boundary values, large inputs)
  • Async behavior (promises, callbacks, streams)

Step 3: Plan the Test Suite

Before writing code, outline what you'll test:

Unit Tests

  • Every exported function with representative inputs
  • Return values for happy path
  • Error handling for invalid inputs
  • Boundary values (0, -1, empty string, null, max int, etc.)
  • Type coercion edge cases if applicable

Integration Tests (if the code interacts with other modules)

  • Component interactions and data flow
  • API calls with mocked responses (success + failure)
  • Service layer with mocked dependencies
  • State management side effects

Edge Cases and Error Handling

  • Null, undefined, empty inputs
  • Malformed data
  • Network failures / timeouts
  • Concurrent access / race conditions
  • Extremely large inputs

Step 4: Write the Tests

Follow these principles:

Structure

describe("[ModuleName]", () => {
  describe("[functionName]", () => {
    it("should [expected behavior] when [condition]", () => {
      // Arrange
      // Act
      // Assert
    });
  });
});
  • Descriptive test names — Read like documentation: "should return empty array when input is null"
  • AAA pattern — Arrange (setup), Act (execute), Assert (verify). Separate each visually.
  • One assertion per concept — Multiple expect() calls are fine if they assert one logical thing
  • Group with describe — One block per function/method/component behavior
  • Setup/teardown — Use beforeEach/afterEach for test isolation. Clean up subscriptions, timers, mocks.

Mocking Strategy

  • Mock external dependencies only — Don't mock the code under test
  • Use the project's existing mock patterns (e.g., jest.mock(), vi.mock(), unittest.mock)
  • Create test data factories for complex objects instead of inline literals
  • Mock timers (jest.useFakeTimers() / vi.useFakeTimers()) for time-dependent code
  • Mock dates for deterministic snapshots
  • Always restore mocks in afterEach to prevent test pollution

Async Testing

  • Always await async functions or return the promise
  • Test both resolve and reject paths
  • Use waitFor / findBy for async UI updates (React Testing Library)
  • Test loading, success, and error states

Framework-Specific Guidance

FrameworkComponent TestingKey Patterns
ReactReact Testing Libraryrender(), screen.getByRole(), userEvent, waitFor
VueVue Test Utilsmount(), shallowMount(), wrapper.find(), trigger()
AngularTestBedTestBed.configureTestingModule(), fixture.detectChanges()
Node.jsSupertestrequest(app).get("/api/...").expect(200)
Pythonpytest@pytest.fixture, monkeypatch, parametrize
Gotestingt.Run(), table-driven tests, t.Parallel()

Step 5: Verify and Improve

After generating the tests:

  1. Run the tests — Execute the test suite to make sure they pass
  2. Check coverage — Identify untested lines or branches
  3. Add missing cases — Fill gaps in coverage, especially error paths
  4. Review test quality — Tests should fail when the code breaks, not just when the tests break

Coverage Goals

PriorityCoverage Target
Critical business logic90%+
Utility functions85%+
UI components80%+
Configuration/glue code60%+

Focus on branch coverage over line coverage — untested else and catch paths are where bugs hide.


Output Checklist

Before finishing, verify:

  • Tests follow the project's existing naming convention and file location
  • All exported functions/components have at least one test
  • Happy path tested for every function
  • Error/failure path tested for every function that can fail
  • Edge cases covered (null, empty, boundary values)
  • External dependencies are mocked (no real API calls, no real DB)
  • Async code is properly awaited
  • Mocks are cleaned up in afterEach
  • Tests are independent — can run in any order
  • Test names read like documentation

Domande frequenti

Cosa fa la skill IA Generate Tests?

Use when asked to generate tests for a file, module or component, to raise coverage, or to bootstrap a suite for untested code. Detects the project's test framework and conventions first, then writes unit, integration and edge-case tests.

Perché usare Generate Tests su TypingMind?

Perché la installi una volta e la usi con qualsiasi modello. Generate Tests è scritta in semplice Markdown anziché in codice specifico di un fornitore, quindi la stessa skill funziona con GPT-5, Claude, Gemini, Grok o un modello locale, e puoi cambiare modello durante la chat senza che la skill smetta di funzionare. TypingMind usa le tue chiavi API, quindi paghi direttamente i fornitori anziché un abbonamento per posto utente, e le tue skill e chat restano nel tuo spazio di archiviazione.

Come installo Generate Tests in TypingMind?

Apri Plugin → Skill → Installa da GitHub in TypingMind e incolla https://github.com/coco-research/coco/tree/main/skills/generate-tests. TypingMind legge il file SKILL.md e installa la skill, che puoi abilitare per ogni singola chat.

Quali modelli IA possono usare Generate Tests?

Qualsiasi modello che colleghi a TypingMind. Le skill IA sono semplici istruzioni in Markdown anziché codice specifico di un fornitore, quindi GPT, Claude, Gemini, Grok e i modelli locali possono tutti caricare questa skill quando una richiesta corrisponde al suo scopo.

Quanti modelli IA posso usare con Generate Tests?

Quanti ne vuoi. Se un modello supporta le skill, puoi usarlo con Generate Tests: GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama e molti altri, tutti su TypingMind con le tue chiavi API.

La skill IA Generate Tests è gratuita?

È pubblicata su GitHub da coco-research. Consulta il repository per i termini di licenza. Paghi solo il tuo fornitore IA per i token che usi.

Cosa sono le skill IA?

Una skill IA è un pacchetto di istruzioni riutilizzabili che insegna a un modello IA come svolgere un'attività specifica. Segue il formato aperto Agent Skills: un file SKILL.md con un nome e una descrizione, più eventuali script, template o file di riferimento di cui il modello potrebbe aver bisogno. Il modello legge le istruzioni solo quando la tua richiesta corrisponde alla skill, quindi una skill installata non comporta costi finché non viene usata.

In cosa si differenziano le skill IA dai plugin o dai server MCP?

Un plugin o un server MCP fornisce a un modello nuovi strumenti da richiamare: codice che viene eseguito da qualche parte e restituisce un risultato. Una skill IA, invece, fornisce al modello conoscenze e procedure: come affrontare un'attività, quali passaggi seguire e quali caratteristiche deve avere un buon output. Le skill sono semplici istruzioni in Markdown, quindi non richiedono server, chiavi API né ambienti di esecuzione e funzionano con qualsiasi modello.

Elenco completo

Crea subito il tuo spazio di lavoro AI

Iscriviti alla nostra newsletter per ricevere aggiornamenti sulle nuove funzionalità e sulle prossime iniziative a premi 👇