forked from Klaveness-Digital/cypress-cucumber-preprocessor
-
-
Notifications
You must be signed in to change notification settings - Fork 148
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Filtering non-Cucumber specs (which doesn't contain tags) is not straight forward and there's not a single behavior that's more intuitive than others. Hence a `filterSpecsMixedMode` option. This fixes #1125 [1], essentially reverts 0b2702b [2] by retaining original behavior by default, and also relates to #1116 [3]. [1] #1125 [2] 0b2702b [3] #1116
- Loading branch information
Showing
9 changed files
with
281 additions
and
67 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,73 +1,106 @@ | ||
Feature: filter spec | ||
|
||
Background: | ||
Given additional preprocessor configuration | ||
Given additional Cypress configuration | ||
""" | ||
{ | ||
"e2e": { | ||
"specPattern": "**/*.{spec.js,feature}" | ||
} | ||
} | ||
""" | ||
And additional preprocessor configuration | ||
""" | ||
{ | ||
"filterSpecs": true | ||
} | ||
""" | ||
And a file named "cypress/e2e/foo.feature" with: | ||
""" | ||
@foo | ||
Feature: some feature | ||
Scenario: first scenario | ||
Given a step | ||
""" | ||
And a file named "cypress/e2e/bar.feature" with: | ||
""" | ||
@bar | ||
Feature: some other feature | ||
Scenario: second scenario | ||
Given a step | ||
""" | ||
And a file named "cypress/support/step_definitions/steps.js" with: | ||
""" | ||
const { Given } = require("@badeball/cypress-cucumber-preprocessor"); | ||
Given("a step", function() {}) | ||
""" | ||
And a file named "cypress/e2e/baz.spec.js" with: | ||
""" | ||
it("should work", () => {}); | ||
""" | ||
|
||
Rule: it should filter features based on whether they contain a matching scenario | ||
|
||
Scenario: 1 / 2 specs matching | ||
Given a file named "cypress/e2e/a.feature" with: | ||
""" | ||
@foo | ||
Feature: some feature | ||
Scenario: first scenario | ||
Given a step | ||
""" | ||
And a file named "cypress/e2e/b.feature" with: | ||
""" | ||
@bar | ||
Feature: some other feature | ||
Scenario: second scenario | ||
Given a step | ||
""" | ||
And a file named "cypress/support/step_definitions/steps.js" with: | ||
""" | ||
const { Given } = require("@badeball/cypress-cucumber-preprocessor"); | ||
Given("a step", function() {}) | ||
""" | ||
When I run cypress with "--env tags=@foo" | ||
Then it passes | ||
And it should appear to not have ran spec "b.feature" | ||
And it should appear to not have ran spec "bar.feature" | ||
But it should appear to have ran spec "foo.feature" | ||
|
||
Scenario: 2 / 2 specs matching | ||
When I run cypress with "--env tags='@foo or @bar'" | ||
Then it passes | ||
And it should appear to have ran spec "foo.feature" and "bar.feature" | ||
|
||
Rule: non-feature specs should be filtered as if they have tags equalling the empty set | ||
Rule: filterSpecsMixedMode: hide (default) should hide non-feature specs regardless of tag expression | ||
|
||
Scenario: positive tag expression | ||
When I run cypress with "--env tags=@foo" | ||
Then it passes | ||
And it should appear to not have ran spec "baz.spec.js" | ||
|
||
Scenario: negative tag expression | ||
When I run cypress with "--env 'tags=not @foo'" | ||
Then it passes | ||
And it should appear to not have ran spec "baz.spec.js" | ||
|
||
Rule: filterSpecsMixedMode: show should show non-feature specs regardless of tag expression | ||
|
||
Background: | ||
Given additional Cypress configuration | ||
Given additional preprocessor configuration | ||
""" | ||
{ | ||
"e2e": { | ||
"specPattern": "**/*.{spec.js,feature}" | ||
} | ||
"filterSpecsMixedMode": "show" | ||
} | ||
""" | ||
And a file named "cypress/e2e/a.feature" with: | ||
""" | ||
@bar | ||
Feature: some feature | ||
Scenario: first scenario | ||
Given a step | ||
""" | ||
And a file named "cypress/support/step_definitions/steps.js" with: | ||
""" | ||
const { Given } = require("@badeball/cypress-cucumber-preprocessor"); | ||
Given("a step", function() {}) | ||
""" | ||
And a file named "cypress/e2e/b.spec.js" with: | ||
|
||
Scenario: positive tag expression | ||
When I run cypress with "--env tags=@foo" | ||
Then it passes | ||
And it should appear to have ran spec "baz.spec.js" | ||
|
||
Scenario: negative tag expression | ||
When I run cypress with "--env 'tags=not @foo'" | ||
Then it passes | ||
And it should appear to have ran spec "baz.spec.js" | ||
|
||
|
||
Rule: filterSpecsMixedMode: empty-set should filter non-feature specs as if they have tags equalling the empty set | ||
|
||
Background: | ||
Given additional preprocessor configuration | ||
""" | ||
it("should work", () => {}); | ||
{ | ||
"filterSpecsMixedMode": "empty-set" | ||
} | ||
""" | ||
|
||
Scenario: logical not | ||
When I run cypress with "--env 'tags=not @foo'" | ||
Scenario: positive tag expression | ||
When I run cypress with "--env tags=@foo" | ||
Then it passes | ||
And it should appear to have ran spec "a.feature" and "b.spec.js" | ||
And it should appear to not have ran spec "baz.spec.js" | ||
|
||
Scenario: not logical not | ||
When I run cypress with "--env tags=@bar" | ||
Scenario: negative tag expression | ||
When I run cypress with "--env 'tags=not @foo'" | ||
Then it passes | ||
And it should appear as if only a single test ran | ||
And it should appear to have ran spec "baz.spec.js" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.