Skip to content

bug: inline snapshots are tab-indented in vite-plus/test #1553

@GabbeV

Description

@GabbeV

Describe the bug

vite-plus@0.1.20 writes tab-indented multiline inline snapshots even when the surrounding test file uses two-space indentation.

This looks specific to Vite+ packaging rather than upstream Vitest. The bundled vite-plus/test code ends up with:

const indentNext = indent.includes("  ") ? `${indent}\t` : `${indent}  `;

Upstream Vitest uses indent.includes("\t") here.

The likely cause is Vite+'s convertTabsToSpaces() build step rewriting literal tab characters inside copied JS string literals.

Reproduction

Minimal reproduction is described in the Steps to reproduce section below.

Steps to reproduce

  1. Create a minimal project with vite-plus@0.1.20.
  2. Add this test in a normal two-space-indented file:
import { describe, expect, it } from "vite-plus/test";

describe("inline snapshot indentation", () => {
  it("writes multiline snapshots using the surrounding file indentation style", () => {
    expect("alpha\nbeta").toMatchInlineSnapshot();
  });
});
  1. Run npm install.
  2. Run vp test --update.
  3. Inspect the generated inline snapshot.

Actual output uses tabs in the snapshot body:

    [TAB]"alpha
    [TAB]beta"

Expected output should use spaces to match the file indentation style.

System Info

VITE+ - The Unified Toolchain for the Web

Environment:
  Version       24.15.0
  Source        engines.node
  Source Path   C:\Users\Gabriel\Code\csslit\package.json
  Project Root  C:\Users\Gabriel\Code\csslit

Tool Paths:
  node  C:\Users\Gabriel\.vite-plus\js_runtime\node\24.15.0\node.exe
  npm   C:\Users\Gabriel\.vite-plus\js_runtime\node\24.15.0\npm.cmd
  npx   C:\Users\Gabriel\.vite-plus\js_runtime\node\24.15.0\npx.cmd

VITE+ - The Unified Toolchain for the Web

vp v0.1.14

Local vite-plus:
  vite-plus  v0.1.20

Tools:
  vite             v8.0.10
  rolldown         v1.0.0-rc.17
  vitest           v4.1.5
  oxfmt            v0.46.0
  oxlint           v1.61.0
  oxlint-tsgolint  v0.22.0
  tsdown           v0.21.10

Environment:
  Package manager  npm v11.12.0
  Node.js          v24.15.0 (engines.node)

Used Package Manager

npm

Logs

VITE+ - The Unified Toolchain for the Web

 RUN  <project>

 ✓ src/inline-snapshot.test.ts (1 test) 4ms
   ✓ inline snapshot indentation (1)
     ✓ writes multiline snapshots using the surrounding file indentation style 3ms

  Snapshots  1 written
 Test Files  1 passed (1)
      Tests  1 passed (1)
   Duration  429ms (transform 12ms, setup 0ms, import 29ms, tests 4ms, environment 0ms)

Validations

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

Priority

None yet

Effort

None yet

Target date

None yet

Start date

None yet

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions