Skip to content

feat: allow calling hook methods - #5231

Merged
JoshuaKGoldberg merged 6 commits into
mochajs:mainfrom
perrin4869:feat/suite/allow-calling-hook-methods
Oct 30, 2024
Merged

JoshuaKGoldberg merged 6 commits into
mochajs:mainfrom
perrin4869:feat/suite/allow-calling-hook-methods

Conversation

@perrin4869

@perrin4869 perrin4869 commented Oct 14, 2024 •

Copy link
Copy Markdown
Contributor

PR Checklist

Overview

It seems the only reason this wasn't supported was simply the return value of calling beforeAll, etc, was not the hook itself, unlike the result of calling a function like describe, which does use the suite as the return value.
I will look into adding tests and maybe some docs

@linux-foundation-easycla

linux-foundation-easycla Bot commented Oct 14, 2024 •

Copy link
Copy Markdown

CLA Signed

The committers listed above are authorized under a signed CLA.

@JoshuaKGoldberg

JoshuaKGoldberg commented Oct 30, 2024 •

Copy link
Copy Markdown
Member

By the way, a tip: the template has a place to put the Closes #5202. 🙂

I edited it in just now.

@perrin4869

Copy link
Copy Markdown
Contributor Author

oh oops, sorry about that 😅
thanks for editing!
hm... maybe the failure is a flakey test here?

@JoshuaKGoldberg

Copy link
Copy Markdown
Member

Looks like it! I re-ran the CI job and it's all passing. Phew 😄

@perrin4869

Copy link
Copy Markdown
Contributor Author

was getting worried there for a sec!

@JoshuaKGoldberg JoshuaKGoldberg left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Looks great to me, thanks! 🙌

Comment thread lib/suite.js Resolved
Comment thread docs/index.md Resolved
@JoshuaKGoldberg JoshuaKGoldberg changed the title feat(suite): allow calling hook methods feat: allow calling hook methods Oct 30, 2024
@JoshuaKGoldberg
JoshuaKGoldberg merged commit e3da641 into mochajs:main Oct 30, 2024
lennonnikolas pushed a commit to lennonnikolas/mocha that referenced this pull request Jan 24, 2026
* feat(suite): allow calling hook methods

* add tests and docs

* fix

* address comment
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.

🚀 Feature: Allow to set timeout on before/after/beforeEach/afterEach in declaration

2 participants