-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Report skipped tests upon beforeAll hook failure #4221
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
base: main
Are you sure you want to change the base?
Conversation
acf8687
to
3b59dd8
Compare
3b59dd8
to
9bcd7fc
Compare
a85e55f
to
9febfaf
Compare
9febfaf
to
989fae1
Compare
989fae1
to
06fc1d0
Compare
I'm confused about this vs. #4223 |
@boneskull I don't know if this is actually much different then that issue described, but I forced failure at a beforeEach statement. I got no other pending or skipped test cases for the tests omitted after the failure while using Mocha 8.1.1 |
Any update on this? would be really helpful for multiple e2e testing workflows. |
Any updates on this? Could really use this update. |
Per #1815 (comment), marking this and #4223 as |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR extends Mocha’s reporting functionality to include tests skipped due to failing before hooks. Key changes include:
- Introducing a new event (EVENT_TEST_SKIPPED) and a new test state ("skipped") to differentiate tests skipped because of hook failures.
- Updating reporters (spec, JSON, base) and the stats-collector to report and display skipped tests.
- Adjusting test fixtures and helpers to validate the new behavior.
Reviewed Changes
Copilot reviewed 24 out of 24 changed files in this pull request and generated no comments.
Show a summary per file
File | Description |
---|---|
test/integration/hook-err.spec.js | Updated tests to verify proper reporting of skipped tests for various hook error scenarios. |
test/integration/helpers.js | Modified helper to include and parse the new "skipped" count in the summary output. |
test/integration/glob.spec.js | Adjusted assertions to work with updated expected output strings. |
lib/suite.js, lib/runnable.js | Added new "skipped" property and corresponding isSkipped() methods. |
lib/stats-collector.js | Updated to count skipped tests in the overall stats. |
lib/runner.js | Modified hook and test execution flows to emit and handle skipped test events. |
lib/reporters/* | Updated reporters to display the new skipped tests count and log skipped test titles. |
docs/index.md | Added documentation on the behavior change when hooks fail, leading to skipped tests. |
Comments suppressed due to low confidence (3)
test/integration/helpers.js:310
- When parsing the output summary, consider using parseInt(match[1], 10) instead of parseInt(match, 10) to ensure the captured group is correctly converted to a number.
summary[type] = match ? parseInt(match, 10) : 0;
lib/reporters/spec.js:92
- [nitpick] Since EVENT_TEST_SKIPPED uses the red fail color to display skipped tests, consider clarifying in the reporter docs or using a distinct visual cue to differentiate these from genuinely failing tests.
runner.on(EVENT_TEST_SKIPPED, function(test) {
docs/index.md:450
- [nitpick] Consider adding further clarification that tests marked as 'skipped' due to hook failures are treated differently from user-declared pending tests, ensuring users understand the distinction in test outcomes.
### Failing Hooks
Description
related: #4233
Before: a failing
before
hook ignores the three tests completely. They disappear and are not even summarised in the epilogue.After:
Description of the Change
EVENT_TEST_SKIPPED
test.state
:skipped
pending
test cases, but in color red.We now have four test states:
passes
pending
: set by the userit('some test')
it.skip()
ordescribe.skip()
this.skip()
skipped
: test not run because of a failing hookfailed
: test failed or hook failedWe are aware of
pending
not being an optimal label. Nevertheless we will stick to it for historical reasons, it has been established for many years.Applicable issues
ToDo:
afterEach
hooks#1955
#1815