we are adding additional content like screenshots, logs in beforeEach Mocha hook but the content is always attached to the test. Normally it is not big issue as the test is listed in report so additional content can be checked there. In the case that beforeEach fails, any additional content is also added to the test but the test is marked as pending in this time and the mochawesome report is hiding all pending tests by the default.
As user I need to go to menu and enable switch to show all pending tests. Only then the user can check additional content added in the beforeEach hook.
Code Reproduce
Run test below where 'addContext' is called in beforeEach
describe.only("Mochawesome", () => {
beforeEach(async function () {
addContext(this, {
title: "beforeEach hook",
value: "Additional content is added to the test not to the reported hook in the report.",
});
throw "Error in beforeEach hook";
});
it("My test", () => {});
});
* Open mochawesome report
**Actual behavior**
* Additional content by `addContext` is added to the test "My test" which is hidden in the report by default.
**Expected behavior**
Additional content by `addContext` will be directly added to the failed beforeEach hook in the report.
![image](https://github.com/adamgruber/mochawesome/assets/136086747/fa457e4f-b6e1-4c0f-a0a4-cd003db5c665)
In my opinion, additional content added in beforeEach (or in any other hook) hook should be always added to that hook in the report. then it would be always clear if it was added in the hook or test.
**Environment (please complete the following information):**
- Platform Windows 10
- mochawesome 7.1.3
- mocha 8.2.3
- Node 16.19.0
Hello,
we are adding additional content like screenshots, logs in beforeEach Mocha hook but the content is always attached to the test. Normally it is not big issue as the test is listed in report so additional content can be checked there. In the case that beforeEach fails, any additional content is also added to the test but the test is marked as pending in this time and the mochawesome report is hiding all pending tests by the default.
As user I need to go to menu and enable switch to show all pending tests. Only then the user can check additional content added in the beforeEach hook.
Code Reproduce
describe.only("Mochawesome", () => { beforeEach(async function () { addContext(this, { title: "beforeEach hook", value: "Additional content is added to the test not to the reported hook in the report.", }); throw "Error in beforeEach hook"; });
});