-
Notifications
You must be signed in to change notification settings - Fork 4.2k
[Feature]: Improve the usage of snapshotPathTemplate to screenshot() method. #35882
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
Comments
Have you tried Could you elaborate on your use-case? So you take a screenshot and place it into some directory which you'd like to follow the |
My use case is like this :
So using what I showed on my first post works but as I said, it could be better to have a way to use the same path. To respond to your second question, it doesn’t work because when screenshot doesn’t exist, the test is marked as failing. With |
I don't think this is a use-case we support yet: Asserting against a screenshot which was just created. In your case you workaround it by writing the expectation image to the file system first and then using Do I understand it correctly that if we make it possible to allow asserting against a const beforeImage = await page.screenshot();
// actions
await expect(page).not.toHaveScreenshot(beforeImage);
// actions
await expect(page).toHaveScreenshot(beforeImage); In the meantime Aria snapshots might work for your use-case: https://playwright.dev/docs/aria-snapshots |
Yes it seem that it could be another solution (if we don't want to use the I already looked at the aria-snapshot solution, it seem to be lot of works (as our page can change a lot after a deployment has been done) while the screenshot assertion is a lot easier and works with every executed pipeline without any conflict between other test/deployment done. |
🚀 Feature Request
Actually
snapshotPathTemplate
config value seem not to work for.screenshot()
method while it works fine for.toHaveScreenshot()
Example
For example, in my project I've this config :
snapshotPathTemplate: './fixtures/__screenshots__/${ environment }/{testFilePath}/{arg}{ext}',
On my test I just do
And I just need to put a screenshot name to make it works.
But if I want to generate a new screenshot for my test, do some action, and then assert screenshot, then I need to do like this :
Instead of this current behavior, it could become something like that :
Motivation
It could be better to just use the snapshotPathTemplate for the
.screenshot()
method too so It will just need to set the screenshot name has we did for.toHaveScreenshot()
method.The text was updated successfully, but these errors were encountered: