Skip to content

Commit 5ac9fb5

Browse files
authored
feat: adding support for the But keyword (#5291)
1 parent 32d37f7 commit 5ac9fb5

File tree

5 files changed

+5
-4
lines changed

5 files changed

+5
-4
lines changed

lib/step/base.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ class Step {
225225
processingStep = this
226226

227227
while (processingStep.metaStep) {
228-
if (processingStep.metaStep.actor?.match(/^(Given|When|Then|And)/)) {
228+
if (processingStep.metaStep.actor?.match(/^(Given|When|Then|And|But)/)) {
229229
hasBDD = true
230230
break
231231
} else {

lib/step/meta.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ class MetaStep extends Step {
1515

1616
/** @return {boolean} */
1717
isBDD() {
18-
if (this.actor && this.actor.match && this.actor.match(/^(Given|When|Then|And)/)) {
18+
if (this.actor && this.actor.match && this.actor.match(/^(Given|When|Then|And|But)/)) {
1919
return true
2020
}
2121
return false

test/data/sandbox/configs/html-reporter-plugin/features/html-reporter.feature

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ Feature: HTML Reporter BDD Test
1313
When I perform an action
1414
Then I should see the expected result
1515
And everything should work correctly
16+
But I should see the expected result
1617

1718
@regression @critical
1819
Scenario: Test with data table

test/runner/html-reporter-plugin_test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ describe('CodeceptJS html-reporter-plugin', function () {
181181
expect(reportContent).toContain('data-type=')
182182

183183
// Should contain scenario steps with proper keywords
184-
expect(reportContent).toMatch(/Given|When|Then|And/)
184+
expect(reportContent).toMatch(/Given|When|Then|And|But/)
185185

186186
done()
187187
})

test/unit/steps_test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ describe('Steps', () => {
9292
})
9393

9494
describe('#isBDD', () => {
95-
;['Given', 'When', 'Then', 'And'].forEach(key => {
95+
;['Given', 'When', 'Then', 'And', 'But'].forEach(key => {
9696
it(`[${key}] #isBdd should return true if it BDD style`, () => {
9797
const metaStep = new MetaStep(key, 'I need to open Google')
9898
expect(metaStep.isBDD()).to.be.true

0 commit comments

Comments
 (0)