diff --git a/fern/products/sdks/overview/typescript/testing.mdx b/fern/products/sdks/overview/typescript/testing.mdx new file mode 100644 index 00000000..defae82b --- /dev/null +++ b/fern/products/sdks/overview/typescript/testing.mdx @@ -0,0 +1,97 @@ +--- +title: "Integration Tests" +description: "Test your SDK with auto-generated integration tests" +--- + +# Integration Tests + +Fern can automatically generate integration tests for your TypeScript SDK to verify that your client behaves correctly against a mock server. This feature helps ensure your SDK works as expected and maintains compatibility with your API specification. + +## Supported Generators + +Integration test generation is currently supported in: +- TypeScript SDK Generator (v1.2.4+) +- C# SDK Generator + + +We recommend using TypeScript SDK Generator v1.5.0 or later for the best experience with integration tests. + + +## Getting Started + +### Prerequisites + +- Fern CLI (latest version) +- Node.js 16+ +- npm or yarn +- TypeScript SDK Generator v1.2.4 or later + +### Updating Your Generator Version + +To use integration tests, ensure you're using a supported generator version: + +```yaml +generators: + - name: fernapi/fern-typescript-sdk + version: 1.5.0 + output: + location: local-file-system + path: ../generated/typescript +``` + + +If you're seeing version 1.0.0 or 1.0.1 selected automatically, update your Fern CLI to the latest version to access newer generator versions. + + +## Test Structure + +When you generate your SDK, Fern automatically creates: +1. A test directory with the basic test infrastructure +2. Integration tests based on your API specification +3. Stubs for custom tests + +The generated tests use a mock server to validate: +- Request/response handling +- Parameter serialization +- Error scenarios +- Authentication flows +- API endpoint behavior + +## Running Tests + +To run the integration tests: + +```bash +npm test +``` + +Or with yarn: + +```bash +yarn test +``` + +## Custom Tests + +While the auto-generated tests cover most common scenarios, you can add custom tests for specific use cases: + +```typescript +describe('Custom API Tests', () => { + it('should handle specific business logic', async () => { + const client = new YourApiClient(); + const response = await client.someEndpoint(); + expect(response).toBeDefined(); + }); +}); +``` + +## Best Practices + +1. Keep your generator version up to date for the latest testing features +2. Run tests before publishing SDK updates +3. Add custom tests for complex business logic +4. Use the mock server for consistent test behavior + + +Integration test support for additional SDK generators is under development. Check the Fern documentation for updates. + \ No newline at end of file diff --git a/fern/products/sdks/pages/testing/integration-tests.mdx b/fern/products/sdks/pages/testing/integration-tests.mdx new file mode 100644 index 00000000..9b1aece1 --- /dev/null +++ b/fern/products/sdks/pages/testing/integration-tests.mdx @@ -0,0 +1,105 @@ +--- +title: 'Integration Tests' +description: 'Testing your SDK against a mock server' +--- + +# Integration Tests + +Fern can automatically generate integration tests for your SDK to verify its functionality against a mock server. This feature ensures your SDK correctly implements your API specification. + +## Supported Languages + +Integration test generation is currently supported for: +- TypeScript (v1.2.4 and later, recommended v1.5.0+) +- C# + +Support for additional languages is in development. + +## Prerequisites + +- Fern CLI (latest version) +- Node.js 16+ +- npm or yarn +- TypeScript SDK generator v1.5.0+ for best results + +## Setting Up Integration Tests + +### 1. Update Your Generator Version + +In your `fern.config.json`, specify the generator version: + +```json +{ + "generators": { + "typescript": { + "version": "1.5.0" + } + } +} +``` + +### 2. Generate the SDK + +Run the Fern CLI to generate your SDK with integration tests: + +```bash +fern generate +``` + +### 3. Running Tests + +The generated tests will be in your SDK's test directory. Run them using your language's standard test runner: + +For TypeScript: +```bash +npm test +``` + +## What Gets Tested + +The generated integration tests verify: +- Request/response handling +- Parameter serialization +- Error handling +- Authentication flows +- Content type handling + + +The mock server automatically implements your API specification, allowing for comprehensive testing without hitting your actual API endpoints. + + +## Custom Tests + +While automatic tests cover most common scenarios, you can add custom tests to verify specific business logic or edge cases: + +```typescript +describe('Custom API Tests', () => { + it('should handle specific business case', async () => { + const client = new ApiClient(); + const response = await client.customEndpoint(); + expect(response).toBeDefined(); + }); +}); +``` + +## Best Practices + +- Keep your Fern CLI and generators up to date +- Run integration tests as part of your CI/CD pipeline +- Combine generated tests with custom tests for comprehensive coverage +- Review generated tests to understand expected API behavior + + +Always use a stable generator version in production. Test new generator versions in a development environment first. + + +## Troubleshooting + +If you encounter issues: + +1. Verify you're using a supported generator version +2. Ensure your API specification is valid +3. Check that all required dependencies are installed +4. Review the generator output for any error messages + +For additional help, reach out to the Fern team via the support channels. \ No newline at end of file diff --git a/fern/products/sdks/sdks.yml b/fern/products/sdks/sdks.yml index c771d752..aee3914c 100644 --- a/fern/products/sdks/sdks.yml +++ b/fern/products/sdks/sdks.yml @@ -18,6 +18,8 @@ navigation: slug: capabilities - link: Customer Showcase href: https://buildwithfern.com/showcase + - page: Testing + path: ./overview/typescript/testing.mdx - section: Generators contents: - section: TypeScript @@ -41,8 +43,6 @@ navigation: slug: custom-code - changelog: ./overview/typescript/changelog slug: changelog - # - link: Customer Showcase - # href: https://buildwithfern.com/showcase - section: Python contents: - page: Quickstart @@ -59,12 +59,10 @@ navigation: path: ./overview/python/publishing-to-pypi.mdx slug: publishing - page: Adding custom code - path: ./overview/python/custom-code.mdx + path: ./overview/python/custom-code.mdx slug: custom-code - changelog: ./overview/python/changelog slug: changelog - # - link: Customer Showcase - # href: https://buildwithfern.com/showcase - section: Go contents: - page: Quickstart @@ -81,12 +79,10 @@ navigation: path: ./overview/go/publishing-to-go-package-manager.mdx slug: publishing - page: Adding custom code - path: ./overview/go/custom-code.mdx + path: ./overview/go/custom-code.mdx slug: custom-code - changelog: ./overview/go/changelog slug: changelog - # - link: Customer Showcase - # href: https://buildwithfern.com/showcase - section: Java contents: - page: Quickstart @@ -107,8 +103,6 @@ navigation: slug: custom-code - changelog: ./overview/java/changelog slug: changelog - # - link: Customer Showcase - # href: https://buildwithfern.com/showcase - section: .NET slug: csharp contents: @@ -131,8 +125,6 @@ navigation: slug: custom-code - changelog: ./overview/csharp/changelog slug: changelog - # - link: Customer Showcase - # href: https://buildwithfern.com/showcase - section: PHP contents: - page: Quickstart @@ -154,8 +146,6 @@ navigation: slug: custom-code - changelog: ./overview/php/changelog slug: changelog - # - link: Customer Showcase - # href: https://buildwithfern.com/showcase - section: Ruby contents: - page: Quickstart @@ -177,13 +167,11 @@ navigation: slug: custom-code - changelog: ./overview/ruby/changelog slug: changelog - # - link: Customer Showcase - # href: https://buildwithfern.com/showcase - page: MCP Server path: ./overview/mcp-server/introduction.mdx slug: mcp-server - section: Deep Dives - contents: + contents: - page: Customize Method Names path: ./guides/customize-method-names.mdx slug: customize-method-names @@ -207,7 +195,7 @@ navigation: path: ./guides/self-host-fern-generators.mdx slug: self-host-generators - section: Reference - contents: + contents: - page: generators.yml path: ./reference/generators-yml-reference.mdx slug: generators-yml