Skip to content

Commit 9e18f55

Browse files
committed
Create versions.mdx based on issue #267
1 parent ce7ce8c commit 9e18f55

File tree

1 file changed

+95
-0
lines changed

1 file changed

+95
-0
lines changed
Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
---
2+
title: "Integration Tests"
3+
description: "Automatically generate integration tests for your TypeScript SDK"
4+
---
5+
6+
## Overview
7+
8+
Integration tests are automatically generated when using version 1.2.4 or later of the TypeScript SDK generator. These tests validate your SDK's functionality by testing it against a mock server that implements your API specification.
9+
10+
<Note>
11+
Integration tests are currently supported for TypeScript and C# SDKs. Support for other languages is in development.
12+
</Note>
13+
14+
## Requirements
15+
16+
- Fern CLI version that supports SDK generator version 1.2.4 or later
17+
- TypeScript SDK generator version 1.2.4 or later (recommended: 1.5.0+)
18+
19+
## Updating Your Generator Version
20+
21+
To use integration tests, ensure you're using a recent version of the TypeScript SDK generator:
22+
23+
```yaml
24+
generators:
25+
- name: fernapi/fern-typescript-sdk
26+
version: 1.5.0
27+
output:
28+
location: local-file-system
29+
path: ../generated
30+
```
31+
32+
If you previously generated an SDK with an older version, you may need to update your Fern CLI:
33+
34+
```bash
35+
npm install -g fern-api
36+
```
37+
38+
## Generated Tests Structure
39+
40+
When you generate your SDK, Fern automatically creates integration tests in the `__test__` directory. These tests include:
41+
42+
- Base unit tests for core functionality
43+
- Integration tests that validate your API endpoints
44+
- A mock server implementation matching your API specification
45+
46+
## Running Integration Tests
47+
48+
1. Navigate to your generated SDK directory
49+
2. Install dependencies:
50+
```bash
51+
npm install
52+
```
53+
54+
3. Run the test suite:
55+
```bash
56+
npm test
57+
```
58+
59+
## Custom Tests
60+
61+
While Fern generates comprehensive integration tests automatically, you can add custom tests to cover specific use cases:
62+
63+
1. Create a new test file in the `__test__` directory
64+
2. Import your SDK client
65+
3. Write tests using your preferred testing framework (Jest is included by default)
66+
67+
Example custom test:
68+
69+
```typescript
70+
import { YourApiClient } from "../src";
71+
72+
describe("Custom API Tests", () => {
73+
const client = new YourApiClient({
74+
environment: "http://localhost:8080",
75+
});
76+
77+
test("custom endpoint behavior", async () => {
78+
const response = await client.yourEndpoint();
79+
expect(response).toBeDefined();
80+
});
81+
});
82+
```
83+
84+
## Troubleshooting
85+
86+
If you encounter issues with integration tests:
87+
88+
- Verify you're using TypeScript SDK generator version 1.2.4 or later
89+
- Ensure your Fern CLI is up to date
90+
- Check that your API specification is valid and complete
91+
- Review the mock server implementation for any configuration issues
92+
93+
<Note>
94+
The mock server uses your API specification to simulate responses. Ensure your specification accurately reflects your API's behavior for reliable test results.
95+
</Note>

0 commit comments

Comments
 (0)