Skip to content

Commit 682f221

Browse files
authored
Merge pull request #282 from Polymarket/codex/testing-guidance-client-fixtures
docs: clarify client test fixture guidance
2 parents ac67184 + 7f26b7d commit 682f221

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

AGENTS.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,12 +115,14 @@
115115

116116
- Default client tests to integration-style coverage.
117117
- Do not mock API responses unless explicitly requested or unless mocking is necessary to isolate a boundary under test.
118-
- Never build local fake-client helpers by casting partial objects to `BaseClient` or `BaseSecureClient` and stubbing transport responses. Those fixtures can silently diverge from upstream behavior.
118+
- Never create client fixtures solely to satisfy an action signature. This includes casting partial objects to `BaseClient` or `BaseSecureClient`, and instantiating real clients with dummy environments, credentials, signers, or unrelated dependencies. A real client class backed by fabricated configuration is still a fake-client fixture when the behavior under test does not require the client.
119119
- Prove cross-boundary behavior such as request counts, caching, retries, and pagination in `packages/client/tests/integration` with real clients and live APIs. Observing the real network with a `fetch` spy is fine; replacing responses is not.
120120
- When stateful policy requires controlled time or failures, extract it behind a consumer-defined, domain-typed dependency seam and unit test that logic without clients, transports, responses, or wire-format fixtures.
121121
- For tests involving async iterators, especially integration tests, prefer idiomatic consumer usage such as `for await (...)` so the test reads like final SDK DX. Manual iterator calls like `iterator.next()` are acceptable in unit tests or narrow cases where they make the behavior materially easier to isolate or understand.
122122
- Add tests when they protect user-facing behavior, public API contracts, integration boundaries, or regressions that are likely to recur.
123123
- Do not add tests reflexively for every small implementation change. For narrow schema or mechanical changes, prefer existing broader coverage plus `typecheck` or build verification when that gives enough confidence.
124+
- Do not add production exports, dependency seams, or constructor-heavy setup solely to test a private schema or simple predicate.
125+
- Validation tests should protect a non-obvious public contract, cross-field rule, transformation, or demonstrated regression. Tests that merely repeat a literal Zod refinement or verify that a newly added error-union member is recognized are usually low signal.
124126
- Prefer extending an existing high-signal test suite over creating a new narrow unit-test file.
125127
- A good test should catch a plausible future regression, not just prove that the current diff works.
126128

0 commit comments

Comments
 (0)