Skip to content

Can't serve @vitest/ui report on a subpath #3481

@segevfiner

Description

@segevfiner

Describe the bug

Upload a vitest/ui generated report to a subpath in an HTTP server (And make sure the .gz file is served with an Content-Type: application/gzip, or Content-Encoding: gzip which might also work). You will get a blank page. The report only works at the root path of a site, disallowing uploading it somewhere for others to view. (e.g. From CI).

That is, it works when the URL is:
http://somewhere.com/

But fails if it is:
http://somewhere.com/vitest-report/

Such reports are very useful to upload to a shared server for others to easily view from CI, but they need to handle being served from any subpath for this to work properly.

Reproduction

Generate any @vitest/ui report, and use caddy run (Install caddy) with the following Caddyfile and the report in a subdirectory.

http://localhost:8080

@gz {
	path *.gz
}

header @gz Content-Type application/gzip

file_server browse

e.g.

  • Caddyfile
  • report/
    • index.html

And try to access http://localhost:8080/report/, you will get a blank page, no errors in the console.

System Info

System:
    OS: macOS 13.4
    CPU: (10) arm64 Apple M1 Pro
    Memory: 57.72 MB / 16.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 16.20.0 - ~/.nvm/versions/node/v16.20.0/bin/node
    npm: 9.6.7 - ~/.nvm/versions/node/v16.20.0/bin/npm
  Browsers:
    Chrome: 113.0.5672.126
    Safari: 16.5
  npmPackages:
    @vitejs/plugin-vue: ^4.0.0 => 4.1.0 
    @vitest/ui: ^0.31.2 => 0.31.2 
    vite: ^4.1.4 => 4.2.1 
    vitest: ^0.31.2 => 0.31.2

Used Package Manager

pnpm

Validations

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions