-
-
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
Changes from 8 commits
485aab5
9c50bf4
5e1e9b9
3464004
ce0ae13
015d49b
21b0e34
b71e110
d4aa7c9
77b15f4
ec2fd12
ccdffad
d6b0eb5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,15 +19,25 @@ if (!fs.existsSync(pathToStorybookStatic)) { | |
} else { | ||
initStoryshots({ | ||
suite: 'Image snapshots', | ||
storyKindRegex: /^Addons\|Storyshots/, | ||
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 commentThe 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 commentThe 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 commentThe 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
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
#2679 should help a lot here. We could just introduce There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah 👍 |
||
test: imageSnapshot({ | ||
storybookUrl: `file://${pathToStorybookStatic}`, | ||
getMatchOptions: () => ({ | ||
failureThreshold: 0.04, // 4% threshold, | ||
failureThreshold: 0.02, // 2% threshold, | ||
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 commentThe reason will be displayed to describe this comment to others. Learn more. Looks like it's not needed anymore |
||
// Some weird stuff are done inside Layout component, so we have to wait some to get a viable screenshot. | ||
// Tried some values here, seems 200 is long enough, not too short either :) | ||
// Not sure why this is required but seems better than to avoid taking screenshots for these. | ||
return new Promise(resolve => setTimeout(resolve, 200)); | ||
} | ||
return Promise.resolve(); | ||
}, | ||
}), | ||
}); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`Storyshots Addons|Storyshots Default 1`] = `<button />`; | ||
|
||
exports[`Storyshots Addons|Storyshots Disabled 1`] = ` | ||
<button | ||
disabled="" | ||
> | ||
Testing the storyshots addon | ||
</button> | ||
`; | ||
|
||
exports[`Storyshots Addons|Storyshots Label 1`] = ` | ||
<button> | ||
Testing the storyshots addon | ||
</button> | ||
`; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import React from 'react'; | ||
import { storiesOf } from '@storybook/react'; | ||
import BaseButton from '../components/BaseButton'; | ||
|
||
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 commentThe 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 commentThe 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. |
||
.add('Label', () => <BaseButton label={text} />) | ||
.add('Disabled', () => <BaseButton disabled label={text} />); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#!/bin/sh | ||
# Workaround for https://github.com/GoogleChrome/puppeteer/issues/290 | ||
|
||
sudo apt-get update | ||
sudo apt-get install -yq gconf-service libasound2 libatk1.0-0 libc6 libcairo2 libcups2 libdbus-1-3 \ | ||
libexpat1 libfontconfig1 libgcc1 libgconf-2-4 libgdk-pixbuf2.0-0 libglib2.0-0 libgtk-3-0 libnspr4 \ | ||
libpango-1.0-0 libpangocairo-1.0-0 libstdc++6 libx11-6 libx11-xcb1 libxcb1 libxcomposite1 \ | ||
libxcursor1 libxdamage1 libxext6 libxfixes3 libxi6 libxrandr2 libxrender1 libxss1 libxtst6 \ | ||
ca-certificates fonts-liberation libappindicator1 libnss3 lsb-release xdg-utils wget |
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.