badeball/cypress-cucumber-preprocessor

feature: option to customize mocha template

fcurella opened this issue · 9 comments

right now the .feature files gets converted to a mocha test using a hardcoded template. Would be nice if we could pass an option to the preprocessor to override the template

Could you explain a bit more what's the usecase here? Maybe an example of a different template/structure you would possibly like to use?

I'd like to use a template that would gather the scenario's tags and skip the test if they don't match a specific list.

oh, I see. Like a @Focus or @ignore. Where would you put the list that decides what to ignore/what to exclusively focus on?

I'm using an environment variable called CYPRESS_TAGS, which I then read with Cypress.env('TAGS').split(',').

Another use case I just found is adding my own beforeEach.

Specifically, the app I'm testing stores the authentication token in a cookie. But because the template is rendering every step as a different test, Cypress is clearing the cookie after the login. So my solution was to add:

    beforeEach(function () {
      Cypress.Cookies.preserveOnce('token',);
    });

To the template, and that cookie is retained through the feature.

@fcurella I'm thinking more about this.. is the cookie removed in between steps of a single scenario? or between separate scenarios?

@lgandecki between steps, since each step is converted to a single test

aside from the fact that it might be nice to have dynamic templates, I think preserving cookie and the local storage should be a default inside a scenario, what do you think?
Once this is done it will be much easier to do this properly:

cypress-io/cypress#686

but we can have a temporary solution . This is not really usable if we clear cookies and local storage betwen every it :)

Due to personal reasons, the previous maintainers of this package are stepping down and handing the reigns over to me, a long-time contributor to the project and a user of it myself. This is a responsibility I'm very excited about. Furthermore, I'd like to thank @lgandecki ++ for all the work that they've done so far.

Read more about the transfer of ownership here.

The repository has however moved and all outstanding issues are being closed. This is not a reflection of the perceived importance of your reported issue. However, if after upgrading to the new version, you still find there to be an issue, feel free to open up another ticket or comment below. Please make sure to read CONTRIBUTING.md before doing so.