testing

A set of Jest testing rules for the openapi-to-cli project. Jest is a tool that runs automated JavaScript and TypeScript tests.

In plain words
What is it for?
Use it when adding or editing tests, especially tests for modules that turn OpenAPI or Swagger documents into command-line tools.
Why use it?
It keeps tests arranged and written consistently, making failures easier to understand and reducing accidental changes to shared test data.

Cursor rule for Cursor

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add rules/evilfreelancer/openapi-to-cli/testing
Clone the repo
git clone --depth 1 https://github.com/EvilFreelancer/openapi-to-cli

Made for: Cursor.

Per session 580 This file is loaded in full into every session.
When invoked 580 The same file — it is already loaded in full.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00580 $0.00580
Opus 5 $0.00290 $0.00290
Sonnet 5 $0.00116 $0.00116
Haiku 4.5 $0.00058 $0.00058

Measured yesterday against content hash 7b9f08e1f77a, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

testing scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured yesterday.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

.cursor/rules/testing.mdc · 53 lines

How it starts

The opening of the file, as written. The whole thing — 53 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Test conventions (Jest)

Applies when editing or adding files under tests/.

Layout

  • All tests live in tests/ alongside the matching src/ module.
  • Test files: tests/<module>.test.ts (one per src/<module>.ts).
  • Shared inputs in tests/fixtures/ (OpenAPI/Swagger documents, sample profiles). Recorded outputs in tests/results/.
  • github-api.test.ts and box-api-yaml.test.ts are large real-spec regression tests - do not hand-edit their fixtures.

Structure

  • Group with describe(<moduleName>, ...); one nested describe per public method or scenario.
  • Test names: it("does X when Y", ...) - describe behavior, not implementation.
  • Arrange / Act / Assert order inside each it. Blank lines between the three sections are encouraged.

Isolation

  • Each it is independent. Use beforeEach/afterEach for setup and teardown, not module-level mutable state.
  • Mock fs and axios (HttpClient) through the constructor options the modules expose. Do not monkey-patch the real fs/axios modules in tests.
  • For .ocli/ fixtures, use fs.mkdtempSync(os.tmpdir() + "/...") and clean up in afterEach.

Running

npm test                                # full Jest suite
npx jest tests/<file>.test.ts           # one file
npx jest tests/<file>.test.ts -t "X"    # one test by name

What to assert

  • Public behavior visible at the module boundary - return values, written files, requests issued via the mocked HttpClient, captured stdout.
  • For BM25 / command-search - assert ranking order and matched commands, not internal scores.
  • For openapi-to-commands - assert the resulting CliCommand[] structure (names, options, body schema), not intermediate spec normalization.

What not to assert

  • Internal helper signatures, private state, exact log strings - those are implementation details.
  • Floating-point BM25 scores beyond ranking order.

Fixtures

  • Add new spec fixtures only when an existing one cannot reproduce the case. Keep them minimal: one path, one operation, only the fields needed for the test.
  • For tests covering spec features (OAS 3 requestBody, Swagger 2 formData, multi-file $ref, header/cookie params), name the fixture after the feature, e.g. tests/fixtures/swagger2-formdata.yaml.

Read the full file on GitHub · 53 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. yesterday First seen · 53 lines · 580 tokens per session scan A 7b9f08e1f77a

Subscribe to this mod's changes

testing is a cursor rule published in the GitHub repository EvilFreelancer/openapi-to-cli (256 stars, last pushed 11d ago), licensed MIT. It adds 580 tokens to every session, about $0.0029 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.