-
-
Notifications
You must be signed in to change notification settings - Fork 14
docs: introduce beforeEach / beforeAll returns #607
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
Conversation
✅ Deploy Preview for rstest-dev ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
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 documents a feature in Rstest where beforeEach and beforeAll hooks can return cleanup functions that automatically run after tests complete. The documentation is added to both English and Chinese versions of the migration guide and API reference.
- Documents return function capabilities for beforeEach/beforeAll hooks
- Provides code examples showing cleanup pattern implementation
- Updates both migration guide and API documentation
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| website/docs/zh/guide/migration/jest.mdx | Adds Chinese documentation for hook return functions in Jest migration guide |
| website/docs/zh/api/test-api/hooks.mdx | Adds Chinese API documentation with examples for beforeAll and beforeEach return functions |
| website/docs/en/guide/migration/jest.mdx | Adds English documentation for hook return functions in Jest migration guide |
| website/docs/en/api/test-api/hooks.mdx | Adds English API documentation with examples for beforeAll and beforeEach return functions |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
|
|
||
| ```diff | ||
| - beforeEach(() => doSomething()); | ||
| + beforeEach(() => { doSomething() }); |
Copilot
AI
Sep 29, 2025
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.
The migration example doesn't clearly demonstrate the cleanup function feature being documented. The diff only shows adding braces around doSomething() without showing how to return a cleanup function. Consider showing an example that actually returns a cleanup function to illustrate the feature.
| + beforeEach(() => { doSomething() }); | |
| + beforeEach(() => { | |
| + doSomething(); | |
| + return () => cleanupSomething(); | |
| + }); |
|
|
||
| ```diff | ||
| - beforeEach(() => doSomething()); | ||
| + beforeEach(() => { doSomething() }); |
Copilot
AI
Sep 29, 2025
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.
The migration example doesn't clearly demonstrate the cleanup function feature being documented. The diff only shows adding braces around doSomething() without showing how to return a cleanup function. Consider showing an example that actually returns a cleanup function to illustrate the feature.
| + beforeEach(() => { doSomething() }); | |
| - afterEach(() => cleanupSomething()); | |
| + beforeEach(() => { | |
| + doSomething(); | |
| + return () => cleanupSomething(); | |
| + }); |
Summary
The return functions of the
beforeEachandbeforeAllhooks in Rstest are used to perform cleaning work after testing.Related Links
Checklist