Skip to content

Commit

Permalink
Merge pull request #713 from jtomaszewski/patch-1
Browse files Browse the repository at this point in the history
docs: Add async/await example to README
  • Loading branch information
niftylettuce authored Jan 5, 2022
2 parents a70c1a0 + ad699ed commit 70a3d00
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
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 = await 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 70a3d00

Please sign in to comment.