-
-
Notifications
You must be signed in to change notification settings - Fork 9.4k
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
fix screenshots tests & add getScreenshotOption to storyshots #3102
fix screenshots tests & add getScreenshotOption to storyshots #3102
Conversation
}; | ||
|
||
testFn.beforeEach = () => | ||
testFn.beforeAll = () => |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moving this to beforeAll
is a perf booster. No need to re-run Chrome for each tests.
Is it a breaking change? |
Looks like there are a lot more failures than just one addon-a11y story: BTW, for some reason diffs are not uploaded as artifacts |
yay @Hypnosphi I believe I broke everything :D The diffs were not even generated in the first place 👎 |
Oh and yes this is breaking. Since the 3.4 is not out yet (still in alpha if I'm correct) I was thinking maybe that's not too bad to throw it now. |
Codecov Report
@@ Coverage Diff @@
## master #3102 +/- ##
===========================================
- Coverage 92.5% 35.98% -56.52%
===========================================
Files 6 437 +431
Lines 40 9474 +9434
Branches 2 899 +897
===========================================
+ Hits 37 3409 +3372
- Misses 2 5506 +5504
- Partials 1 559 +558
Continue to review full report at Codecov.
|
Ok I just forgot it's an alpha feature |
a9eb76a
to
37f0564
Compare
I re-added the workaround for puppeteer as I suspect this is linked to Chrome headless not willing to run properly. It was previously removed in #3052, and not noticed it was used by the official-storybook storyshot tests because tests were not run anymore. |
Still lots of errors =( |
Yep, I see that too.. I was actually trying to determine a good threshold ... not an easy thing to do... |
Sure, if you can make current tests pass with it in a way that can be reproduced by other contributors. I mean, examples may change, and we need a way to update screenshots that would work in any environment (e.g., some people use Windows, others use Mac, and on CI we have Linux) |
Yep I get it, can you point me to contributors willing to help test these screenshots for Mac & Windows ? I've only got Linux. |
I use Mac, @igor-dv uses Windows |
Allright, thanks. Could you test this then ? As well as @igor-dv ? |
Sure, but some of the tests are still failing on CI: https://circleci.com/gh/storybooks/storybook/41017#artifacts/containers/0 |
Yep .. argh not sure what to do, just raise the threshold and let some image still pass even if incorrect ? :( |
I think a good solution would involve taking screenshot and verifying them in the same environment (e.g. in docker) Without that, you'll always have a number of false positives or negatives depending on threshould. To me, personally, false positives (failures without actual error) are much worse, because they block development. In the case of storybook, we won't miss any visual changes, because Chromatic will catch them for us. But for external storyshots users, with current realization it always will be a tough compromise. That's basically what @tobilen was talking about when you opened the first PR: |
Are we doing this anywhere in this repo ? |
No. It requires users to have docker installed on their side |
I will just raise the threshold then. |
Ok, I'll check how it works on my machine |
@@ -21,13 +21,22 @@ if (!fs.existsSync(pathToStorybookStatic)) { | |||
suite: 'Image snapshots', | |||
framework: 'react', | |||
configPath: path.join(__dirname, '..'), | |||
storyNameRegex: /^((?!tweaks static values with debounce delay|Inlines component inside story).)$/, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What would be the correct way to ignore those stories?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's the way to ignore... But adding a proper ignore list to the api will definitely simplify everything...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like it didn't work: it ignored all the tests instead
UPD: I just missed *
in the end, it had to be this:
/^((?!tweaks static values with debounce delay|Inlines component inside story).)*$/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
adding a proper ignore list
#2679 should help a lot here. We could just introduce skipSnapshots
story parameter (name can be configurable)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah 👍
I have a local failure:
I guess it's because different fonts lead to different line wrapping, which affects page height |
Thanks @Hypnosphi for helping with this 💌 . This won't fix the main issue we got here though. I may specify a greater viewport height to fix this issues, meaning these stories will be taller than the real viewport. WDYT ? |
I think we should just ignore the problematic stories |
failureThresholdType: 'percent', | ||
}), | ||
beforeScreenshot: (page, { context }) => { | ||
// Screenshots for this story have to be tweaked. | ||
if (context.kind === 'ui/Layout') { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like it's not needed anymore
Thanks, I hope I'll be able to do the local testing again tomorrow |
const text = 'Testing the storyshots addon'; | ||
|
||
storiesOf('Addons|Storyshots', module) | ||
.add('Default', () => <BaseButton label="" />) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using an an unstyled button for those stories isn't a really good idea, because it uses appearance of system UI button, which means the differences between OS are huge
E. g., this is how storyshots story looks like on mac
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh so true ! I'll change the test, did a bit too quickly.
My bad, did this a bit too quickly, will be extra careful ! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Works OK on macOS. @igor-dv please test on Windows
Oh @igor-dv seems a weird issue .... :( |
Yeah, tried it several times, I'll investigate it a bit more |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My bad. Tried it before with an unstable version of Node. Works with the latest stable.
Great, thanks @Hypnosphi & @igor-dv ! |
Issue: none
What I did
getScreenshotOptions
to be able to configure puppeteerscreenshot()
behavior.Also, I wanted to draw your attention that if we specify a threshold higher than 0 we might end-up with some bad visual regression. More info below.
How to test
yarn run test --image
.yarn run image-snapshots
Is this testable with jest or storyshots?
Does this need a new example in the kitchen sink apps?
Does this need an update to the documentation?
Threshold for jest-image-snapshot.
This is from the addon-a11-default story.
This diff is ~2.5 % as for jest-image-snapshot. It looks bad to me, so I believe we will not want to have this kind of changes to pass, are we ? Just a question though, if you are fine with it, let it be and I will re-add the threshold to 4%.