Skip to content
FeedbackDashboard
Getting started

Test your SDKs

Learn about the tests Stainless generates for your SDKs and how and when they're run.

When you create or make changes to your SDKs, Stainless generates the following tests:

  • Unit tests for the core SDK client
  • Endpoint tests for each endpoint configured in your Stainless config file, including the following:
    • Synchronous and asynchronous request and response tests with only required parameters
    • Synchronous and asynchronous request and response tests with all parameters

Endpoint tests are run against a mock test server we create and run based on your OpenAPI spec.

When you make changes, we automatically spin up a mock test server based on your OpenAPI spec, confirm the mock server doesn’t fail validation, and run all enabled tests and linters, and validate responses.

By default, tests run automatically as part of our standard GitHub CI workflow. The workflow configuration is defined in the .github/workflows/ci.yml file inside your SDK’s repository, under the test section.

You can run tests and the mock test server locally, on demand, by running these scripts from the root of your SDK’s repository:

  • ./scripts/mock - Run the mock test server
  • ./scripts/test - Run tests (this script will start the mock test server for you if it’s not already running)

We recommend you add examples of how you want your users to use your SDKs in the ./examples directory inside each of your SDK repositories. Adding examples simplifies testing common use cases against your live API. Have a look at OpenAI’s TypeScript demo for a working example.

The ./examples directory is safe to use; Stainless won’t modify its content.