| 30 | } |
| 31 | |
| 32 | const addStep = async (step, fn) => { |
| 33 | const config = await getConfig() |
| 34 | const avoidDuplicateSteps = config.get('gherkin', {}).avoidDuplicateSteps || false |
| 35 | if (avoidDuplicateSteps && steps[step]) { |
| 36 | throw new Error(`Step '${step}' is already defined`) |
| 37 | } |
| 38 | steps[step] = fn |
| 39 | |
| 40 | // Use the current step file context if available (fallback for old usage) |
| 41 | if (currentStepFile) { |
| 42 | let relativePath = currentStepFile |
| 43 | |
| 44 | // Remove any leading './' and keep step_definitions/ path |
| 45 | relativePath = relativePath.replace(/^\.\//, '').replace(/^.*\/(?=step_definitions)/, '') |
| 46 | |
| 47 | fn.line = `${relativePath}:3:1` |
| 48 | } else { |
| 49 | fn.line = 'unknown_file:1:1' |
| 50 | } |
| 51 | } |
| 52 | |
| 53 | const parameterTypeRegistry = new ParameterTypeRegistry() |
| 54 | |