MCPcopy
hub / github.com/codeceptjs/CodeceptJS / prepareStep

Function prepareStep

lib/els.js:140–161  ·  view source on GitHub ↗
(purpose, locator, fn)

Source from the content-addressed store, hash-verified

138}
139
140function prepareStep(purpose, locator, fn) {
141 if (store.dryRun) return
142 const helpers = Object.values(container.helpers())
143
144 const helper = helpers.filter(h => !!h._locate)[0]
145
146 if (!helper) {
147 throw new Error('No helper enabled with _locate method with returns a list of elements.')
148 }
149
150 if (!isAsyncFunction(fn)) {
151 throw new Error('Async function should be passed into each element')
152 }
153
154 const isAssertion = purpose.startsWith('expect')
155
156 const step = new FuncStep(`${purpose} within "${locator}" ${isAssertion ? 'to be' : 'to'}`)
157 step.setHelper(helper)
158 step.setArguments([humanizeFunction(fn)]) // user defined function is a passed argument
159
160 return step
161}
162
163async function executeStep(step, action, stepConfig = {}) {
164 step.setCallable(action)

Callers 5

elementFunction · 0.85
eachElementFunction · 0.85
expectElementFunction · 0.85
expectAnyElementFunction · 0.85
expectAllElementsFunction · 0.85

Calls 6

setHelperMethod · 0.95
isAsyncFunctionFunction · 0.90
humanizeFunctionFunction · 0.90
helpersMethod · 0.80
filterMethod · 0.80
setArgumentsMethod · 0.80

Tested by

no test coverage detected