Stop cucumber Before hook clobbering mocha before. #216
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Differentiate between Before as a cucumber Hook and before as the cypress mocha hook. This PR allows both to be defined and invoked appropriately.
Also fix the issues with mocha before and after hooks getting called multiple times #214 (comment). Changed the loader to wrap the required imports into the describe block for the generated testsuite.
There is a sample repo to illustrate the results on hook invocation of this PR at https://github.com/jcundill/cypressHooks.git
Note: For global step definitions all mocha hooks are at the Global scope - so beforeEach applies to all scenarios, etc. As the support pages are included into the cypress runner outside of any test scopes.
For local step definitions, mocha hooks scope appropriately. Those in common are applied to all features individually - before and after is called at the feature level. Those in step definition and helper files scoped to a single feature are applied just to that feature. This seems OK to me.
Also there seems to be a bug in cypress itself with regard to the mocha after hook when specified at the global level. This hook is applied after the first test rather than after all of them - run the js files just_cypress and just_cypress2 included in the test repo to reproduce this outside of the cypress-cucumber-plugin