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.
Pull Request Overview
This PR introduces a new onTestFinished hook that executes after test completion regardless of test result, providing a mechanism for cleanup actions. The hook runs after afterEach hooks and supports both synchronous and asynchronous operations with timeout configuration.
Key changes:
- Added
onTestFinishedAPI to the test framework with timeout support - Implemented proper execution order (after
afterEachhooks) - Added comprehensive test coverage for success, failure, and error scenarios
Reviewed Changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| packages/core/src/types/api.ts | Defines the OnTestFinishedHandler type and adds onTestFinished to the RunnerAPI interface |
| packages/core/src/runtime/runner/runner.ts | Core implementation of the onTestFinished functionality with timeout wrapping and execution logic |
| packages/core/src/runtime/runner/runtime.ts | Updates the runtime API type to exclude onTestFinished from the base implementation |
| packages/core/src/runtime/runner/index.ts | Integrates onTestFinished into the final runner API by forwarding calls to the TestRunner instance |
| packages/core/src/runtime/api/public.ts | Exports the onTestFinished function for public API consumption |
| website/docs/en/api/test-api/hooks.mdx | English documentation for the new hook with usage examples |
| website/docs/zh/api/test-api/hooks.mdx | Chinese documentation for the new hook with usage examples |
| e2e/lifecycle/onTestFinished.test.ts | Comprehensive end-to-end tests covering execution order, error handling, and validation |
| e2e/lifecycle/fixtures/*.test.ts | Test fixtures demonstrating various scenarios including success, failure, and misuse cases |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
|
|
||
| test('test server', () => { | ||
| const server = startServer(); | ||
| // Register a cleanup function to close the server after the test |
There was a problem hiding this comment.
The comment is in English while the documentation is in Chinese. Consider translating the comment to Chinese for consistency: // 注册清理函数在测试后关闭服务器
| // Register a cleanup function to close the server after the test | |
| // 注册清理函数在测试后关闭服务器 |
Summary
onTestFinishedhook will called after the test has finished running whatever the test result is. This can be used to perform cleanup actions. This hook will be called afterafterEach.Related Links
Checklist