Skip to content

toMatchScreenshot still creates a folder with the test's filename even when specifing otherwise #8604

@michaelhazan

Description

@michaelhazan

Describe the bug

I have specified in the vitest.config.ts a different path for the screenshot directory like so:

resolveScreenshotPath: ({ root, testFileDirectory, screenshotDirectory, arg, browserName, platform, ext }) => 
    `${root}/${testFileDirectory}/${screenshotDirectory}/${arg}-${browserName}-${platform}${ext}`,

resolveDiffPath: ({ root, testFileDirectory, screenshotDirectory, arg, browserName, platform, ext }) => 
    `${root}/${testFileDirectory}/${screenshotDirectory}/diff/${arg}-${browserName}-${platform}${ext}`,

and yet whenever i update my screenshot with the command pnpm vitest run --update, it creates the folder with the test file's name (in this screenshot the file name is button.visual.spec.tsx)

Image

also important to note that as you can see, it doesnt insert any of the files into it, but simply creates it.

Reproduction

i feel like the issue is pretty straight forward... if a reproduction is absolutely necessary ill make one.

System Info

System:
    OS: macOS 15.6.1
    CPU: (8) x64 Intel(R) Core(TM) i7-7700HQ CPU @ 2.80GHz
    Memory: 248.60 MB / 16.00 GB
    Shell: 5.3.3 - /usr/local/bin/bash
  Binaries:
    Node: 22.18.0 - ~/.nvm/versions/node/v22.18.0/bin/node
    npm: 10.9.3 - ~/.nvm/versions/node/v22.18.0/bin/npm
    pnpm: 10.16.1 - ~/.nvm/versions/node/v22.18.0/bin/pnpm
    Watchman: 2025.08.25.00 - /usr/local/bin/watchman
  Browsers:
    Chrome: 140.0.7339.133
    Safari: 18.6
  npmPackages:
    @vitejs/plugin-react: catalog: => 5.0.2
    @vitest/browser: ^4.0.0-beta.11 => 4.0.0-beta.11
    @vitest/coverage-v8: ^4.0.0-beta.11 => 4.0.0-beta.11
    @vitest/ui: ^4.0.0-beta.11 => 4.0.0-beta.11
    playwright: ^1.55.0 => 1.55.0
    vite: catalog: => 6.3.6
    vitest: ^4.0.0-beta.11 => 4.0.0-beta.11
    vitest-browser-react: ^2.0.0-beta.3 => 2.0.0-beta.3

Used Package Manager

pnpm

Validations

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions