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

Attachments are not cleared in before/after hooks #282

Closed
nebehr opened this issue Dec 18, 2014 · 3 comments
Closed

Attachments are not cleared in before/after hooks #282

nebehr opened this issue Dec 18, 2014 · 3 comments

Comments

@nebehr
Copy link
Contributor

nebehr commented Dec 18, 2014

If an attachment is created in after hook, it gets embedded to all subsequent after hooks of the current scenario and all before hooks of the next one. This is because attachments are cleared in AstTreeWalker.witnessNewStep (https://github.com/cucumber/cucumber-js/blob/master/lib/cucumber/runtime/ast_tree_walker.js#L223) but it does not get called for before/after hooks.

To reproduce create a feature file with 2 scenarios, define before and after hook and make an attachment in the latter:

this.Before(function (callback) {
      callback();
});

this.After(function (scenario, callback) {
        scenario.attach('BLABLABLA ', 'text/plain');
        callback();
})

When this feature is run with JSON formatter, total number of embeddings will be 3 instead of 2.

@jbpros
Copy link
Member

jbpros commented Dec 21, 2014

Thank you for reporting this. Fancy sending a PR?

@nebehr
Copy link
Contributor Author

nebehr commented Dec 22, 2014

#284

@jbpros jbpros closed this as completed in 75822d8 Feb 6, 2015
@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

2 participants