Skip to content

fix before/after all hooks not finding tests that aren't direct children of parent#46

Merged
bmomberger-bitovi merged 2 commits into
masterfrom
mocha-error-fix-nested-tests
Jun 7, 2018
Merged

fix before/after all hooks not finding tests that aren't direct children of parent#46
bmomberger-bitovi merged 2 commits into
masterfrom
mocha-error-fix-nested-tests

Conversation

@bmomberger-bitovi
Copy link
Copy Markdown
Contributor

@bmomberger-bitovi bmomberger-bitovi commented Jun 7, 2018

As a refinement of #45 -- I just realized that failures on the before all / after all hooks might not find a test to glom onto if there wasn't a test that was a direct sibling. This fix uses eachTest() to always find a suitable test to fail when one of these hooks fails, as long as one exists in the suite.

Comment thread src/adapters/mocha.js Outdated
data.parent.eachTest(function(t) {
test = test || t;
})
data = test;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should preserve the original data if no test is found rather than setting undefined.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The way mocha works, if there's no test in the suite or any subsuite, the hook doesn't run (so it shouldn't be able to fail without a test to be found). But it's not a big deal to make the change, so sure.

@bmomberger-bitovi bmomberger-bitovi merged commit 0150206 into master Jun 7, 2018
@bmomberger-bitovi bmomberger-bitovi deleted the mocha-error-fix-nested-tests branch June 7, 2018 21:20
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

Successfully merging this pull request may close these issues.

2 participants