Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cucumber sync hooks #4288

Merged
merged 17 commits into from Aug 14, 2019
Merged

Cucumber sync hooks #4288

merged 17 commits into from Aug 14, 2019

Conversation

mgrybyk
Copy link
Member

@mgrybyk mgrybyk commented Jul 31, 2019

Proposed changes

fixes #4207

Types of changes

  • Bugfix (non-breaking change which fixes an issue)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

Checklist

  • I have read the CONTRIBUTING doc
  • I have added tests that prove my fix is effective or that my feature works
  • I have added necessary documentation (if appropriate)

Further comments

Reviewers: @webdriverio/technical-committee

@mgrybyk mgrybyk added the PR: Bug Fix 🐛 PRs that contain bug fixes label Jul 31, 2019
Copy link
Member

@christian-bromann christian-bromann left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome! Can we add a smoke test that checks if all hooks are executed (e.g. by writing the name of the hook into a file or something around that)

@mgrybyk
Copy link
Member Author

mgrybyk commented Aug 1, 2019

If I could somehow determine step type in wrapStep function that would be awesome.
In such we would be able to add before after step hooks.
I've noticed that wrap step function also wraps hooks defined by user. I'm pretty sure this is not something we'd like to do, have to take a look if we can handle it somehow. Sorry to say cucumberJs doesn't support it

@mgrybyk
Copy link
Member Author

mgrybyk commented Aug 1, 2019

Great news! I've managed to make before/after step hooks work!

@codecov
Copy link

codecov bot commented Aug 1, 2019

Codecov Report

Merging #4288 into master will increase coverage by <.01%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #4288      +/-   ##
==========================================
+ Coverage   99.31%   99.31%   +<.01%     
==========================================
  Files         178      180       +2     
  Lines        4359     4408      +49     
  Branches      936      948      +12     
==========================================
+ Hits         4329     4378      +49     
  Misses         27       27              
  Partials        3        3
Impacted Files Coverage Δ
packages/webdriverio/src/constants.js 100% <ø> (ø) ⬆️
packages/wdio-config/src/constants.js 100% <ø> (ø) ⬆️
packages/wdio-sync/src/executeHooksWithArgs.js 100% <ø> (ø)
packages/wdio-sync/src/index.js 100% <100%> (ø)
packages/wdio-utils/src/utils.js 100% <100%> (ø)
packages/wdio-cucumber-framework/src/constants.js 100% <100%> (ø) ⬆️
packages/wdio-cucumber-framework/src/index.js 98.61% <100%> (+0.36%) ⬆️
packages/wdio-cucumber-framework/src/utils.js 100% <100%> (ø) ⬆️
... and 1 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 18cdfc5...7aa97e7. Read the comment docs.

@mgrybyk
Copy link
Member Author

mgrybyk commented Aug 2, 2019

Added smoke tests for cucumber to ensure hooks and steps are running sync, will add unit tests later on

@mgrybyk
Copy link
Member Author

mgrybyk commented Aug 2, 2019

work completed

@christian-bromann
Copy link
Member

Thanks so much, I will take a closer look on Monday.

@mgrybyk
Copy link
Member Author

mgrybyk commented Aug 2, 2019

@christian-bromann thank you!
Added one very last commit, noticed that step before/after hooks error are not printed out.

@mgrybyk
Copy link
Member Author

mgrybyk commented Aug 5, 2019

resolved all the conflicts and made changes according to #4308

@miguelyoobic95
Copy link

Looking forward to seeing this merged, we will test the new version straight away once it is :) thanks a lot guys

@mgrybyk
Copy link
Member Author

mgrybyk commented Aug 14, 2019

resolved conflicts, any other comments @christian-bromann @erwinheitzman ?

Copy link
Member

@christian-bromann christian-bromann left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Copy link
Member

@christian-bromann christian-bromann left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@christian-bromann christian-bromann merged commit 2939b3a into webdriverio:master Aug 14, 2019
@mgrybyk mgrybyk deleted the cucumber-sync-hooks branch August 20, 2019 07:22
yamkay pushed a commit to MoveInc/webdriverio that referenced this pull request Sep 4, 2019
* wdio-cucumber-framework: sync hooks

* wdio-cucumber-framework: add before after step hooks

* wdio-cucumber-framework: simplify wrap step with hooks

* wdio-cucumber-framework: fix sync step hook

* wdio-cucumber-framework: add unit tests

* wdio-cucumber-framework: added docs

* wdio-sync: add executeSync test, mark other functions as ignored

* fix typos in docs

* wdio-cucumber-framework: print step hook failure

* use isFunctionAsync everywhere

* fix wdio-utils version

* wdio-cucumber-framework: utils functions minor fixes

* wdio-cucumber-framework: simplify getDataFromResult

* remove redundant verifications

* wdio-cucumber-framework: move hook definition types to constants

* remove comma
@miguelyoobic95
Copy link

Is this supposed to be working ? We have upgraded and I get my first step on my test being called beforeFeature which is causing quite a bit of issues

@mgrybyk
Copy link
Member Author

mgrybyk commented Sep 18, 2019

Please raise an issue with proper description.

@miguelyoobic95
Copy link

Do you want me to raise an issue or would this be related to this one ? Basically we have a beforeFeature hook with some async code and the first Given of the cucumber test is still triggered before all the async actions in beforeFeature have finished running. Would beforeAll and afterAll be better replacements ?

@mgrybyk
Copy link
Member Author

mgrybyk commented Sep 19, 2019

It's not related to the PR, I don't know anything about your setup, looks like some configuration issue.
If you still have some problems please raise an issue with proper description and steps to reproduce.
Thank you

@miguelyoobic95
Copy link

Hey guys, I still have issues, will file a bug report with a repro case as soon as possible.

Is there an example repo where running functions inside the hooks is working ? Would like to have a look at one so I can check whether our setup is correct.

Weirdly the code within the hooks on our side only seems to be able to run a console log and it stops running correctly as soon as I add anything else with it stops running, almost like it terminates completely. Any help with examples would be great, I will link the issue here once I raise it :)

1 similar comment
@miguelyoobic95
Copy link

Hey guys, I still have issues, will file a bug report with a repro case as soon as possible.

Is there an example repo where running functions inside the hooks is working ? Would like to have a look at one so I can check whether our setup is correct.

Weirdly the code within the hooks on our side only seems to be able to run a console log and it stops running correctly as soon as I add anything else with it stops running, almost like it terminates completely. Any help with examples would be great, I will link the issue here once I raise it :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Cucumber + v5] How to make hooks (afterStep) to run and finish before next step is executed?
4 participants