Skip to content

Expose updateSnapshot via SnapshotState #9481

@foxable

Description

@foxable

Clear and concise description of the problem

As a developer using Vitest I want to read the current value of updateSnapshot in order to implement custom snapshot matchers following the update behavior of Vitests own snapshot matchers.

Suggested solution

Expose updateSnapshot as a public and typed property on SnapshotState, which can be accessed from Vitest matchers using expect.getState().snapshotState.

Currently, the value of updateSnapshot is only accessible through the internal property _updateSnapshot on snapshotState, which is not typed and can be subject to change.

Alternative

No response

Additional context

There is a related open issue regarding the --update flag, but is has a slightly different context and intention. That's why I opened a new issue. If you prefer, I'm open to add my request to the existing issue. In this case, you can close my request.

Validations

Metadata

Metadata

Assignees

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions