Skip to content

Commit

Permalink
docs: Add async/await example to README
Browse files Browse the repository at this point in the history
  • Loading branch information
jtomaszewski committed Apr 7, 2021
1 parent 1bb8c66 commit fc269b6
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions README.md
Expand Up @@ -125,6 +125,21 @@ describe('GET /users', function() {
});
```

Or async/await syntax:

```js
describe('GET /users', function() {
it('responds with json', async function() {
const response = request(app)
.get('/users')
.set('Accept', 'application/json')
expect(response.headers["Content-Type"]).toMatch(/json/);
expect(response.status).toEqual(200);
expect(response.body.email).toEqual('foo@bar.com');
});
});
```

Expectations are run in the order of definition. This characteristic can be used
to modify the response body or headers before executing an assertion.

Expand Down

0 comments on commit fc269b6

Please sign in to comment.