(text, file)
| 21 | parser.stopAtFirstError = false |
| 22 | |
| 23 | const gherkinParser = (text, file) => { |
| 24 | const ast = parser.parse(text) |
| 25 | let currentLanguage |
| 26 | |
| 27 | if (ast.feature) { |
| 28 | // Ensure translations are loaded before trying to access them |
| 29 | currentLanguage = getTranslation(ast.feature.language) |
| 30 | } |
| 31 | |
| 32 | if (!ast.feature) { |
| 33 | throw new Error(`No 'Features' available in Gherkin '${file}' provided!`) |
| 34 | } |
| 35 | const suite = new Suite(ast.feature.name, new Context()) |
| 36 | enhanceMochaSuite(suite) |
| 37 | const tags = ast.feature.tags.map(t => t.name) |
| 38 | suite.title = `${suite.title} ${tags.join(' ')}`.trim() |
| 39 | suite.tags = tags || [] |
| 40 | suite.comment = ast.feature.description |
| 41 | suite.feature = ast.feature |
| 42 | suite.file = file |
| 43 | suite.timeout(0) |
| 44 | |
| 45 | suite.beforeEach('codeceptjs.before', function (done) { |
| 46 | // In Mocha, 'this' is the hook Context; currentTest is the running scenario |
| 47 | setup(this)(done) |
| 48 | }) |
| 49 | suite.afterEach('codeceptjs.after', function (done) { |
| 50 | teardown(this)(done) |
| 51 | }) |
| 52 | suite.beforeAll('codeceptjs.beforeSuite', suiteSetup(suite)) |
| 53 | suite.afterAll('codeceptjs.afterSuite', suiteTeardown(suite)) |
| 54 | |
| 55 | const runSteps = async steps => { |
| 56 | for (const step of steps) { |
| 57 | const metaStep = new MetaStep(null, step.text) |
| 58 | metaStep.actor = step.keyword.trim() |
| 59 | let helperStep |
| 60 | const setMetaStep = step => { |
| 61 | helperStep = step |
| 62 | if (step.metaStep) { |
| 63 | if (step.metaStep === metaStep) { |
| 64 | return |
| 65 | } |
| 66 | setMetaStep(step.metaStep) |
| 67 | return |
| 68 | } |
| 69 | step.metaStep = metaStep |
| 70 | } |
| 71 | const fn = matchStep(step.text) |
| 72 | |
| 73 | if (step.dataTable) { |
| 74 | fn.params.push({ |
| 75 | ...step.dataTable, |
| 76 | parse: () => new DataTableArgument(step.dataTable), |
| 77 | }) |
| 78 | metaStep.comment = `\n${transformTable(step.dataTable)}` |
| 79 | } |
| 80 |
no test coverage detected