Skip to content
Discussion options

You must be logged in to vote

I don't think Vitest has a built-in command that prints the whole transitive module graph for a test run, but you can get very close by logging what Vite actually transforms while Vitest is running.

A small plugin is usually enough:

// vitest.config.ts
import { defineConfig } from "vitest/config"
import { writeFileSync } from "node:fs"

function writeVitestDeps() {
  const files = new Set<string>()

  return {
    name: "write-vitest-deps",
    enforce: "post" as const,
    transform(_code: string, id: string) {
      const clean = id.split("?")[0]
      if (clean && !clean.includes("/node_modules/") && !clean.startsWith("\0")) {
        files.add(clean)
      }
      return null
    },
    

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@jennings
Comment options

@jennings
Comment options

Answer selected by jennings
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants