(purpose, locator, fn)
| 138 | } |
| 139 | |
| 140 | function 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 | |
| 163 | async function executeStep(step, action, stepConfig = {}) { |
| 164 | step.setCallable(action) |
no test coverage detected