Skip to content

Does not recognize __vi_import_ prefix in static test discovery #10128

@Yejneshwar

Description

@Yejneshwar

Describe the bug

Description

Test discovery via the static AST parser silently drops it/test calls when a file contains both:

  1. A vi.mock() statement (even commented out)
  2. An extended test function imported from a separate module (e.g. import { it } from "./utils/test-extend.js")

Reproduction

Given this test file:

import { describe } from 'vitest'
import { it } from "./Utils/test-extend.js"

// vi.mock('@/composables/test.js', async (importOriginal) => { });

describe('my suite', () => {
  it('should work', () => {})
})

Where test-extend.js exports an extended test:

import { test as baseTest } from 'vitest'
export const it = baseTest.extend({ /* fixtures */ })

Expected: Both describe and it are discovered by the static parser (gutter icons appear).
Actual: Only describe is discovered; it calls are silently skipped.

Removing either the vi.mock line or the extended import makes it work — the combination of both is required to trigger the bug.

Reproduction

StackBlitz

https://stackblitz.com/edit/vitest-dev-vitest-kdxvkvnr

System Info

System:
    OS: Linux 5.0 undefined
    CPU: (8) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
    Memory: 0 Bytes / 0 Bytes
    Shell: 1.0 - /bin/jsh
  Binaries:
    Node: 22.22.0 - /usr/local/bin/node
    Yarn: 1.22.19 - /usr/local/bin/yarn
    npm: 10.8.2 - /usr/local/bin/npm
    pnpm: 8.15.6 - /usr/local/bin/pnpm
  npmPackages:
    @vitest/ui: latest => 4.1.4 
    vite: latest => 8.0.8 
    vitest: latest => 4.1.4

Used Package Manager

npm

Validations

Metadata

Metadata

Assignees

No one assigned

    Labels

    p3-minor-bugAn edge case that only affects very specific usage (priority)

    Type

    No fields configured for Bug.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions