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

There are plans to support generators on the steps? #438

Closed
srhwork opened this issue Oct 21, 2015 · 4 comments
Closed

There are plans to support generators on the steps? #438

srhwork opened this issue Oct 21, 2015 · 4 comments

Comments

@srhwork
Copy link

srhwork commented Oct 21, 2015

Hi.

I recently started using "cucumber" and I love it. I'm using "WebdriverIO" in my tests and I would like to use generators. Like this:

this.Then(/^I should see "(.*)" as the page title$/, function*(title, next) {

        let result = yield this.driver
             .url( "http://localhost:3000" )
             .title();

        expect( result ).to.equal( title );
        next(); 
 });

So, there are plans to support generators on the steps?

Thanks.

@charlierudolph
Copy link
Member

Looking at the idea behind for es6 generators, I believe support for generators is simply based on what version of node you are running. What happens when you run the given code? (I'm curious what would happen if you were to remove next as well)

@srhwork
Copy link
Author

srhwork commented Oct 22, 2015

Ok, if I run something like this:

this.Then(/^I should see "(.*)" as the page title$/, function*(title) {

        let result = yield driver
            .execute(() => {
                return document.title;
            });

        console.log(result);

        yield driver
            .end();
});

The steps pass without open the browser. The scenario is successful but does nothing, even the result variable never print.

And if I run something like this:

this.Then(/^I should see "(.*)" as the page title$/, function*(title, next) {

        let result = yield driver
            .execute(() => {
                return document.title;
            });

        console.log(result);

        yield driver
            .end();

        next();
});

The step exceed the timed out with any time I set.

I use Node v4.2.1 with generators support.

So, I think "cucumber" does not support the flow generator. How to make do it exceeds my knowledge.

Thanks.

@charlierudolph
Copy link
Member

Looks like we can use is-generator to check if the function supplied is a generator function and then use co to run it.

I like the idea of supporting it. Personally don't have time to work on this at the moment and probably won't until we get to 1.0. Pull request welcome.

@lock
Copy link

lock bot commented Oct 25, 2018

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked as resolved and limited conversation to collaborators Oct 25, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants