Skip to content
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

[Vitest 2.x] Browser mode failure snapshots directory name can conflict with other tools #6239

Closed
6 tasks done
yannbf opened this issue Jul 29, 2024 · 3 comments
Closed
6 tasks done
Labels
p4-important Violate documented behavior or significantly improves performance (priority)

Comments

@yannbf
Copy link
Contributor

yannbf commented Jul 29, 2024

Describe the bug

When testing story files from Storybook using Vitest (e.g. Button.stories.tsx), the failures generate a directory like __screenshots__/Button.stories.tsx/FailingStoryName.png:

image

However because the Storybook indexer uses globs that match *.stories.*, it ends up detecting the directory too.
While Storybook could improve its matching mechanics, being able to modify the names used in the snapshots like Jest's snapshotResolver would be quite useful. There could be other tools which might conflict because of similar situations.

If Vitest appended .snap at the end of the directory name, this would also fix the issue.

Used Package Manager

npm

Validations

@sheremet-va sheremet-va added p4-important Violate documented behavior or significantly improves performance (priority) and removed pending triage labels Jul 29, 2024
@sheremet-va
Copy link
Member

sheremet-va commented Jul 29, 2024

Maybe we should just have it in the name? How do other frameworks do 🤔

  • __screenshots__
    • Button.stories.tsx_ReponsiveMovile-1.png

@sheremet-va
Copy link
Member

sheremet-va commented Jul 30, 2024

Looks like cypress does the same, but their screenshot folder is in the root: https://docs.cypress.io/api/commands/screenshot#Naming-conventions

Can't you just add __screenshots__ folder to ignore?

@yannbf
Copy link
Contributor Author

yannbf commented Aug 22, 2024

Good point, I'll make sure we can handle this in Storybook! Thanks for investigating <3

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
p4-important Violate documented behavior or significantly improves performance (priority)
Projects
None yet
Development

No branches or pull requests

2 participants