From c305b409bfaf28d58ddc7cd74b7a63b4d26562f1 Mon Sep 17 00:00:00 2001 From: Matthew J Martin <19975+matmar10@users.noreply.github.com> Date: Wed, 10 Nov 2021 00:32:38 -0500 Subject: [PATCH] feat: allow use of suite context & args inside loop --- lib/suite.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/suite.js b/lib/suite.js index 6fd44fb..6e26d5c 100644 --- a/lib/suite.js +++ b/lib/suite.js @@ -412,20 +412,22 @@ export default class Suite extends EventEmitter { let loopItems; let LoopItemsBuilderError = customError('LoopItemsBuilderError'); + let _context = { suite: this.userContext, runSpec: this.runDependencySpec, _sctx: this }; + try { if (loopData.type === 'static') { loopItems = loopData.static; } else if (loopData.type === 'dynamic') { if (loopData.dynamic.run_type === 'inline') { let inlineFunction = loopData.dynamic.inline.function; - let inlineResult = await runInlineFunction(inlineFunction); + let inlineResult = await runInlineFunction(inlineFunction, _context, loopData.dynamic.inline.args || []); loopItems = inlineResult; } else if (loopData.dynamic.run_type === 'module') { let modulePath = this.resolveFile(loopData.dynamic.module.module_path); const module = assertFileValidity(modulePath, 'Loop data module'); const customModule = loadModule(module); - let moduleResult = await runModuleFunction(customModule, loopData.dynamic.module.function_name); + let moduleResult = await runModuleFunction(customModule, loopData.dynamic.module.function_name, _context, loopData.dynamic.module.args || []); loopItems = moduleResult; } else { throw new InvalidYAMLSuiteSchemaError(`Loop dynamic run_type should be either inline or module`);