Fixing delay as it was causing test case to be inconsistent (triggering automation)

This commit is contained in:
mike12345567 2020-09-23 15:29:25 +01:00
parent e7be9dd698
commit d5112c82c6
1 changed files with 1 additions and 1 deletions

View File

@ -170,6 +170,7 @@ describe("/automations", () => {
expect(res.body.automation.name).toEqual(TEST_AUTOMATION.name) expect(res.body.automation.name).toEqual(TEST_AUTOMATION.name)
// wait for automation to complete in background // wait for automation to complete in background
for (let tries = 0; tries < MAX_RETRIES; tries++) { for (let tries = 0; tries < MAX_RETRIES; tries++) {
await delay(500)
let elements = await getAllFromModel(request, app._id, instance._id, model._id) let elements = await getAllFromModel(request, app._id, instance._id, model._id)
// don't test it unless there are values to test // don't test it unless there are values to test
if (elements.length === 1) { if (elements.length === 1) {
@ -178,7 +179,6 @@ describe("/automations", () => {
expect(elements[0].description).toEqual("TEST") expect(elements[0].description).toEqual("TEST")
return return
} }
await delay(500)
} }
throw "Failed to find the records" throw "Failed to find the records"
}) })