-
-
Notifications
You must be signed in to change notification settings - Fork 9.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1584 from storybooks/887-generate-snapshot-per-st…
…ory-file 887 Generate snapshot per story file
- Loading branch information
Showing
24 changed files
with
420 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import path from 'path'; | ||
|
||
export function getStoryshotFile(fileName) { | ||
const { dir, name } = path.parse(fileName); | ||
return path.format({ dir: path.join(dir, '__snapshots__'), name, ext: '.storyshot' }); | ||
} | ||
|
||
export function getPossibleStoriesFiles(storyshotFile) { | ||
const { dir, name } = path.parse(storyshotFile); | ||
|
||
return [ | ||
path.format({ dir: path.dirname(dir), name, ext: '.js' }), | ||
path.format({ dir: path.dirname(dir), name, ext: '.jsx' }), | ||
]; | ||
} |
19 changes: 19 additions & 0 deletions
19
addons/storyshots/stories/directly_required/__snapshots__/index.storyshot
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`Storyshots Another Button with some emoji 1`] = ` | ||
<button | ||
className="css-1yjiefr" | ||
onClick={[Function]} | ||
> | ||
😀 😎 👍 💯 | ||
</button> | ||
`; | ||
|
||
exports[`Storyshots Another Button with text 1`] = ` | ||
<button | ||
className="css-1yjiefr" | ||
onClick={[Function]} | ||
> | ||
Hello Button | ||
</button> | ||
`; |
19 changes: 19 additions & 0 deletions
19
addons/storyshots/stories/required_with_context/__snapshots__/Button.stories.storyshot
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`Storyshots Button with some emoji 1`] = ` | ||
<button | ||
className="css-1yjiefr" | ||
onClick={[Function]} | ||
> | ||
😀 😎 👍 💯 | ||
</button> | ||
`; | ||
|
||
exports[`Storyshots Button with text 1`] = ` | ||
<button | ||
className="css-1yjiefr" | ||
onClick={[Function]} | ||
> | ||
Hello Button | ||
</button> | ||
`; |
104 changes: 104 additions & 0 deletions
104
addons/storyshots/stories/required_with_context/__snapshots__/Welcome.stories.storyshot
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`Storyshots Welcome to Storybook 1`] = ` | ||
<article | ||
className="css-1fqbdip" | ||
> | ||
<h1 | ||
className="css-nil" | ||
> | ||
Welcome to storybook | ||
</h1> | ||
<p> | ||
This is a UI component dev environment for your app. | ||
</p> | ||
<p> | ||
We've added some basic stories inside the | ||
|
||
<code | ||
className="css-mteq83" | ||
> | ||
src/stories | ||
</code> | ||
|
||
directory. | ||
<br /> | ||
A story is a single state of one or more UI components. You can have as many stories as you want. | ||
<br /> | ||
(Basically a story is like a visual test case.) | ||
</p> | ||
<p> | ||
See these sample | ||
|
||
<a | ||
className="css-ca0824" | ||
onClick={[Function]} | ||
role="button" | ||
tabIndex="0" | ||
> | ||
stories | ||
</a> | ||
|
||
for a component called | ||
|
||
<code | ||
className="css-mteq83" | ||
> | ||
Button | ||
</code> | ||
. | ||
</p> | ||
<p> | ||
Just like that, you can add your own components as stories. | ||
<br /> | ||
You can also edit those components and see changes right away. | ||
<br /> | ||
(Try editing the | ||
<code | ||
className="css-mteq83" | ||
> | ||
Button | ||
</code> | ||
stories located at | ||
<code | ||
className="css-mteq83" | ||
> | ||
src/stories/index.js | ||
</code> | ||
.) | ||
</p> | ||
<p> | ||
Usually we create stories with smaller UI components in the app. | ||
<br /> | ||
Have a look at the | ||
|
||
<a | ||
className="css-ca0824" | ||
href="https://storybook.js.org/basics/writing-stories" | ||
rel="noopener noreferrer" | ||
target="_blank" | ||
> | ||
Writing Stories | ||
</a> | ||
|
||
section in our documentation. | ||
</p> | ||
<p | ||
className="css-bwdon3" | ||
> | ||
<b> | ||
NOTE: | ||
</b> | ||
<br /> | ||
Have a look at the | ||
|
||
<code | ||
className="css-mteq83" | ||
> | ||
.storybook/webpack.config.js | ||
</code> | ||
|
||
to add webpack loaders and plugins you are using in this project. | ||
</p> | ||
</article> | ||
`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import path from 'path'; | ||
import initStoryshots, { multiSnapshotWithOptions } from '../src'; | ||
|
||
initStoryshots({ | ||
framework: 'react', | ||
configPath: path.join(__dirname, '..', '.storybook'), | ||
test: multiSnapshotWithOptions({}), | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.