MCPcopy Index your code
hub / github.com/codeceptjs/CodeceptJS / addStep

Function addStep

lib/mocha/bdd.js:32–51  ·  view source on GitHub ↗
(step, fn)

Source from the content-addressed store, hash-verified

30}
31
32const 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
53const parameterTypeRegistry = new ParameterTypeRegistry()
54

Callers

nothing calls this directly

Calls 2

getMethod · 0.80
getConfigFunction · 0.70

Tested by

no test coverage detected