Skip to content

Conversation

@macarie
Copy link
Member

@macarie macarie commented Nov 24, 2025

Description

Add fullName and fullTestName to TaskBase.

  • fullName is the concatenation of any parent suites and the task's name using > as a separator, it includes the file path.
  • fullTestName is like fullName, excluding the file path. It's undefined for File tasks.

This should be the last necessary step towards a fix for #8853.

Please don't delete this checklist! Before submitting the PR, please make sure you do the following:

  • It's really useful if your PR references an issue where it is discussed ahead of time. If the feature is substantial or introduces breaking changes without a discussion, PR might be closed.
  • Ideally, include a test that fails without this PR but passes with it.
  • Please, don't make changes to pnpm-lock.yaml unless you introduce a new test example.
  • Please check Allow edits by maintainers to make review process faster. Note that this option is not available for repositories that are owned by Github organizations.

Tests

  • Run the tests with pnpm test:ci.

Documentation

  • If you introduce new functionality, document it. You can run documentation with pnpm run docs command.

Changesets

  • Changes in changelog are generated from PR name. Please, make sure that it explains your changes in an understandable manner. Please, prefix changeset messages with feat:, fix:, perf:, docs:, or chore:.

@macarie macarie requested a review from sheremet-va November 24, 2025 10:41
Copy link
Member Author

Choose a reason for hiding this comment

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

This test should most likely never change, so I kept manual assertions for debuggability. Could convert to a snapshot or something more automated if necessary.


allChildren.forEach((task) => {
task.file = file
task.fullName = createTaskName([file.fullName, task.fullName])
Copy link
Member Author

Choose a reason for hiding this comment

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

Not entirely sure about this. file seems to be "injected" at a later stage, so to include the file path I had to change all children's fullName. Is there a better way of doing this?

Copy link
Member

Choose a reason for hiding this comment

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

yeah, it seems weird that it works like that, maybe we can add the file sooner?


export function getTestName(task: Task, separator = ' > '): string {
return getNames(task).slice(1).join(separator)
return createTaskName(getNames(task).slice(1), separator)
Copy link
Member

Choose a reason for hiding this comment

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

This just adds more loops, let's keep these two as they were


allChildren.forEach((task) => {
task.file = file
task.fullName = createTaskName([file.fullName, task.fullName])
Copy link
Member

Choose a reason for hiding this comment

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

yeah, it seems weird that it works like that, maybe we can add the file sooner?

sheremet-va
sheremet-va previously approved these changes Nov 25, 2025
Copy link
Member

@sheremet-va sheremet-va left a comment

Choose a reason for hiding this comment

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

Looks good, just some refactoring ideas

runner.onCollectStart?.(file)

clearCollectorContext(filepath, runner)
clearCollectorContext(filepath, runner, file)
Copy link
Member

@sheremet-va sheremet-va Nov 25, 2025

Choose a reason for hiding this comment

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

We can just pass down file first and get file.filepath from it inside the function

): void {
if (!defaultSuite) {
defaultSuite = createDefaultSuite(currentRunner)
defaultSuite = createDefaultSuite(currentRunner, file)
Copy link
Member

Choose a reason for hiding this comment

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

Maybe it's better to assign it after it's created/read here? (on line 225) If defaultSuite already exists in isolate: false, I think it will have incorrect file at one point

@sheremet-va sheremet-va merged commit 821aa20 into vitest-dev:main Nov 25, 2025
15 of 16 checks passed
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.

2 participants