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

Function parseSteps

lib/command/gherkin/snippets.js:57–88  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

55 const newSteps = new Map()
56
57 const parseSteps = steps => {
58 const newSteps = []
59 let currentKeyword = ''
60 for (const step of steps) {
61 if (step.keyword.trim() === 'And') {
62 if (!currentKeyword) throw new Error(`There is no active keyword for step '${step.text}'`)
63 step.keyword = currentKeyword
64 }
65 currentKeyword = step.keyword
66 try {
67 matchStep(step.text)
68 } catch (err) {
69 let stepLine
70 if (/[{}()/]/.test(step.text)) {
71 stepLine = escapeStringRegexp(step.text)
72 .replace(/\//g, '\\/')
73 .replace(/\"(.*?)\"/g, '"(.*?)"')
74 .replace(/(\d+\\\.\d+)/, '(\\d+\\.\\d+)')
75 .replace(/ (\d+) /, ' (\\d+) ')
76 stepLine = Object.assign(stepLine, { type: step.keyword.trim(), location: step.location, regexp: true })
77 } else {
78 stepLine = step.text
79 .replace(/\"(.*?)\"/g, '{string}')
80 .replace(/(\d+\.\d+)/, '{float}')
81 .replace(/ (\d+) /, ' {int} ')
82 stepLine = Object.assign(stepLine, { type: step.keyword.trim(), location: step.location, regexp: false })
83 }
84 newSteps.push(stepLine)
85 }
86 }
87 return newSteps
88 }
89
90 const parseFile = file => {
91 const ast = parser.parse(fs.readFileSync(file).toString())

Callers 1

parseFileFunction · 0.85

Calls 2

matchStepFunction · 0.90
pushMethod · 0.80

Tested by

no test coverage detected