feat(cucumber): Fix skipping tests with skip tag (#14672)

Fixes #14671
This commit is contained in:
Luis Zurro 2025-07-31 07:21:52 +02:00 committed by GitHub
parent 7087238e9f
commit 0c77bb1791
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 33 additions and 3 deletions

View file

@ -222,7 +222,7 @@ export function generateSkipTagsFromCapabilities(capabilities: Capabilities.Reso
.find((filter: WebdriverIO.Capabilities) => Object.keys(filter)
.every((key: keyof WebdriverIO.Capabilities) => match((capabilities as Record<string, string>)[key], filter[key] as RegExp)))
if (isSkip) {
generatedTags.push(`(not ${tag.replace(/[()[\]{}^$*+?.|\\]/g, '\\$&')})`)
generatedTags.push(`(not ${tag.replace(/[(){}^$*+?.|\\]/g, '\\$&')})`)
}
}
})

View file

@ -5,6 +5,7 @@ Feature: Test Feature
When a step passes
@skip(browserName="chrome")
@skip(browserName=["firefox","safari"])
Scenario: Scenario #1
Given a step passes
When a step passes

View file

@ -18,6 +18,7 @@ Feature: Example feature
Then I should fail once but pass on the second run
@skip(browserName="chrome")
@skip(browserName=["firefox","safari"])
Scenario: Skipped... should never be executed
Then this test should fail

View file

@ -482,6 +482,33 @@ const cucumberFileOption = async () => {
)
}
/**
* Cucumber @skip() tag
*/
const cucumberSkipTag = async () => {
for (const browserName of ['chrome', 'firefox']) {
const { skippedSpecs } = await launch(
'cucumberTestrunner',
path.resolve(__dirname, 'helpers', 'cucumber-hooks.conf.js'),
{
capabilities: [{ browserName }],
specs: [
path.resolve(__dirname, 'cucumber', 'test.feature'),
path.resolve(__dirname, 'cucumber', 'test-skipped.feature')
],
cucumberOpts: {
tags: '(not @SKIPPED_TAG)',
ignoreUndefinedDefinitions: true,
retry: 1,
retryTagFilter: '@retry',
scenarioLevelReporter: true
}
}
)
assert.strictEqual(skippedSpecs, 1)
}
}
/**
* wdio test run with custom service
*/
@ -1136,6 +1163,7 @@ const jasmineAfterHookArgsValidation = async () => {
cucumberPendingTest,
cucumberReporter,
cucumberFileOption,
cucumberSkipTag,
standaloneTest,
mochaAsyncTestrunner,
customService,