Skip to content

Commit

Permalink
docs(http-api): add doc about debugging API tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Raphaël Benitte committed Jul 8, 2017
1 parent d0bf516 commit add6414
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
17 changes: 17 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ It's also the perfect companion for testing CLI applications built with commande
- [Using values issued by a previous request](#using-values-issued-by-a-previous-request)
- [Using cookies](#using-cookies)
- [Testing json response](#testing-json-response)
- [Debugging failing API tests](#debugging-failing-api-tests)
- [Type system](#type-system)
- [CLI testing](#cli-testing)
- [Running a simple command](#running-a-simple-command-and-checking-its-exit-code)
Expand Down Expand Up @@ -266,6 +267,22 @@ Available matchers are:
| `equal` | property must equal given value |
| `equals` | see `equal` |

#### Debugging failing API tests

When testing APIs using cucumber, we often faced situations were we didn't understand why a given test were failing.
The dirty fix was to add some nasty `console.log()` everywhere, that's why **veggies** provides helpers to dump response properties.

```gherkin
Scenario: Fetching something from the internets
When I GET http://whatever.io/things
And dump response body
And dump response headers
And dump response cookies
```

You'll now have the response body/headers/cookies dumped in your terminal.
You should disable those steps when the test is fixed as it can be noisy enough.

#### Type system

When testing json based APIs, which is a standard nowadays, you have to be aware of data types
Expand Down
17 changes: 17 additions & 0 deletions doc/README.tpl.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ It's also the perfect companion for testing CLI applications built with commande
- [Using values issued by a previous request](#using-values-issued-by-a-previous-request)
- [Using cookies](#using-cookies)
- [Testing json response](#testing-json-response)
- [Debugging failing API tests](#debugging-failing-api-tests)
- [Type system](#type-system)
- [CLI testing](#cli-testing)
- [Running a simple command](#running-a-simple-command-and-checking-its-exit-code)
Expand Down Expand Up @@ -270,6 +271,22 @@ Available matchers are:
| `equal` | property must equal given value |
| `equals` | see `equal` |

#### Debugging failing API tests

When testing APIs using cucumber, we often faced situations were we didn't understand why a given test were failing.
The dirty fix was to add some nasty `console.log()` everywhere, that's why **veggies** provides helpers to dump response properties.

```gherkin
Scenario: Fetching something from the internets
When I GET http://whatever.io/things
And dump response body
And dump response headers
And dump response cookies
```

You'll now have the response body/headers/cookies dumped in your terminal.
You should disable those steps when the test is fixed as it can be noisy enough.

#### Type system

When testing json based APIs, which is a standard nowadays, you have to be aware of data types
Expand Down

0 comments on commit add6414

Please sign in to comment.