Fastapi testing
Skill dkmqflx/fastapi-best-practices-plugin/plugins/fastapi-best-practices/skills/fastapi-testing
FastAPI testing best practices. Use when writing or reviewing tests for a FastAPI app — TestClient, dependency_overrides, async httpx clients. Triggers on TestClient, AsyncClient, ASGITransport, dependency_overrides, or pytest test files for FastAPI endpoints.From its SKILL.md
npx -y skills add dkmqflx/fastapi-best-practices-plugin --skill fastapi-testingAssembled from the repository path, not quoted from the project. Check it against their README if it does not work.
One thing to look at
- 1 stars1 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.
What its file declares
Copied from the file, not written here
The file declares its own license as MIT. That is the author’s claim about this one file, and it is not the same thing as the license GitHub reports for the repository, which is listed with the other numbers below.
SKILL.md
1.8 KB, 339 tokens by cl100k_base, as published. Nobody here has run it
FastAPI Testing
Best practices for testing FastAPI applications, following the official testing docs
(https://fastapi.tiangolo.com/tutorial/testing/). Covers exercising endpoints through
real HTTP semantics via TestClient/AsyncClient, and swapping dependencies safely
with dependency_overrides. Each rule pairs an antipattern with the idiomatic pytest
pattern.
When to Apply
Reference these guidelines when:
- Writing tests for FastAPI path operations
- Swapping a dependency (DB session, auth, external client) for a test double
- Writing async tests against an ASGI app without a running server
- Reviewing or refactoring an existing FastAPI test suite
Rules
testclient(HIGH) — test endpoints throughfastapi.testclient.TestClient(real HTTP, in-process)dependency-overrides(HIGH) — swap deps withapp.dependency_overrides, not monkeypatchasync-client(MEDIUM) — use httpxAsyncClient+ASGITransportfor async tests
How to Use
Read the individual rule file for the detailed explanation and before/after example:
rules/testclient.md
rules/dependency-overrides.md
rules/async-client.md
Each rule file contains:
- A short explanation of why it matters, tied to the official docs
- An Incorrect example (the antipattern)
- A Correct example (the official pattern)
- A link to the relevant page on https://fastapi.tiangolo.com/
All examples follow the official FastAPI documentation and avoid deprecated APIs.
What ships with it: 3 files
4.0 KB alongside SKILL.md
rules/
- async-client.md1.3 KB
- dependency-overrides.md1.3 KB
- testclient.md1.4 KB