vitest-dev / vitest-dev/vitest

Calling a function on a value named 'test' in a type test fails with `TypeError: Cannot read properties of undefined (reading 'start')`

Open
#7,432 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

feat: typecheck p2-edge-case
Dominant language
TypeScript
Stars
17.1k
Forks
2k
Avg merge
1d 22h
Merged PRs (30d)
94

Description

Describe the bug

Calling any function without any arguments on a variable named test (or it, describe, or suite) in a type test causes the test runner to crash with TypeError: Cannot read properties of undefined (reading 'start'). I have traced this issue to: https://github.com/vitest-dev/vitest/blob/b997355be71220c098563b1a60056eb57f4d4d90/packages/vitest/src/typecheck/collect.ts#L147

Reproduction

https://stackblitz.com/edit/vitest-dev-vitest-4ad7gp5b?file=test%2Fbug.types.ts

System Info
System:
    OS: macOS 15.3
    CPU: (14) arm64 Apple M4 Pro
    Memory: 69.95 MB / 48.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 22.12.0 - ~/.nvm/versions/node/v22.12.0/bin/node
    Yarn: 1.22.22 - /usr/local/bin/yarn
    npm: 10.9.0 - ~/.nvm/versions/node/v22.12.0/bin/npm
    Watchman: 2024.11.18.00 - /run/current-system/sw/bin/watchman
  Browsers:
    Chrome: 120.0.6099.129
    Safari: 18.3
    Safari Technology Preview: 18.2
  npmPackages:
    @vitejs/plugin-react: 4.3.4 => 4.3.4 
    @vitest/ui: 3.0.4 => 3.0.4 
    vitest: 3.0.4 => 3.0.4
Used Package Manager

npm

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

Run the linked StackBlitz reproduction to confirm the crash, then inspect packages/vitest/src/typecheck/collect.ts around line 147. Trace how zero-argument calls on variables named test, it, describe, or suite are collected, and verify that the type test completes without the undefined start error.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
testing-qa
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.