From fcb1fba374ed1ff9a4040c0d12f8b887f028a97c Mon Sep 17 00:00:00 2001 From: Nursoltan Saipolda Date: Sat, 3 Sep 2022 12:45:16 +0800 Subject: [PATCH] clean data before run test --- test/postman/newman.js | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/test/postman/newman.js b/test/postman/newman.js index 7f029d5..bd7881e 100644 --- a/test/postman/newman.js +++ b/test/postman/newman.js @@ -183,15 +183,17 @@ async function clearTestData () { /** * Run the postman tests. */ -apiTestLib.runTests(requests, require.resolve('./resource-api.postman_collection.json'), - require.resolve('./resource-api.postman_environment.json')).then(async () => { - logger.info('newman test completed!') - await clearTestData() -}).catch(async (err) => { - logger.logFullError(err) - - // Only calling the clean up function when it is not validation error. - if (err.name !== 'ValidationError') { +clearTestData().then(() => { + apiTestLib.runTests(requests, require.resolve('./resource-api.postman_collection.json'), + require.resolve('./resource-api.postman_environment.json')).then(async () => { + logger.info('newman test completed!') await clearTestData() - } + }).catch(async (err) => { + logger.logFullError(err) + + // Only calling the clean up function when it is not validation error. + if (err.name !== 'ValidationError') { + await clearTestData() + } + }) })