From 964a38db2cba225d4d4033cafafae91900182adf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=96mer=20Faruk=20Ayd=C4=B1n?= Date: Fri, 28 Oct 2022 20:07:31 +0200 Subject: [PATCH] chore: Add explanations to early exit conditions of global variable Co-authored-by: Ali BARIN --- packages/backend/src/helpers/global-variable.ts | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/packages/backend/src/helpers/global-variable.ts b/packages/backend/src/helpers/global-variable.ts index 0307591c..bd7bdfe9 100644 --- a/packages/backend/src/helpers/global-variable.ts +++ b/packages/backend/src/helpers/global-variable.ts @@ -73,16 +73,17 @@ const globalVariable = async ( }, }, pushTriggerItem: (triggerItem: ITriggerItem) => { - if ($.execution.testRun) { - $.triggerOutput.data.push(triggerItem); - throw new EarlyExitError(); - } - - if (isAlreadyProcessed(triggerItem.meta.internalId)) { + if (isAlreadyProcessed(triggerItem.meta.internalId) && !$.execution.testRun) { + // early exit as we do not want to process duplicate items in actual executions throw new EarlyExitError(); } $.triggerOutput.data.push(triggerItem); + + if ($.execution.testRun) { + // early exit after receiving one item as it is enough for test execution + throw new EarlyExitError(); + } }, setActionItem: (actionItem: IActionItem) => { $.actionOutput.data = actionItem;