webdriverio-boneyard / wdio-sync

A WebdriverIO v4 plugin. Helper module to run WebdriverIO commands synchronously.
http://v4.webdriver.io
MIT License
17 stars 31 forks source link

should hooks be getting called before/after async commands? #38

Closed jedwards1211 closed 7 years ago

jedwards1211 commented 7 years ago

If I understand the code correctly, hooks won't get run around async commands.

wrapCommand is basically the identity function for async commands: https://github.com/webdriverio/wdio-sync/blob/master/index.js#L153

But for sync commands it calls hooks: https://github.com/webdriverio/wdio-sync/blob/master/index.js#L199

Is this right? I'm trying to work on an async-only version, and this seemed odd to me.

christian-bromann commented 7 years ago

hooks won't get run around async commands.

Only beforeCommand and afterCommand hooks are being ignored in async mode. On the longterm I wanted to implement them in the WebdriverIO monad but it's super low priority.

jedwards1211 commented 7 years ago

I guess I'll just have to hope that fibers gets deprecated and abandoned someday.

christian-bromann commented 7 years ago

Fibers has right now way more advantages compared to async/await. I love to write my test code fully synchronous. It provides super clear stacktraces and is easy to understand for non devs. We will see how JS evolves and how other opinions will shape the architecture of this project. I appreciate your opinion but truly believe that making anything more difficult and inconvenient makes it harder for others and that is not the intention I want to follow.

sassda commented 6 years ago

kind of resurrecting this, what's the status of beforeCommand and afterCommand in async mode? I tried and they don't seem to be called, is this still a low priority?

christian-bromann commented 6 years ago

is this still a low priority?

Command hooks might be available in v5, any contributions are much appreciated

gztomas commented 6 years ago

Please consider adding a warning about that behavior to the docs, otherwise, it's just guessing.

jedwards1211 commented 6 years ago

Nice, does this package being moved to the boneyard mean webdriverio will stop using fibers?

christian-bromann commented 6 years ago

webdriverio will stop using fibers?

Never! Why should it?

Update on this issue: in didn't land in v5 but any contributions to make this happen are still appreciated.

jedwards1211 commented 6 years ago

Darn :wink: I'm still hoping fibers in node eventually becomes a thing of the past

christian-bromann commented 6 years ago

I'm still hoping fibers in node eventually becomes a thing of the past

@jedwards1211 why do you think that? Fibers is beautiful and clears up all unnecessary awaits in my code. In v5 there will be no need for you to install fibers. You can work with async/await and it will be the same API. However you will have tons of unnecessary async awaits in your code.

fijijavis commented 6 years ago

My biggest complaint against fibers is that It prevents me from running my Wdio tests in a pure Alpine Docker container.

jedwards1211 commented 6 years ago