bluesky-social / atproto

Social networking technology created by Bluesky
Other
6.88k stars 486 forks source link

Provide mock responses for APIs #3006

Open nzakas opened 1 week ago

nzakas commented 1 week ago

Is your feature request related to a problem? Please describe.

I'm using the AtpAgent class to make API calls to Bluesky, which works great. For testing purposes, I'd like to be able to mock out the API responses. I've read through all of the documentation and there isn't anywhere that gives complete example responses for the APIs. The best we get is stubs like this:

{
  "uri": "string",
  "cid": "string",
  "commit": {
    "cid": "string",
    "rev": "string"
  },
  "validationStatus": "valid"
}

However, because the AtpAgent is validating all responses, it's easy to create a response that doesn't pass validation and only throws a vague error message. This is really frustrating.

Describe the solution you'd like

Provide some clear, valid example responses for each API that can be used to mock out responses when using AtpAgent to make API calls. It would be helpful if this was exported as part of the @atproto/api package so they can be imported directly into tests.

Describe alternatives you've considered

Including full and valid responses in the API docs.

Additional context