openapi-to-cli / rules
Cursor rule263 starsChanged 3 months agoMITView on GitHub
Test conventions for openapi-to-cli (Jest)
Where files are headingNew Cursor rule files have more rules about planning and tracking tasks, and fewer about code style.
Of the Cursor rule files we read, the 1,533 first seen in the last six months, against the older ones: the kind of rule that gained most share, and the kind that lost most. About files like this in general, not this one, and an estimate, since a kind is a pattern in the words.
In this repository7 other files it gives its agents.
- AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- .cursor/rules/architecture.mdcCursor rule
- .cursor/rules/code-style.mdcCursor rule
- .cursor/rules/implementation-order.mdcCursor rule
- .cursor/rules/workflow.mdcCursor rule
- ocli-apiSkill
The file
We split this testing.mdc into the rules it gives an agent
4 rules. About 0 are common, 1 is distinctive, and 3 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈1
Distinctive · estimate
This author's own choices. Worth a look.
3
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 13
All tests live in tests/ alongside the matching src/ module.
- Very specific: line 14
Test files: tests/<module>.test.ts (one per src/<module>.ts).
- Very specific: line 21
Test names: it("does X when Y", ...) - describe behavior, not implementation.
- Distinctive: line 51
Add new spec fixtures only when an existing one cannot reproduce the case.
≈ “Common” is an estimate: at least 1 in 5 of the 3,030 Cursor rule files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
---
description: Test conventions for openapi-to-cli (Jest)
globs: tests/**/*.ts
alwaysApply: true
---
# 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
```bash
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`.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

