Przejdź do treści
Biblioteka skilli
Programowanie · Testowanie

api-test-writer

/api-test-writer

Pisze testy API w Playwright i TypeScript dla endpointu, z przypadkami pozytywnymi i negatywnymi według ustalonego układu katalogów.

Repozytorium
api-test-agent ↗
Licencja
MIT
Ostatnia zmiana repozytorium
10.11.2026

Ocena i bezpieczeństwo

100/ 100Klasa: dobry
Format25 / 25
Frontmatter z nazwą i opisem, poprawna nazwa, opis do 1024 znaków, nazwa zgodna z folderem.
Odkrywalność25 / 25
Opis mówi, kiedy użyć skilla, ma sensowną długość i jest w 3. osobie.
Treść35 / 35
Co najmniej 150 słów i do 500 linii, nagłówki, listy kroków, przykłady albo kod.
Higiena15 / 15
Bez zaślepek typu TODO, bez ścieżek Windows, z licencją.
Ryzykobrak sygnałów w skanie
Pliki w paczce
1
Skrypty
0
Komentarze HTML
0
Adresy URL w SKILL.md
0
Przestarzałość

Brak sygnałów. Repozytorium zmienione 10.11.2026, bez odwołań do wycofanych modeli i API.

Licencja

MIT, otwarta: można używać i zmieniać, z zachowaniem informacji o autorze.

Co robi i kiedy

Pisze testy API w Playwright i TypeScript dla endpointu, z przypadkami pozytywnymi i negatywnymi według ustalonego układu katalogów.

Oryginalny opis (EN)

Write or extend Playwright + TypeScript API tests for an endpoint in the project's folder layout (<resource>/<method>[-by-id]/functional.spec.ts, contract.spec.ts, scenarios.spec.ts; positive/negative as tags). Use when the user asks to write, add, cover or extend API tests for an endpoint, a user story or an OpenAPI operation, or to add negative / boundary / validation cases. Not for UI or E2E browser tests.

Jak działa

  1. 1. Folder layout (mandatory)
  2. 2. Before writing: read, do not assume
  3. 3. When negative cases are allowed
  4. 4. House rules for every test
  5. 5. Finish
Sekcje z nagłówków SKILL.md, w oryginale · 79 linii, 903 słów
Podgląd SKILL.md
---
name: api-test-writer
description: Write or extend Playwright + TypeScript API tests for an endpoint in the project's folder layout (<resource>/<method>[-by-id]/functional.spec.ts, contract.spec.ts, scenarios.spec.ts; positive/negative as tags). Use when the user asks to write, add, cover or extend API tests for an endpoint, a user story or an OpenAPI operation, or to add negative / boundary / validation cases. Not for UI or E2E browser tests.
---

# API test writer

Write API tests the way this project lays them out, from sources that can be shown, never from guesses.

## 1. Folder layout (mandatory)

One folder per resource, one folder per operation, one file per **suite type** (up to three):

```
tests/api/
  orders/                    ← static path segments joined with "-": /orders → orders, /admin/reset → admin-reset
    get/                     ← GET /orders
      functional.spec.ts
      contract.spec.ts
    get-by-id/               ← GET /orders/{orderId}: path ends with a parameter → "<method>-by-id"
      functional.spec.ts
      contract.spec.ts
    patch-by-id/
      functional.spec.ts
      contract.spec.ts
      scenarios.spec.ts      ← create → PATCH → read → cleanup lives here, under the action, not under create
  _support/                  ← shared: contract assertions, <resource>.resource.ts data helpers, api/ objects
```

- `functional.spec.ts`: the endpoint does its job: expected status and result; documented 404 / 401 as behavior.
- `contract.spec.ts`: conformance to OpenAPI: the returned status is documented and the body matches the schema; invalid input gets a documented rejection.
- `scenarios.spec.ts`: multi-request flows (CRUD lifecycle, business rules), in the folder of the operation under test.
- **Positive/negative is not a file**: tag every test `{ tag: '@positive' }` or `{ tag: '@negative' }`, and the describe block with its suite (`@functional`, `@contract`, `@scenario`).
- Create a file only when it gets at least one case; for a suite without cases tell the user why in one line.
- If a positive case is impossible (missing test data, unknown dependency), create only what is possible and state the blocker as a concrete question.
- Two operations that would land in the same folder: suffix the folder with the operationId.
- **Language** follows `API_TESTS_LANG` in `.env` (default TypeScript). For Python (pytest + requests) the same layout uses underscores and pytest names: `orders/get_by_id/test_functional.py`, `test_contract.py`, `test_scenarios.py`, polarity as `@pytest.mark.positive` / `@pytest.mark.negative`, an `__init__.py` in each folder, shared fixtures in `tests/api/conftest.py` (`api`, `anonymous_api`, `contract`, `<resource>`, `created_<resource>`), negative cases with `pytest.mark.parametrize`, cleanup in fixture teardown. Hand-written files: `test_functional_manual.py`.

## 2. Before writing: read, do not assume

1. Find the source of expectations: OpenAPI operation (request schema, documented responses, `links`), the user story, or the user's words. Quote it in a comment at the top of the file.
2. Read the project's existing `_support/` helpers, fixtures and one neighbouring test. Reuse them; do not create a second helper that does the same thing. Match naming and style.
3. If `api-test-agent` is installed, run `npx @testomut/api-test-agent generate <spec> --tests-dir tests/api` first and extend its output, rather than writing the same cases by hand. Hand-written cases go into separate files (e.g. `functional.manual.spec.ts`), because generated files are overwritten when the spec changes.

## 3. When negative cases are allowed

A negative case needs BOTH:

- a rule written down to break: `required`, `type`, `minLength/maxLength`, `minimum/maximum`, `enum`, `maxItems`, `additionalProperties: false`, `minProperties`, required query/path params, security;
- a documented rejection for that operation: `400`/`422`/`4XX` for validation, `404` for an unknown id, `401`/`403` for missing or foreign credentials.

No documented rejection → no negative case. Do not invent "should return 400" because it seems reasonable: ask the user, or note it as a spec gap.

Per case, break **exactly one** rule, starting from a valid payload. Name the case after the rule (`missing required field "name"`, `"price" below minimum 0`) and keep a `source` pointing to the schema location. Prefer a data-driven array + loop over copy-pasted tests.

Typical set per operation:
| Operation | Cases |
|---|---|
| POST / PUT / PATCH with body | each required field missing, wrong type per field, each min/max/length/enum bound ±1, unknown field, empty object if `minProperties` |
| GET with query params | wrong type, below minimum, above maximum, not in enum, required param missing |
| any `…/{id}` | non-existent id → documented 404 (uuid format → random uuid) |
| secured operation | no credentials → documented 401; other user's resource → documented 403 |

## 4. House rules for every test

- **Data:** create preconditions through the API with the documented example payload; never rely on pre-existing records unless the user says a fixed test dataset exists.
- **Cleanup:** delete what the test created in `finally` (or a fixture teardown), even when an assertion fails. A negative create test that the API wrongly accepted must delete the created record too.
- **Assertions:** check the documented status code AND the response contract (schema, content type), plus the business fact the test is about (same id returned, updated value persisted). `status 200` alone is not a test.
- **Isolation:** tests must pass with `fullyParallel: true`; no shared mutable state, no ordering between files.
- **No waits:** never `waitForTimeout`; poll with `expect.poll` only for documented eventual consistency.
- **Secrets:** credentials only from environment variables; never hard-code tokens, never log request bodies with personal data.
- **Assumptions:** anything asserted that the source does not state gets a `// ASSUMPTION:` comment and is listed for the reviewer.
- **Never** weaken or delete an assertion to make a test pass. A failing test against the documented contract is a finding: report it (status, endpoint, expected vs actual, quote of the spec).
- **Never** send write requests to an operation without known cleanup, or to production.

## 5. Finish

Tell the user, briefly:
- files created (paths) and the number of cases in each;
- which suite files were not created for an operation (no functional, contract or scenario case), and why;
- assumptions to confirm and blockers as precise questions;
- the command to run them: `npx playwright test tests/api/<resource>`.

Wersje

W bazie nie ma innych skilli o nazwie api-test-writer.

Migawka bazy z 13.11.2026 · wersja paczki f4d7e94a468d (skrót SHA-256 całej paczki)

Pobrania w ostatnich 30 dniach: 0 · ranking

Zgłoś problem z tym skillem: szkodliwa treść, błędny opis albo prośba autora o usunięcie.

Podobne skille

  • 100playwright-test-writer
    Pisze i rozszerza testy Playwright E2E dla strony lub funkcji, także przy poprawkach istniejących testów przeglądarkowych.
  • 90api-session
    Prowadzi sesję testów API: z specyfikacji OpenAPI tworzy testy Playwright-BDD, uruchamia je, zgłasza błędy i pisze raport.
  • 100test-cases
    Generuje pełny zestaw przypadków testowych z wymagania, historyjki lub opisu funkcji, z przypadkami granicznymi i walidacją skryptem.
  • 95e2e-test-writer
    Pisze testy end-to-end w Playwright ze wzorcem page object model dla przepływów użytkownika w przeglądarce.
  • 95write-tests
    Pisze testy jednostkowe w Vitest i testy E2E w Playwright według praktyk doświadczonych inżynierów testów, w tym pokrycie, przypadki brzegowe i brakujące asercje.
  • 100integration-tests
    Pisze testy integracyjne API z jednej specyfikacji OpenAPI albo testy E2E API z wielu specyfikacji: mapa zasobów i usług, scenariusze cyklu życia, łańcuchy, przejścia stanów i propagacja asynchroniczna, bez uruchamiania.

Uwagi i zgłoszenia

Wiadomość trafi do Bartosza Sokolińskiego. Adres e-mail jest potrzebny tylko do odpowiedzi. Szczegóły w polityce prywatności.