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

Function matchStep

lib/mocha/bdd.js:55–76  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

53const parameterTypeRegistry = new ParameterTypeRegistry()
54
55const matchStep = step => {
56 for (const stepName in steps) {
57 if (stepName.indexOf('/') === 0) {
58 const regExpArr = stepName.match(/^\/(.*?)\/([gimy]*)$/) || []
59 const res = step.match(new RegExp(regExpArr[1], regExpArr[2]))
60 if (res) {
61 const fn = steps[stepName]
62 fn.params = res.slice(1)
63 return fn
64 }
65 continue
66 }
67 const expression = new CucumberExpression(stepName, parameterTypeRegistry)
68 const res = expression.match(step)
69 if (res) {
70 const fn = steps[stepName]
71 fn.params = res.map(arg => arg.getValue(null))
72 return fn
73 }
74 }
75 throw new Error(`No steps matching "${step.toString()}"`)
76}
77
78const clearSteps = () => {
79 steps = {}

Callers 3

runStepsFunction · 0.90
parseStepsFunction · 0.90
bdd_test.jsFile · 0.90

Calls 2

getValueMethod · 0.80
toStringMethod · 0.45

Tested by

no test coverage detected