Skip to content

Setting browser.screenshotDirectory leads to two folders being created #9636

@finalyards

Description

@finalyards

Describe the bug

If I set browser.screenshotDirectory and run my tests, I get:

 FAIL   visual (chromium)  tests/routes/(home)/visual.test.ts > Landing page (visuals) > ..looks like before
Error: expect(element).toMatchScreenshot()

No existing reference screenshot found; a new one was created. Review it before running tests again.

Reference screenshot:
  /home/ubuntu/website.1/tests/routes/(home)/home/ubuntu/website.1/__shots__/visual.test.ts/home-chromium-linux.png


Failure screenshot:
  - __shots__/tests/routes/(home)/visual.test.ts/Landing-page--visuals----looks-like-before-1.png

While the "Failure screenshot" path is as expected, the "Reference screenshot" path is strange.

Expectation:

  • only one folder to be named (__shots__/tests/routes/[...])

Actual:

  • a second, strange path gets created

vitest 4.0.17, 4.0.18

Reproduction

Sorry no MVR at this hour.. Going on a trip and wanted at least to share this, in hopes a fix might land by 4.1.

System Info

System:
    OS: Linux 6.8 Ubuntu 24.04.3 LTS 24.04.3 LTS (Noble Numbat)
    CPU: (2) x64 06/9e
    Memory: 2.53 GB / 3.82 GB
    Container: Yes
    Shell: 5.2.21 - /bin/bash
  Binaries:
    Node: 24.13.0 - /usr/bin/node
    npm: 11.6.2 - /usr/bin/npm
  npmPackages:
    @vitest/browser-playwright: ^4.0.18 => 4.0.18 
    @vitest/ui: ^4.0.15 => 4.0.18 
    playwright: ^1.58.0 => 1.58.2 
    vite: 8.0.0-beta.13 => 8.0.0-beta.13 
    vitest: ^4.0.18 => 4.0.18 
    vitest-browser-svelte: ^2.0.2 => 2.0.2

Used Package Manager

npm

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