Skip to content

vitest UI doesn't log html correctly in the "console log" tab. #1279

@MarkLyck

Description

@MarkLyck

Describe the bug

When trying to log out HTML text in the console log with vitest UI, vitest UI is cutting up the output a lot, missing entire tags and symbols.

Example of broken output:
Screen Shot 2022-05-09 at 11 08 56

This is what the exact same output looks like in my terminal:
Screen Shot 2022-05-09 at 11 09 53

vitest UI seems to be removing all lines starting with < so entire lines like <body> are missing in the output.

This makes it extremely hard to debug anything to do with HTML when using vitest UI and I have to revert to using my console every time.

As a React developer who uses @testing-library/react and screen.debug() a lot. I am constantly looking at HTML output in my tests.

Reproduction

Try to console log any HTML in a test with vitest UI.

Or use React testing library's screen.debug method in any component to see the broken output.

System Info

System:
    OS: macOS 12.3.1
    CPU: (10) arm64 Apple M1 Max
    Memory: 3.49 GB / 32.00 GB
    Shell: 5.8 - /bin/zsh
  Binaries:
    Node: 18.0.0 - /usr/local/bin/node
    Yarn: 1.22.17 - /usr/local/bin/yarn
    npm: 8.6.0 - /usr/local/bin/npm
  Browsers:
    Brave Browser: 101.1.38.111
    Chrome: 101.0.4951.54
    Firefox: 99.0.1
    Safari: 15.4
  npmPackages:
    @vitejs/plugin-react: 1.3.2 => 1.3.2
    vite: 2.9.8 => 2.9.8
    vitest: ^0.12.1 => 0.12.1

Used Package Manager

pnpm

Validations

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions