Skip to content

Comments

fix(snapshot): fix indent normalization#7400

Merged
sheremet-va merged 4 commits intovitest-dev:mainfrom
hi-ogawa:fix-snapshot-object-indent-detection
Mar 28, 2025
Merged

fix(snapshot): fix indent normalization#7400
sheremet-va merged 4 commits intovitest-dev:mainfrom
hi-ogawa:fix-snapshot-object-indent-detection

Conversation

@hi-ogawa
Copy link
Contributor

@hi-ogawa hi-ogawa commented Feb 1, 2025

Description

I couldn't tell why prepareExpected is needed since stripSnapshotIndentation already takes care of inline snapshot indent normalization. Removing prepareExpected didn't break any tests, such as the ones added in #1232.

Please don't delete this checklist! Before submitting the PR, please make sure you do the following:

  • It's really useful if your PR references an issue where it is discussed ahead of time. If the feature is substantial or introduces breaking changes without a discussion, PR might be closed.
  • Ideally, include a test that fails without this PR but passes with it.
  • Please, don't make changes to pnpm-lock.yaml unless you introduce a new test example.

Tests

  • Run the tests with pnpm test:ci.

Documentation

  • If you introduce new functionality, document it. You can run documentation with pnpm run docs command.

Changesets

  • Changes in changelog are generated from PR name. Please, make sure that it explains your changes in an understandable manner. Please, prefix changeset messages with feat:, fix:, perf:, docs:, or chore:.

@netlify
Copy link

netlify bot commented Feb 1, 2025

Deploy Preview for vitest-dev ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit a513cdf
🔍 Latest deploy log https://app.netlify.com/sites/vitest-dev/deploys/679dedbec2692f0008bd6b2c
😎 Deploy Preview https://deploy-preview-7400--vitest-dev.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@hi-ogawa hi-ogawa force-pushed the fix-snapshot-object-indent-detection branch from a513cdf to b58d470 Compare February 1, 2025 09:53
@hi-ogawa hi-ogawa changed the title fix(snapshot): tweak indent normalization fix(snapshot): fix indent normalization Mar 24, 2025
@hi-ogawa hi-ogawa marked this pull request as ready for review March 24, 2025 05:39
@sheremet-va
Copy link
Member

I think this is needed to respect the file identation. If you don't have this, it will create generate this:

// ... a lot of tests
                expect().toBeUndefined()
                expect().toMatchInlineSnapshot(`
{
  foo: true
}
`

Now it does this:

// ... a lot of tests
                expect().toBeUndefined()
                expect().toMatchInlineSnapshot(`
                {
                   foo: true
                }
`

@hi-ogawa
Copy link
Contributor Author

I think this is needed to respect the file identation. If you don't have this, it will create generate this:

Can you provide runnable code? I don't think this PR changes indent of snapshots generation. That would've been caught by test/snapshots/test-update.

@sheremet-va sheremet-va merged commit 8299709 into vitest-dev:main Mar 28, 2025
13 checks passed
@hi-ogawa hi-ogawa deleted the fix-snapshot-object-indent-detection branch March 29, 2025 02:11
Tobbe added a commit to cedarjs/cedar that referenced this pull request Jun 28, 2025
I was upgrading to Vitest 3.x and noticed one of our snapshot tests
started failing. Looking into it I realized we weren't handling
whitespace properly when setting up Supertokens auth. This PR fixes
that.

I'm guessing this is the Vitest change that caused the diff in
snapshots: vitest-dev/vitest#7400
It doesn't say in the PR description, but the [release notes for Vitest
3.1.0](https://github.com/vitest-dev/vitest/releases/tag/v3.1.0), where
it was first included, says
> This change can cause small amount of very old snapshots to be
updated, but there will be no functional change to how they work.
Tobbe added a commit to cedarjs/cedar that referenced this pull request Jun 28, 2025
Updates from Vite 2.x to latest 3.x release

Had to update two tests because of breaking changes between v2 and v3
vitest-dev/vitest#5876
vitest-dev/vitest#7400
Tobbe added a commit to cedarjs/cedar that referenced this pull request Jul 6, 2025
I was upgrading to Vitest 3.x and noticed one of our snapshot tests
started failing. Looking into it I realized we weren't handling
whitespace properly when setting up Supertokens auth. This PR fixes
that.

I'm guessing this is the Vitest change that caused the diff in
snapshots: vitest-dev/vitest#7400
It doesn't say in the PR description, but the [release notes for Vitest
3.1.0](https://github.com/vitest-dev/vitest/releases/tag/v3.1.0), where
it was first included, says
> This change can cause small amount of very old snapshots to be
updated, but there will be no functional change to how they work.
Tobbe added a commit to cedarjs/cedar that referenced this pull request Jul 6, 2025
Updates from Vite 2.x to latest 3.x release

Had to update two tests because of breaking changes between v2 and v3
vitest-dev/vitest#5876
vitest-dev/vitest#7400
quilicicf added a commit to quilicicf/mermaid that referenced this pull request Jul 14, 2025
Ran `pnpm update` and fixed these two issues :

* Line breaks removed from nested lists in mardkown, see [Prettier release notes](https://prettier.io/blog/2025/06/23/3.6.0#change-16637)
* Vitest snapshots indent normalization, see [Vitest release notes](https://github.com/vitest-dev/vitest/releases/tag/v3.1.0) ([relevant change](vitest-dev/vitest#7400))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Unreadable diff for large HTML snapshot

2 participants