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

addContext called in beforeEach/afterEach hook adds additional context to the test even when the hook fails and the test is pending #395

Open
xkorin opened this issue Jun 13, 2023 · 0 comments

Comments

@xkorin
Copy link

xkorin commented Jun 13, 2023

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.

image

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.

image

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

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant