vitest-dev / vitest-dev/vitest

Watch mode test target tracking for file path+line input

Open
#8,075 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement: pending triage
Dominant language
TypeScript
Stars
17.1k
Forks
2k
Avg merge
1d 22h
Merged PRs (30d)
94

Description

Clear and concise description of the problem

I am using Zed tasks (but could be VSCode etc.) and have this config:

{
    "label": "vitest line (watch)",
    "command": "npx vitest",
    "args": ["$ZED_FILE:$ZED_ROW"],
}

This works initially. However if the test file is changed such that the test no longer begins on line $ZED_ROW then Vitest will say that no test is found in the given file. Is there a strong reason for this behaviour being desirable and reasonable?

Suggested solution

In watch mode if Vitest receives a <file path>:line input, then it should cache what fully qualified test this evaluates to (describe > describe > ... > it etc.) and from then on be running based on:

  1. Full test file path
  2. Full test name

I would accept that Vitest watch fails to track the following:

  1. I change the test file path
  2. I change the test path (its name, or ancestor describe names)
Alternative

No response

Additional context

No response

Validations

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

No repository file or test is named. Start by reproducing the issue with npx vitest : in watch mode, then trace how file-and-line inputs are resolved and retained between runs. Done means watch mode follows the originally resolved full test path and name after line changes, while documented path or test-name changes may stop tracking.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
testing-qa
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.