-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
feat: add --fail-hook-affected-tests option to report skipped tests as failed #5519
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?
feat: add --fail-hook-affected-tests option to report skipped tests as failed #5519
Conversation
|
|
Hmm, I think we can ignore the CLA issue as the non-signer is AI :D |
|
I'll review this in more detail sometime in the next ~7 days :) |
5dee260 to
37acdb2
Compare
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #5519 +/- ##
=======================================
Coverage 93.69% 93.69%
=======================================
Files 57 57
Lines 4391 4440 +49
Branches 850 861 +11
=======================================
+ Hits 4114 4160 +46
- Misses 277 280 +3 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
mark-wiemer
left a comment
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.
Overall looks OK, just requesting some renames for clarity. I'll check the coverage and make sure I can repro this one locally as it's a big change. Fortunately we should be able to include this in 12.0.0-beta-1 :)
test/integration/fixtures/hooks/before-each-hook-error-with-fail-affected.fixture.js
Outdated
Show resolved
Hide resolved
test/integration/fixtures/hooks/before-each-hook-error-with-fail-affected.fixture.js
Outdated
Show resolved
Hide resolved
test/integration/fixtures/hooks/before-hook-error-with-fail-affected.fixture.js
Outdated
Show resolved
Hide resolved
test/integration/fixtures/hooks/before-each-hook-error-with-fail-affected.fixture.js
Outdated
Show resolved
Hide resolved
test/integration/fixtures/hooks/before-hook-error-with-fail-affected.fixture.js
Outdated
Show resolved
Hide resolved
…s failed When `before()` or `beforeEach()` hooks fail, Mocha currently only reports the hook failure and silently skips affected tests. This makes it difficult to track test coverage and understand the full impact of hook failures. This change introduces a new CLI option `--fail-hook-affected-tests` that, when enabled, reports all tests affected by hook failures as failed instead of silently skipping them. Changes: - Added --fail-hook-affected-tests boolean CLI option - Implemented failAffectedTests() method in Runner to fail all affected tests - Updated hook() method to call failAffectedTests when hooks fail - Added failHookAffectedTests option to Mocha class - Added integration tests for both before() and beforeEach() hook failures - All affected tests now receive descriptive error messages indicating which hook caused them to be skipped Fixes mochajs#4392
- Extract error message creation into createHookSkipError() helper function to eliminate duplication across three locations - Simplify recursive forEach call in failAffectedTests() - Update test fixture and suite descriptions to use backticks for clarity (e.g., 'error in `before` hook')
ade4687 to
9fe8493
Compare
When
before()orbeforeEach()hooks fail, Mocha currently only reports the hook failure and silently skips affected tests. This makes it difficult to track test coverage and understand the full impact of hook failures.This change introduces a new CLI option
--fail-hook-affected-teststhat, when enabled, reports all tests affected by hook failures as failed instead of silently skipping them.Changes:
Fixes #4392
PR Checklist
status: accepting prsOverview