From ab5cae6f8d61859e9b119603c58249acac06f9ec Mon Sep 17 00:00:00 2001 From: Muthu Kumar Date: Mon, 6 Aug 2018 09:33:56 +0530 Subject: [PATCH] [docs] Added examples for async tests --- README.md | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/README.md b/README.md index f49cd2f..30f48a5 100644 --- a/README.md +++ b/README.md @@ -54,7 +54,11 @@ gunner.test('sum should equal 3', expect => { const sum = 1 + 2; return expect(sum).equal(3); }); +``` + +Expecting multiple results: +```JavaScript gunner.test('multiple expects should be true', expect => { const a = 1 + 2; const b = 'Hello World'; @@ -66,6 +70,22 @@ gunner.test('multiple expects should be true', expect => { }); ``` +Asynchronous tests: + +```JavaScript +gunner.test('asynchronous test', async expect => { + + const response = await axios.post(url, request); + const userObject = await db.find('userdetails', { username }); + + return [ + expect(response.status).equal(200); + expect(userObject).deepEquals(testUser); + ]; + +}) +``` + ### Gunner#run Starts running Gunner tests. Takes an options object as optional parameter.