feat(core): add task metadata support#1507
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: a5a0236018
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Deploying rstest with
|
| Latest commit: |
400358c
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://5e60f5ca.rstest.pages.dev |
| Branch Preview URL: | https://feat-task-metadata.rstest.pages.dev |
There was a problem hiding this comment.
Pull request overview
This PR adds first-class “task metadata” support to @rstest/core so users can initialize metadata via TestOptions.meta, inherit it through nested describe blocks (shallow merge with child keys overriding), and mutate it at runtime via context.task.meta (tests) and ctx.meta (suite/file hooks). The resolved metadata is then exposed consistently through reporter hooks and the programmatic runRstest results.
Changes:
- Extend core task/result types (
TestCaseInfo,TestSuiteInfo,TestResult,SuiteContext,TestOptions,TestContext.task) withmetaand document the semantics. - Implement metadata initialization + inheritance in the runtime collector, and plumb metadata through runner events/results (including
TestFileResult.meta). - Add/extend unit + e2e coverage verifying inheritance, isolation between siblings, reporter hook visibility, and programmatic API visibility.
Reviewed changes
Copilot reviewed 23 out of 23 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| website/docs/zh/api/runtime-api/test-api/test.mdx | Documents TestOptions.meta and context.task.meta usage in the runtime test API (ZH). |
| website/docs/zh/api/runtime-api/test-api/hooks.mdx | Documents ctx.meta behavior and how hook-written metadata surfaces in results (ZH). |
| website/docs/zh/api/runtime-api/test-api/describe.mdx | Documents suite-level meta inheritance/override semantics (ZH). |
| website/docs/zh/api/javascript-api/types.mdx | Notes how TestResult.meta / TestFileResult.meta are populated and surfaced (ZH). |
| website/docs/zh/api/javascript-api/reporter.mdx | Documents where reporters can read runtime vs hook metadata (ZH). |
| website/docs/en/api/runtime-api/test-api/test.mdx | Documents TestOptions.meta and context.task.meta usage in the runtime test API (EN). |
| website/docs/en/api/runtime-api/test-api/hooks.mdx | Documents ctx.meta behavior and how hook-written metadata surfaces in results (EN). |
| website/docs/en/api/runtime-api/test-api/describe.mdx | Documents suite-level meta inheritance/override semantics (EN). |
| website/docs/en/api/javascript-api/types.mdx | Notes how TestResult.meta / TestFileResult.meta are populated and surfaced (EN). |
| website/docs/en/api/javascript-api/reporter.mdx | Documents where reporters can read runtime vs hook metadata (EN). |
| packages/core/tests/runner/runtime.test.ts | Adds unit tests for metadata initialization, inheritance, overrides, and sibling isolation. |
| packages/core/src/types/testSuite.ts | Introduces TaskMeta and adds meta to task info/results plus SuiteContext. |
| packages/core/src/types/api.ts | Adds TestOptions.meta and TestContext.task.meta to the public runtime API types. |
| packages/core/src/runtime/runner/runtime.ts | Implements metadata initialization on tasks and shallow inheritance during collection. |
| packages/core/src/runtime/runner/runner.ts | Threads metadata through suite/file/test execution contexts and emitted results. |
| packages/core/src/runtime/runner/index.ts | Includes metadata when converting internal tasks to public TestInfo. |
| packages/core/src/api/index.ts | Exposes meta on the programmatic API TestResult/TestFileResult mapping. |
| e2e/reporter/rstest.metadataReporterConfig.ts | Adds a custom reporter fixture that prints captured metadata from hooks. |
| e2e/reporter/index.test.ts | Adds e2e assertions that reporter hooks receive the expected metadata snapshots/finals. |
| e2e/reporter/fixtures/metadata.test.ts | Adds fixture tests that mutate ctx.meta and ctx.task.meta for e2e validation. |
| e2e/programmatic/index.test.ts | Adds e2e assertions that runRstest returns metadata in file/case/suite results. |
| e2e/programmatic/fixtures/run-metadata.mjs | Adds a programmatic runner fixture that collects metadata via reporters + API results. |
| e2e/programmatic/fixtures/disk/sum.test.ts | Updates programmatic disk fixture to write metadata from hooks and test context. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 0ed91658d6
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
# Conflicts: # packages/core/src/runtime/runner/runner.ts
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: ac59f0e82d
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 400358c9dd
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Summary
This PR adds metadata support for tests, suites, file results, and custom reporters.
TestOptions.metainitializes task metadata, suite metadata is shallow-inherited by descendant suites and tests with child keys overriding parent keys, and runtime updates throughcontext.task.meta/ hookctx.metaare exposed through programmatic results and reporter hooks.Example
Custom reporters can read the resolved metadata from case, suite, and file results:
Checklist