这是indexloc提供的服务,不要输入任何密码
Skip to content

🐛 Knip fails to recognize relative paths from Vitest project configurations #1317

@TrevorBurnham

Description

@TrevorBurnham

Prerequisites

Reproduction url

https://codesandbox.io/p/devbox/h4h4v7

Reproduction access

  • I've made sure the reproduction is publicly accessible

Description of the issue

Vitest correctly recognizes relative paths to setupFiles from a root Vitest config file. However, if you use Vitest's Test Projects feature, relative paths from the project-level config files are not resolved correctly:

Root Vitest config (vitest.config.mts)

export default defineConfig({
  test: {
    projects: ["app/vitest.config.mts"],
  },
});

Project config (app/vitest.config.mts)

export default defineConfig({
  test: {
    setupFiles: ["./__test__/vitest.setup.ts"],
  },
});

Knip output

Unused files (1)
app/__test__/vitest.setup.ts  
Unresolved imports (1)
./__test__/vitest.setup.ts  app/vitest.config.mts

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions