Integration Tests

Pro Feature

This feature is only available on paid plans. Please schedule a demo or email us to get started.

To make sure that your SDK works in production, Fern will auto-generate integration tests that run before release. The release will only take place if no tests fail.

What gets generated?

Fern will use your API Definition to generate a mock server that will be used in the integration tests. The mock server will assert that the SDK is making the correct requests.

By default, the mock server will use the examples specified in your API Definition. If no examples are specified, Fern will generate examples to the best of its ability.

Specifying examples in your API Definition is recommended to ensure so that you can control what data is used in the tests.

Fern will generate integration tests as part of your SDK. These integration tests will run against the mock server and assert validity of requests and responses.

The generated tests will use appropriate testing framework for the language:

  • Jest for JavaScript/TypeScript
  • Pytest for Python
  • JUnit for Java
  • RSpec for Ruby
  • NUnit for C#
  • The standard library for Go

Fern will generate a GitHub workflow that will run the integration tests on every pull request, commit and release.

GitHub Workflow

The `test` job runs the integration tests

Adding additional tests

If you would like to add additional tests, you can do so by committing them directly to the generated SDK repositories. Note that you will need to add the test files to your .fernignore file to prevent them from being overwritten by Fern.

1

Create tests/custom.test.ts

1 import { MyClient } from '../src';
2
3 describe('MyClient', () => {
4 it('should do something', async () => {
5 const client = new MyClient();
6 const response = await client.resource.get();
7 expect(response).toEqual({ something: 'something' });
8 });
9 });
2

Run your test

$yarn install
>yarn test tests/custom.test.ts
3

.fernignore your test file

1# Specify any files that shouldn't be modified by Fern
2
3tests/custom.test.ts
Built with