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

Hooks are not waiting for promises with cucumber framework 2.2.8 #3068

Closed
Tallyb opened this issue Nov 22, 2018 · 10 comments
Closed

Hooks are not waiting for promises with cucumber framework 2.2.8 #3068

Tallyb opened this issue Nov 22, 2018 · 10 comments
Labels

Comments

@Tallyb
Copy link
Contributor

Tallyb commented Nov 22, 2018

Environment (please complete the following information):

  • WebdriverIO version: 4.14.4
  • Mode: WDIO
  • If WDIO Testrunner, running sync
  • **Node.js version: 10.13.0
  • NPM version: 6.4.1
  • Browser name and version: chrome
  • Platform name and version: MacOS latest
  • Additional wdio packages used (if applicable): [e.g. @wdio/spec reporter, @wdio/selenium-standalone service]
    wdio-cucumber-framework

Bug repo: https://github.com/Tallyb/wdio-test/tree/async-hooks (branch is async hooks)

Config of WebdriverIO
An example of how you configured WebdriverIO config

Describe the bug
BeforeFeature hook is not waiting for promise resolve.
A clear and concise description of what the bug is.

To Reproduce
Steps to reproduce the behavior:
https://github.com/Tallyb/wdio-test/tree/async-hooks
npm install
npm run test
install wdio-cucumber-framework in version 1.1.1 to see the desired behaviour. Change to 2.2.8 to see the bug (logging message is showing before the async date logs)

Expected behavior
Feature should only run after beforeHook promise was resolved.

Log
If applicable, add logs to help explain your problem.
Create a gist which is a paste of your full Selenium/WebdriverIO logs, and link them here. Do not paste your full Appium logs here, as it will make this issue very long and hard to read! If you are reporting a bug, always include Selenium/WebdriverIO logs!

Additional context
Add any other context about the problem here.

Please use the correct markdown

@christian-bromann
Copy link
Member

@Tallyb in the meantime this should be a workaround:

    beforeFeature: function (feature) {
        browser.windowHandleSize( {width: 375, height: 800});
        console.log('IN BEFORE FEATURE');
        browser.call(() => utils.runDelays());
    },

@Tallyb
Copy link
Contributor Author

Tallyb commented Nov 22, 2018

@christian-bromann I just checked it (also on my real repo previously) and it does not fix.

@rodrigodiez
Copy link

Is this confirmed then? I have some failing tests that could be caused by that behaviour

@jonatr35
Copy link

jonatr35 commented Dec 4, 2018

Seeing the same behavior when attempting to make an axios http POST in beforeScenario hook. The status code in the then block gets logged after beforeStep hook has console logged.

Using "wdio-cucumber-framework": "2.2.8" as well.

@BorisOsipov
Copy link
Member

yes it is 2.x version issue. And this should be moved to cucumber adapter repo @christian-bromann

For @Tallyb @jonatr35 @rodrigodiez

You can achive expected behaviour by using "native" cucumber hooks e.g.:

var { Given, Before } = require('cucumber');
const utils = require('./utils');

Before(() => {
    browser.windowHandleSize({ width: 375, height: 800 });
    return utils.runDelays();
});

Given(/^Log Something$/, function () {
    console.log('Logging something')
});

In this case Before hook will be executed before scenario steps.
Log output:

IN BEFORE FEATURE
2018-12-04T08:18:50.702Z 1
2018-12-04T08:18:52.709Z 2
2018-12-04T08:18:55.710Z 3
2018-12-04T08:18:59.711Z 4
Logging something

1 passing (16.10s)

For more information see cucumber hooks documentaion

@rodrigodiez
Copy link

Thanks @BorisOsipov that is really useful

@christian-bromann
Copy link
Member

Closing this. It will be a requirement for the cucumber v5 effort.

@miguelyoobic95
Copy link

Hey guys, we have upgraded to v5 and we are observing this issue. Any workarounds for this ? Our first Given is consistently running before our async afterFeature hook has finished and it breaks our tests essentially ...

@mgrybyk
Copy link
Member

mgrybyk commented Jul 31, 2019

@miguelyoobic95 #4207

@miguelyoobic95
Copy link

Having a look now, thanks @mgrybyk. Sticking a timeout makes thing work but is far from being a good solution

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

No branches or pull requests

7 participants