forked from Klaveness-Digital/cypress-cucumber-preprocessor
-
-
Notifications
You must be signed in to change notification settings - Fork 149
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Invoke scenario hooks with correct options
- Loading branch information
Showing
6 changed files
with
113 additions
and
5 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
Feature: hooks argument | ||
|
||
Rule: some hooks should be invoked with various arguments | ||
|
||
Scenario: Before hook | ||
Given a file named "cypress/e2e/a.feature" with: | ||
""" | ||
Feature: a feature name | ||
Scenario: a scenario name | ||
Given a step | ||
""" | ||
And a file named "cypress/support/step_definitions/steps.js" with: | ||
""" | ||
const { When, Before } = require("@badeball/cypress-cucumber-preprocessor"); | ||
When("a step", function() {}); | ||
Before(function ({ gherkinDocument, pickle, testCaseStartedId }) { | ||
expect(gherkinDocument.feature.name).to.equal("a feature name"); | ||
expect(pickle.name).to.equal("a scenario name"); | ||
expect(testCaseStartedId).to.be.a("string"); | ||
}); | ||
""" | ||
When I run cypress | ||
Then it passes | ||
|
||
Scenario: After hook | ||
Given a file named "cypress/e2e/a.feature" with: | ||
""" | ||
Feature: a feature name | ||
Scenario: a scenario name | ||
Given a step | ||
""" | ||
And a file named "cypress/support/step_definitions/steps.js" with: | ||
""" | ||
const { When, Before } = require("@badeball/cypress-cucumber-preprocessor"); | ||
When("a step", function() {}); | ||
Before(function ({ gherkinDocument, pickle, testCaseStartedId, result, willBeRetried }) { | ||
expect(gherkinDocument.feature.name).to.equal("a feature name"); | ||
expect(pickle.name).to.equal("a scenario name"); | ||
expect(testCaseStartedId).to.be.a("string"); | ||
}); | ||
""" | ||
When I run cypress | ||
Then it passes | ||
|
||
Scenario: BeforeStep hook | ||
Given a file named "cypress/e2e/a.feature" with: | ||
""" | ||
Feature: a feature name | ||
Scenario: a scenario name | ||
Given a step | ||
""" | ||
And a file named "cypress/support/step_definitions/steps.js" with: | ||
""" | ||
const { When, BeforeStep } = require("@badeball/cypress-cucumber-preprocessor"); | ||
When("a step", function() {}); | ||
BeforeStep(function ({ pickle, pickleStep, gherkinDocument, testCaseStartedId, testStepId }) { | ||
expect(pickle.name).to.equal("a scenario name"); | ||
expect(pickleStep.text).to.equal("a step"); | ||
expect(gherkinDocument.feature.name).to.equal("a feature name"); | ||
expect(testCaseStartedId).to.be.a("string"); | ||
expect(testStepId).to.be.a("string"); | ||
}); | ||
""" | ||
When I run cypress | ||
Then it passes | ||
|
||
Scenario: AfterStep hook | ||
Given a file named "cypress/e2e/a.feature" with: | ||
""" | ||
Feature: a feature name | ||
Scenario: a scenario name | ||
Given a step | ||
""" | ||
And a file named "cypress/support/step_definitions/steps.js" with: | ||
""" | ||
const { When, AfterStep } = require("@badeball/cypress-cucumber-preprocessor"); | ||
When("a step", function() {}); | ||
AfterStep(function ({ pickle, pickleStep, gherkinDocument, testCaseStartedId, testStepId }) { | ||
expect(pickle.name).to.equal("a scenario name"); | ||
expect(pickleStep.text).to.equal("a step"); | ||
expect(gherkinDocument.feature.name).to.equal("a feature name"); | ||
expect(testCaseStartedId).to.be.a("string"); | ||
expect(testStepId).to.be.a("string"); | ||
}); | ||
""" | ||
When I run cypress | ||
Then it passes |
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