Skip to content

Conversation

@iumehara
Copy link

Description

Resolves #8673

  • toMatchSnapshot, matchSnapshot, toMatchFileSnapshot, toThrowErrorMatchingSnapshot can be used with expect.soft. These methods use the existing wrapAssertion function from expect utils.
  • toMatchInlineSnapshot, toThrowErrorMatchingInlineSnapshot could not easily support expect.soft. These methods now throw an error if used with expect.soft

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.
  • Please check Allow edits by maintainers to make review process faster. Note that this option is not available for repositories that are owned by Github organizations.

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:.

- toMatchSnapshot, matchSnapshot, toMatchFileSnapshot, toThrowErrorMatchingSnapshot
  can be used with expect.soft
- toMatchInlineSnapshot, toThrowErrorMatchingInlineSnapshot do not support expect.soft
  and throw an error if used with expect.soft
@netlify
Copy link

netlify bot commented Dec 11, 2025

Deploy Preview for vitest-dev ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit 66eb049
🔍 Latest deploy log https://app.netlify.com/projects/vitest-dev/deploys/693ad0a6bd66a50008f84893
😎 Deploy Preview https://deploy-preview-9231--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 project configuration.

Copy link
Contributor

@hi-ogawa hi-ogawa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you create tests in test/snapshots? test/core only allows single run, so it's probably hard to poke the edge cases here (e.g. creation scenario, update scenario, non-match scenario, etc)

@iumehara
Copy link
Author

@hi-ogawa , can you clarify what I should test in test/snapshots?
It seems like the edge cases (ie. creation, update) will ALWAYS pass. Is that not the case? If so, it'll never exercise the new behavior, which is a side-effect of a failing snapshot test.
Is it that you would like test coverage for assurance that expet.soft has no unexpected side-effects in the success scenario? Or is there something else that I am missing?

@hi-ogawa
Copy link
Contributor

Sorry, my suggestion was a bit vague and I don't have concrete suggestion. Some ideas are:

  • it looks like currently tests are relying on manipulating snapshotState and result.state from tests itself to simulate certain scenarios. this feels a bit brittle and ideally each scenario should be tested in a more realistic way like users would actually write tests.
  • for example, test/snapshots/test/skip-test.test.ts runs same test suites multiple times with different config/snapshot to test various scenarios.

@hi-ogawa
Copy link
Contributor

For example, one "brittleness" is that current tests would break with force update pnpm test snapshot-test -u. So this type of tests should belong to elsewhere in general.

@iumehara
Copy link
Author

iumehara commented Dec 16, 2025

@hi-ogawa , thanks for your detailed input.
I moved the testing to the snapshots directory like you suggested.
I defined an AlwaysFailingSnapshotSerializer in order to test the failure tracking behavior across the different scenarios.
Please let me know what you think.

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.

expect.soft doesnt work with toMatchSnapshot

2 participants