From fc269b65cae0e61e1538d7c432538093894bbe20 Mon Sep 17 00:00:00 2001 From: Jack Tomaszewski Date: Thu, 8 Apr 2021 08:58:57 +1000 Subject: [PATCH 1/2] docs: Add async/await example to README --- README.md | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/README.md b/README.md index 66330216..ef12e204 100644 --- a/README.md +++ b/README.md @@ -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. From ad699ede904816f62a0ecff9984e6c1284120cc0 Mon Sep 17 00:00:00 2001 From: Jack Tomaszewski Date: Sun, 18 Apr 2021 10:03:07 +0200 Subject: [PATCH 2/2] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index ef12e204..aed67ee4 100644 --- a/README.md +++ b/README.md @@ -130,7 +130,7 @@ Or async/await syntax: ```js describe('GET /users', function() { it('responds with json', async function() { - const response = request(app) + const response = await request(app) .get('/users') .set('Accept', 'application/json') expect(response.headers["Content-Type"]).toMatch(/json/);