Skip to content

Improve snapshot tests assertion messages #7820

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 14, 2025

Conversation

mamazu
Copy link
Contributor

@mamazu mamazu commented Feb 24, 2025

The problem

When I create a test and assert that the output matches a given snapshot I write this:

$this->assertSnapshot('some-random-path.txt', $response->getContent(), 'Response content does not match');

If the file I specified does not exist however the error message was very cryptic and took some debugging to figure out what the real problem was.

The change

Before I just got a

Failed asserting that false is of type string.

Now it says:

Failed asserting that file "/some-random-path.txt" exists.

@mamazu mamazu changed the base branch from 2.6 to 3.0 February 24, 2025 14:33
@mamazu mamazu force-pushed the more_helpful_errors branch 2 times, most recently from e2af500 to fa996f5 Compare February 24, 2025 14:43
@mamazu mamazu force-pushed the more_helpful_errors branch from fa996f5 to 7393c80 Compare February 24, 2025 14:43
@mamazu mamazu changed the title More helpful errors Improve snapshot tests assertion messages Mar 10, 2025
@alexander-schranz alexander-schranz merged commit 0f24fbf into sulu:3.0 May 14, 2025
9 checks passed
@alexander-schranz alexander-schranz added the DX Affecting the end developer label May 14, 2025
@mamazu mamazu deleted the more_helpful_errors branch May 14, 2025 11:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
DX Affecting the end developer
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants