Skip to content
This repository has been archived by the owner on Sep 3, 2020. It is now read-only.

allow before hook failures to auto save screenshots #81

Merged
merged 2 commits into from
Jun 22, 2014

Conversation

EndangeredMassa
Copy link
Collaborator

Before, it was impossible to get automatic screenshots to work when there was a failure in a before hook. This implements a custom mocha reporter that allows this logic to live at a higher level than the actual tests. In my local testing, it works as expected.

If we ever get multiple reporters, then we can allow arbitrary user-specified reporters again.

Addresses: #72

@EndangeredMassa EndangeredMassa changed the title Before hook failure allow before hook failures to auto save screenshots Jun 22, 2014
@jkrems
Copy link
Contributor

jkrems commented Jun 22, 2014

LGTM

EndangeredMassa added a commit that referenced this pull request Jun 22, 2014
allow before hook failures to auto save screenshots
@EndangeredMassa EndangeredMassa merged commit de421a6 into master Jun 22, 2014
@EndangeredMassa EndangeredMassa deleted the before-hook-failure branch June 22, 2014 04:21
@EndangeredMassa
Copy link
Collaborator Author

published in 1.7.0

@mzchenorajet
Copy link

mzchenorajet commented Jun 5, 2019

Do you have example on how to attach the screenshots for before hook failures in the mochawesome report ?

Right now I write an afterEach code as below and use addContext() to attach the screenshot for the failed tests in the report. I am able to see that in the report.
But I am not able to get it if beforeAll hook failed.

afterEach("take screenshot on failure", async function () {
...
addContext(this, screenshotFolder + path.sep + imageFileName);

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

Successfully merging this pull request may close these issues.

3 participants