-
-
Notifications
You must be signed in to change notification settings - Fork 742
fix: hook exit code #5058
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: 3.x
Are you sure you want to change the base?
fix: hook exit code #5058
Conversation
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
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 fixes hook exit code handling by ensuring that error reporting is consistent across all hook types. The change ensures that suiteTestFailedHookError
is called for 'after' and 'afterSuite' hooks when errors occur, which was previously missing for these hook types.
- Adds
suiteTestFailedHookError
calls for 'after' and 'afterSuite' hooks - Restructures conditional blocks for better readability with proper bracing
- Maintains existing event emission behavior for each hook type
if (hookName == 'before' || hookName == 'beforeSuite') suiteTestFailedHookError(suite, err, hookName) | ||
if (hookName === 'after') suite.eachTest(test => event.emit(event.test.after, test)) | ||
if (hookName === 'afterSuite') event.emit(event.suite.after, suite) | ||
if (hookName === 'before' || hookName === 'beforeSuite') { |
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.
[nitpick] Consider using a switch statement or array includes for better readability when checking multiple hook types, especially as this pattern is repeated throughout the function.
if (hookName === 'before' || hookName === 'beforeSuite') { | |
if (['before', 'beforeSuite'].includes(hookName)) { |
Copilot uses AI. Check for mistakes.
Motivation/Description of the PR
Applicable helpers:
Applicable plugins:
Type of change
Checklist:
npm run docs
)npm run lint
)npm test
)