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

feature: option to customize mocha template #3

Closed
fcurella opened this issue Jan 23, 2018 · 9 comments
Closed

feature: option to customize mocha template #3

fcurella opened this issue Jan 23, 2018 · 9 comments

Comments

@fcurella
Copy link
Contributor

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

@lgandecki
Copy link
Collaborator

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?

@fcurella
Copy link
Contributor Author

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.

@lgandecki
Copy link
Collaborator

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

@fcurella
Copy link
Contributor Author

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

@fcurella
Copy link
Contributor Author

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.

@lgandecki
Copy link
Collaborator

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

@fcurella
Copy link
Contributor Author

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

@lgandecki
Copy link
Collaborator

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 :)

@badeball
Copy link
Owner

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.

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

No branches or pull requests

3 participants