Skip to content

Instantly share code, notes, and snippets.

@regalius
Created April 29, 2018 06:19
Show Gist options
  • Save regalius/0e053f035f2cd932c803f1f80d22821e to your computer and use it in GitHub Desktop.
Save regalius/0e053f035f2cd932c803f1f80d22821e to your computer and use it in GitHub Desktop.
import initStoryshots, {
multiSnapshotWithOptions,
imageSnapshot
} from "@storybook/addon-storyshots";
import path from "path";
initStoryshots({
suite: "Storyshots",
integrityOptions: { cwd: __dirname },
test: multiSnapshotWithOptions({})
});
const getMatchOptions = ({ context: { fileName } }) => {
const customSnapshotsDir = `${fileName.slice(
0,
fileName.lastIndexOf("/")
)}/_image_snapshots_`;
return {
customSnapshotsDir
};
};
let storybookUrl = "http://localhost:9009";
if (process.env.CI) { // 👈 if in CI environment point to static build
storybookUrl = `file://${path.join(__dirname, "../storybook-static")}`;
}
initStoryshots({
suite: "Image Storyshots",
test: imageSnapshot({
storybookUrl,
getMatchOptions
})
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment