Skip to content

Commit a43b66b

Browse files
authored
(sdks) Add new testing page (#961)
1 parent 3d0e8ae commit a43b66b

File tree

7 files changed

+57
-2
lines changed

7 files changed

+57
-2
lines changed

fern/docs.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,9 @@ redirects:
196196
- source: /learn/sdks/capabilities/idempotency-headers
197197
destination: /learn/sdks/deep-dives/idempotency
198198
permanent: true
199+
- source: /learn/sdks/capabilities/integration-tests
200+
destination: /learn/sdks/deep-dives/testing
201+
permanent: true
199202

200203
# SDK Package Managers redirects
201204
- source: /learn/sdks/package-managers/:slug*

fern/products/sdks/capabilities.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,8 @@ layout: overview
6060
<Card title="Server-Sent Events" icon="fa-duotone fa-broadcast-tower">
6161
Stream JSON data from your server to your client (i.e. chat completions)
6262
</Card>
63-
<Card title="Integration Tests" icon="fa-duotone fa-flask">
64-
Test your SDK against a mock server
63+
<Card title="Testing" icon="fa-duotone fa-flask" href="/sdks/deep-dives/testing">
64+
Auto-generated and handwritten tests to ensure your SDK works in production
6565
</Card>
6666
<Card title="Code Snippets" icon="fa-duotone fa-brackets-curly">
6767
No longer depend on manually written code snippets
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
---
2+
title: Testing
3+
description: Fern automatically generates unit tests and mock server tests for SDKs to ensure quality before release
4+
---
5+
6+
Fern provides comprehensive testing for your SDKs through generated and handwritten tests.
7+
8+
## Generated tests
9+
10+
<Markdown src="/snippets/pro-plan.mdx"/>
11+
12+
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.
13+
14+
### Unit tests
15+
16+
Fern generates unit tests for all SDK languages. They verify individual methods in isolation without making network calls.
17+
18+
### Mock server tests
19+
20+
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.
21+
22+
Mock server tests are available for TypeScript, Go, and Java. Configure mock server tests in your `generators.yml`:
23+
24+
| Language | Configuration | Default |
25+
|----------|---------------|---------|
26+
| TypeScript | [`generateWireTests`](/sdks/generators/typescript/configuration#generatewiretests) | true |
27+
| Go | [`enableWireTests`](/sdks/generators/go/configuration#enablewiretests) | false |
28+
| Java | [`enable-wire-tests`](/sdks/generators/java/configuration#enablewiretests) | false |
29+
30+
## Integration tests
31+
32+
<Markdown src="/snippets/enterprise-plan.mdx"/>
33+
34+
Handwritten integration tests run against your real API server to test end-to-end functionality with live data.
35+
36+
## Adding additional tests
37+
38+
You can add custom tests directly to your SDK repositories. Include test files in your `.fernignore` file to prevent overwrites during regeneration.

fern/products/sdks/overview/go/configuration.mdx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,10 @@ Specifies the name of the generated client struct. This determines the primary c
3636
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.
3737
</ParamField>
3838
39+
<ParamField path="enableWireTests" type="string" default="false" required={false} toc={true}>
40+
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.
41+
</ParamField>
42+
3943
<ParamField path="importPath" type="string" required={false} toc={true}>
4044
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.
4145

fern/products/sdks/overview/java/configuration.mdx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,10 @@ When enabled, generates inline types for nested schemas instead of creating sepa
6666
When enabled, generates public constructors for model types.
6767
</ParamField>
6868
69+
<ParamField path="enable-wire-tests" type="boolean" default="false" required={false} toc={true}>
70+
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.
71+
</ParamField>
72+
6973
<ParamField path="generate-unknown-as-json-node" type="boolean" default="false" required={false} toc={true}>
7074
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.
7175
</ParamField>

fern/products/sdks/overview/typescript/configuration.mdx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,10 @@ Choose whether you want to support Node.js 16 and above (`Node16`), or Node.js 1
172172
* `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`
173173
</ParamField>
174174

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

177181
Includes the content type and content length from binary responses. The user will receive an object of the following type:

fern/products/sdks/sdks.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,8 @@ navigation:
234234
- page: Self-hosted SDKs
235235
path: ./guides/self-hosted.mdx
236236
slug: self-hosted
237+
- page: Testing
238+
path: ./guides/testing.mdx
237239
- section: Reference
238240
contents:
239241
- page: generators.yml

0 commit comments

Comments
 (0)