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.
Added cucumber-js-style Before and After hooks.
- Loading branch information
Showing
9 changed files
with
177 additions
and
15 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
Feature: Using Before and After | ||
|
||
# After is implicitly tested by resetting the counter. | ||
|
||
Scenario: With Before only | ||
Given I do something | ||
And Something else | ||
Then Before was called once | ||
|
||
@withTaggedBefore | ||
Scenario: With tagged Before only | ||
Given I do something | ||
And Something else | ||
Then Before with tag was called once | ||
|
||
Scenario: With After only | ||
Given I do something | ||
And Something else | ||
|
||
@withTaggedAfter | ||
Scenario: With tagged After only | ||
Given I do something | ||
And Something else | ||
|
||
Scenario: With Before and After | ||
Given I do something | ||
And Something else | ||
Then Before was called once | ||
|
||
@withTaggedBefore | ||
@withTaggedAfter | ||
Scenario: With tagged After only | ||
Given I do something | ||
And Something else | ||
Then Before with tag was called once |
37 changes: 37 additions & 0 deletions
37
cypress/support/step_definitions/before_and_after_steps.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/* global given, when, then, before, after */ | ||
/* eslint-env mocha */ | ||
|
||
let beforeCounter = 0; | ||
let beforeWithTagCounter = 0; | ||
|
||
before(() => { | ||
beforeCounter += 1; | ||
}); | ||
|
||
before({ tags: "@withTaggedBefore" }, () => { | ||
beforeWithTagCounter += 1; | ||
}); | ||
|
||
after(() => { | ||
beforeCounter = 0; | ||
}); | ||
|
||
after({ tags: "@withTaggedAfter" }, () => { | ||
beforeWithTagCounter = 0; | ||
}); | ||
|
||
given("I do something", () => {}); | ||
|
||
when("Something else", () => {}); | ||
|
||
then("Before was called once", () => { | ||
expect(beforeCounter).to.equal(1); | ||
}); | ||
|
||
then("Before with tag was called once", () => { | ||
expect(beforeWithTagCounter).to.equal(1); | ||
}); | ||
|
||
then("Before was not called", () => { | ||
expect(beforeCounter).to.equal(1); | ||
}); |
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
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