-
-
Couldn't load subscription status.
- Fork 1.5k
Open
Copy link
Labels
p3-minor-bugAn edge case that only affects very specific usage (priority)An edge case that only affects very specific usage (priority)
Description
Describe the bug
Description:
This is a bit of an edge case, but I thought I'd report it anyway:
It seems like Vitest is unable to write a snapshot to the file if a comment separates toMatchInlineSnapshot and ().
This had me confused for a minute, because the test runner does not report the failure unless the snapshot is incorrect.
Reproduction
Sandbox: StackBlitz
Example:
import * as vi from 'vitest';
// Repro: type 'u' in the terminal to see the snapshots fail to update
vi.test('snapshot w/ comment between assertion and target node does not write', () => {
vi.expect(
0
).toMatchInlineSnapshot
// This comment breaks snapshot updates
();
});System Info
System:
OS: macOS 14.6.1
CPU: (10) arm64 Apple M1 Pro
Memory: 127.13 MB / 16.00 GB
Shell: 3.3.1 - /usr/local/bin/fish
Binaries:
Node: 24.4.1 - ~/.local/state/fnm_multishells/46602_1758709423661/bin/node
npm: 11.4.2 - ~/.local/state/fnm_multishells/46602_1758709423661/bin/npm
pnpm: 10.15.1 - ~/Library/pnpm/pnpm
Browsers:
Chrome: 140.0.7339.214
Safari: 17.6
npmPackages:
@vitest/coverage-v8: catalog: => 3.2.4
@vitest/ui: catalog: => 3.2.4
vitest: catalog: => 3.2.4Used Package Manager
pnpm
Validations
- Follow our Code of Conduct
- Read the Contributing Guidelines.
- Read the docs.
- Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
- Check that this is a concrete bug. For Q&A open a GitHub Discussion or join our Discord Chat Server.
- The provided reproduction is a minimal reproducible example of the bug.
Metadata
Metadata
Assignees
Labels
p3-minor-bugAn edge case that only affects very specific usage (priority)An edge case that only affects very specific usage (priority)