Troubleshooting
Answers to the problems people run into most often.
The chain must end with End(). Without it the test is only described, never run, and nothing can fail.
No mock matched the outbound request. Add Debug() to the test to see each mock and the reason it was rejected. The usual causes are a different path or host, a header or query value that does not match, or a mock that already answered its call. See debugging a mismatch.
The code under test uses an http.Client with its own Transport, so it does not go through http.DefaultTransport. Pass that client to the test with HttpClient. See HTTP clients.
Mock paths, and header, query and form values, are unanchored regular expressions. Query("page", "1") matches page=10, and Get("http://users/api/user") matches /api/user/1234. Anchor them with ^ and $. See paths are regular expressions.
The mock has no Status. A mock response defaults to status code 0, so always set one.
Versions before v1.7.0 discard a query string written into the URL, as in Get("/articles?page=2"). Upgrade, or add the parameters with Query, QueryParams or QueryCollection. See query parameters.
Mocks replace http.DefaultTransport, which is shared by the whole process, so parallel tests overwrite each other's mocks. Remove t.Parallel(), or give each test its own client and pass it with HttpClient. See parallel tests.
JSON numbers decode as float64. Compare with float64(12345), not the integer 12345.
Present requires a non-empty value, so a field that is false, 0, "", null or an empty array counts as not present. Use Equal to check those values.
Delays are off by default. Add EnableMockResponseDelay() to the test. A delay also has no effect on a mock with Timeout(), and it does not trigger client timeouts. Use Timeout() for that. See failures and latency.
Bodies that are not valid JSON are compared exactly, so a trailing newline matters. JSON bodies are compared structurally and are not affected.
The recording driver records everything, including seed data. Seed through the unwrapped driver, or call recorder.Reset() before the test. See database interactions.
Getting help
Ask questions in #apitest on the Gophers Slack, and report bugs or request features on GitHub.