Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions fern/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,9 @@ redirects:
- source: /learn/sdks/capabilities/idempotency-headers
destination: /learn/sdks/deep-dives/idempotency
permanent: true
- source: /learn/sdks/capabilities/integration-tests
destination: /learn/sdks/deep-dives/testing
permanent: true

# SDK Package Managers redirects
- source: /learn/sdks/package-managers/:slug*
Expand Down
4 changes: 2 additions & 2 deletions fern/products/sdks/capabilities.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ layout: overview
<Card title="Server-Sent Events" icon="fa-duotone fa-broadcast-tower">
Stream JSON data from your server to your client (i.e. chat completions)
</Card>
<Card title="Integration Tests" icon="fa-duotone fa-flask">
Test your SDK against a mock server
<Card title="Testing" icon="fa-duotone fa-flask" href="/sdks/deep-dives/testing">
Auto-generated and handwritten tests to ensure your SDK works in production
</Card>
<Card title="Code Snippets" icon="fa-duotone fa-brackets-curly">
No longer depend on manually written code snippets
Expand Down
38 changes: 38 additions & 0 deletions fern/products/sdks/guides/testing.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
---
title: Testing
description: Fern automatically generates unit tests and mock server tests for SDKs to ensure quality before release
---

Fern provides comprehensive testing for your SDKs through generated and handwritten tests.

## Generated tests

<Markdown src="/snippets/pro-plan.mdx"/>

Fern auto-generates tests that must pass before SDK release. Fern generates a GitHub workflow in each SDK repository that runs unit tests and any enabled mock server tests on every pull request, commit, and release.

### Unit tests

Fern generates unit tests for all SDK languages. They verify individual methods in isolation without making network calls.

### Mock server tests

Mock server (wire) tests run your SDK against a mock server generated from your API definition. They verify that the SDK sends HTTP requests and receives HTTP responses as expected. These tests are generated for all endpoints in a service.

Mock server tests are available for TypeScript, Go, and Java. Configure mock server tests in your `generators.yml`:

| Language | Configuration | Default |
|----------|---------------|---------|
| TypeScript | [`generateWireTests`](/sdks/generators/typescript/configuration#generatewiretests) | true |
| Go | [`enableWireTests`](/sdks/generators/go/configuration#enablewiretests) | false |
| Java | [`enable-wire-tests`](/sdks/generators/java/configuration#enablewiretests) | false |

## Integration tests

<Markdown src="/snippets/enterprise-plan.mdx"/>

Handwritten integration tests run against your real API server to test end-to-end functionality with live data.

## Adding additional tests

You can add custom tests directly to your SDK repositories. Include test files in your `.fernignore` file to prevent overwrites during regeneration.
4 changes: 4 additions & 0 deletions fern/products/sdks/overview/go/configuration.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ Specifies the name of the generated client struct. This determines the primary c
Sets the name of the exported client that will be used in code snippets and documentation examples. This is useful for customizing how the client appears in generated documentation.
</ParamField>

<ParamField path="enableWireTests" type="string" default="false" required={false} toc={true}>
When enabled, generates [mock server (wire) tests](/sdks/deep-dives/testing#mock-server-tests) to verify that the SDK sends and receives HTTP requests as expected.
</ParamField>

<ParamField path="importPath" type="string" required={false} toc={true}>
Use this option if you plan to depend on the generated Go SDK from within your project, and **not** depend on it as a separate, published Go module.

Expand Down
4 changes: 4 additions & 0 deletions fern/products/sdks/overview/java/configuration.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,10 @@ When enabled, generates inline types for nested schemas instead of creating sepa
When enabled, generates public constructors for model types.
</ParamField>

<ParamField path="enable-wire-tests" type="boolean" default="false" required={false} toc={true}>
When enabled, generates [mock server (wire) tests](/sdks/deep-dives/testing#mock-server-tests) to verify that the SDK sends and receives HTTP requests as expected.
</ParamField>

<ParamField path="generate-unknown-as-json-node" type="boolean" default="false" required={false} toc={true}>
When enabled, generates unknown or untyped properties as structured JSON objects instead of raw Object types. This provides better type safety and easier manipulation of dynamic JSON content while maintaining flexibility for unknown data structures.
</ParamField>
Expand Down
4 changes: 4 additions & 0 deletions fern/products/sdks/overview/typescript/configuration.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,10 @@ Choose whether you want to support Node.js 16 and above (`Node16`), or Node.js 1
* `Node18` uses the native FormData API, and accepts a wider range of types for file uploads, such as `Buffer`, `File`, `Blob`, `Readable`, `ReadableStream`, `ArrayBuffer`, and `Uint8Array`
</ParamField>

<ParamField path="generateWireTests" type="boolean" default="true" toc={true}>
Generates [mock server (wire) tests](/sdks/deep-dives/testing#mock-server-tests) to verify that the SDK sends and receives HTTP requests as expected.
</ParamField>

<ParamField path="includeContentHeadersOnFileDownloadResponse" type="boolean" toc={true}>

Includes the content type and content length from binary responses. The user will receive an object of the following type:
Expand Down
2 changes: 2 additions & 0 deletions fern/products/sdks/sdks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,8 @@ navigation:
- page: Self-hosted SDKs
path: ./guides/self-hosted.mdx
slug: self-hosted
- page: Testing
path: ./guides/testing.mdx
- section: Reference
contents:
- page: generators.yml
Expand Down