Skip to content

Commit 041d375

Browse files
committed
Sync open source content 🐝 (from 600699749ca5d08d5d8f5a66c8470c477ae11ec8)
1 parent c661ae3 commit 041d375

3 files changed

Lines changed: 36 additions & 0 deletions

File tree

β€Ždocs/sdks/sdk-contract-testing/bootstrapping-test-generation.mdxβ€Ž

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,15 @@ generation:
4848
tests:
4949
generateTests: true # Controls whether tests are generated during speakeasy run
5050
generateNewTests: true # Controls whether new tests are added for new operations
51+
skipResponseBodyAssertions: false # Controls whether response body assertions are included in generated tests
5152
```
5253
5354
The `generateTests` setting controls whether test generation is enabled when running [`speakeasy run`](/docs/speakeasy-reference/cli/run). When set to `true`, tests defined in the `.speakeasy/tests.arazzo.yaml` document will be generated. When set to `false`, tests won't be generated.
5455

5556
The `generateNewTests` setting controls whether new tests are automatically added to the `.speakeasy/tests.arazzo.yaml` document when new operations are found in the OpenAPI specification.
5657

58+
The `skipResponseBodyAssertions` setting controls whether generated tests include response body assertions. When set to `true`, generated tests omit all response body assertions while still asserting on status codes. This is useful when API response bodies are non-deterministic (e.g., dynamic data, timestamps, random IDs) or when using a test server or mock that doesn't return realistic response payloads. Defaults to `false`. This setting applies globally to all generated tests for the target with no per-operation override.
59+
5760
When enabling for the first time this will generate tests for all operations in the OpenAPI document.
5861
Then going forward it will only generate tests for any operations not already found in the `.speakeasy/tests.arazzo.yaml` file.
5962

β€Ždocs/sdks/sdk-contract-testing/customizing-sdk-tests.mdxβ€Ž

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,24 @@ workflows:
115115
Directly modifying SDK tests is not common, but it is possible to customize the actual content of an existing SDK test by modifying the `.speakeasy/tests.arazzo.yaml` file.
116116
To learn more about these kinds of modifications see [here](/docs/sdk-testing/api-contract-tests#writing-custom-end-to-end-tests).
117117

118+
## Skip response body assertions
119+
120+
To omit all response body assertions from generated tests, set the `skipResponseBodyAssertions` option to `true` in the `generation.tests` section of the [`.speakeasy/gen.yaml`](/docs/speakeasy-reference/generation/gen-yaml) file:
121+
122+
```yaml
123+
generation:
124+
tests:
125+
skipResponseBodyAssertions: true
126+
```
127+
128+
When enabled, generated tests still assert on status codes but do not assert on the shape or values of the response body. This is useful when:
129+
130+
- API response bodies are non-deterministic (e.g., dynamic data, timestamps, random IDs)
131+
- A test server or mock doesn't return realistic response payloads
132+
- SDK calls need to be verified as successful without brittle assertions on exact response content
133+
134+
This setting applies globally to all generated tests for the target. There is no per-operation override.
135+
118136
## Next Steps
119137
120138
- [Setup testing in GitHub Actions](/docs/sdk-testing/github-actions)

β€Ždocs/speakeasy-reference/generation/gen-yaml.mdxβ€Ž

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,21 @@ Changes the field name of the request body parameter from using a flattened requ
185185
requestBodyFieldName: body
186186
```
187187

188+
### tests
189+
190+
Configuration for SDK test generation. For more information about SDK testing, see the [SDK contract testing documentation](/docs/sdk-testing/bootstrapping-test-generation).
191+
192+
- `generateTests`: Controls whether tests are generated during [`speakeasy run`](/docs/speakeasy-reference/cli/run). Defaults to `false`.
193+
- `generateNewTests`: Controls whether new tests are automatically added for newly discovered operations. Defaults to `false`.
194+
- `skipResponseBodyAssertions`: When `true`, generated tests omit all response body assertions while still asserting on status codes. Useful when API response bodies are non-deterministic (e.g., dynamic data, timestamps, random IDs) or when using a test server or mock that doesn't return realistic response payloads. Defaults to `false`. Applies globally to all generated tests for the target with no per-operation override.
195+
196+
```yaml
197+
tests:
198+
generateTests: true
199+
generateNewTests: true
200+
skipResponseBodyAssertions: false
201+
```
202+
188203
### mockServer
189204

190205
Disables the generation and use of a mock HTTP server with generated tests.

0 commit comments

Comments
Β (0)