Conversation
✅ Deploy Preview for rstest-dev ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adds task metadata support to TestContext, enabling hooks and test functions to access the current test's name and result. The implementation unifies the type signatures for beforeEach, afterEach, onTestFinished, and onTestFailed to all accept TestContext, providing a more consistent API.
Key Changes:
- Added
taskproperty toTestContextcontainingname(always available) andresult(available after test execution) - Updated hook type signatures (
beforeEach,afterEach,onTestFinished,onTestFailed) to acceptTestContext - Moved fixture initialization to occur before
beforeEachhooks to ensure context is fully populated - Updated documentation in both English and Chinese
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
packages/core/src/types/api.ts |
Added task property with name and optional result to TestContext; unified OnTestFinishedHandler and OnTestFailedHandler types to use TestContext |
packages/core/src/types/testSuite.ts |
Updated BeforeEachListener and AfterEachListener to accept TestContext parameter |
packages/core/src/runtime/runner/runner.ts |
Modified createTestContext to accept test parameter and initialize task.name; moved beforeRunTest call before beforeEach hooks; updated all hook invocations to pass test.context; added task.result population before afterEach hooks |
website/docs/en/api/test-api/test.mdx |
Documented new task property in TestContext interface |
website/docs/zh/api/test-api/test.mdx |
Documented new task property in TestContext interface (Chinese) |
website/docs/en/api/test-api/hooks.mdx |
Updated beforeEach and afterEach type signatures to show TestContext parameter |
website/docs/zh/api/test-api/hooks.mdx |
Updated beforeEach and afterEach type signatures to show TestContext parameter (Chinese) |
e2e/lifecycle/fixtures/beforeEach.test.ts |
Added test case verifying ctx.task.name is accessible in beforeEach hook |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
support get task name from test context
Related Links
Checklist