allure-framework / allure-js

Allure integrations for JavaScript test frameworks
https://allurereport.org/
Apache License 2.0
217 stars 112 forks source link

Fix duplicated afterEach (#236) #1027

Closed delatrie closed 1 week ago

delatrie commented 1 week ago

Context

The PR fixes afterEach fixtures being associated with all tests in the suite, which leads to multiple afterEach entries in the Tear Down section in the report. That was because we incorrectly assumed the following sequence of Mocha events:

onSuite
onTest
onHook (beforeEach)
onHookEnd (beforeEach)
onTestPassed
onHook (afterEach)
onHookEnd (afterEach)
onTestEnd
onSuiteEnd

The PR makes allure-mocha support the actual sequence:

onSuite
onTest
onHook (beforeEach)
onHookEnd (beforeEach)
onTestPassed
onTestEnd
onHook (afterEach)
onHookEnd (afterEach)
onSuiteEnd

This is done by storing the test's scope until onSuiteEnd, where scopes of all the suite's tests are written.

Fix #236

Checklist