From f40714228c5e0cd609e0ff854f662707da28404b Mon Sep 17 00:00:00 2001 From: Vedanta Krishna Date: Tue, 31 Oct 2023 16:25:26 +0530 Subject: [PATCH] refactor: move the should skip execution check inside skip event handler --- CHANGELOG.yaml | 2 +- lib/runner/extensions/event.command.js | 7 +++---- lib/runner/extensions/item.command.js | 2 +- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.yaml b/CHANGELOG.yaml index db501966d..abf680252 100644 --- a/CHANGELOG.yaml +++ b/CHANGELOG.yaml @@ -1,6 +1,6 @@ master: new features: - - GH-1354 Added support for skipping execution through script + - GH-1354 Added support for skipping request execution through script 7.34.0: date: 2023-10-19 diff --git a/lib/runner/extensions/event.command.js b/lib/runner/extensions/event.command.js index 5fc86faec..1d3c03ec2 100644 --- a/lib/runner/extensions/event.command.js +++ b/lib/runner/extensions/event.command.js @@ -19,7 +19,7 @@ var _ = require('lodash'), EXECUTION_ASSERTION_EVENT_BASE = 'execution.assertion.', EXECUTION_ERROR_EVENT_BASE = 'execution.error.', EXECUTION_COOKIES_EVENT_BASE = 'execution.cookies.', - EXECUTION_SKIP_EVENT_BASE = 'execution.skip.', + EXECUTION_SKIP_REQUEST_EVENT_BASE = 'execution.skipRequest.', COOKIES_EVENT_STORE_ACTION = 'store', COOKIE_STORE_PUT_METHOD = 'putCookie', @@ -448,8 +448,9 @@ module.exports = { }.bind(this)); }.bind(this)); - this.host.on(EXECUTION_SKIP_EVENT_BASE + executionId, function () { + this.host.on(EXECUTION_SKIP_REQUEST_EVENT_BASE + executionId, function () { skippedExecutions.add(executionId); + shouldSkipExecution = true; }); // finally execute the script @@ -543,8 +544,6 @@ module.exports = { // now that this script is done executing, we trigger the event and move to the next script this.triggers.script(err || null, scriptCursor, result, script, event, item); - shouldSkipExecution = isExecutionSkipped(executionId); - // move to next script and pass on the results for accumulation next(((stopOnScriptError || abortOnError || stopOnFailure) && err) ? err : null, _.assign({ event, diff --git a/lib/runner/extensions/item.command.js b/lib/runner/extensions/item.command.js index 116c92ee5..d532b5161 100644 --- a/lib/runner/extensions/item.command.js +++ b/lib/runner/extensions/item.command.js @@ -166,7 +166,7 @@ module.exports = { if (shouldSkipExecution) { this.triggers.item(prereqExecutionError, coords, item); - return callback && callback.call(this, null, { + return callback && callback.call(this, prereqExecutionError, { prerequest: prereqExecutions }); }