Skip to content

Commit 70a3d00

Browse files
authored
Merge pull request #713 from jtomaszewski/patch-1
docs: Add async/await example to README
2 parents a70c1a0 + ad699ed commit 70a3d00

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

README.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,21 @@ describe('GET /users', function() {
125125
});
126126
```
127127

128+
Or async/await syntax:
129+
130+
```js
131+
describe('GET /users', function() {
132+
it('responds with json', async function() {
133+
const response = await request(app)
134+
.get('/users')
135+
.set('Accept', 'application/json')
136+
expect(response.headers["Content-Type"]).toMatch(/json/);
137+
expect(response.status).toEqual(200);
138+
expect(response.body.email).toEqual('[email protected]');
139+
});
140+
});
141+
```
142+
128143
Expectations are run in the order of definition. This characteristic can be used
129144
to modify the response body or headers before executing an assertion.
130145

0 commit comments

Comments
 (0)