-
-
Notifications
You must be signed in to change notification settings - Fork 9.5k
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
Add renderer option to storyshots #2414
Changes from 10 commits
50a4b06
5ddb6b5
8143264
b4c7098
f42b29a
2b2b27d
45755f9
beda473
c78e169
e3c2fc0
e762993
9b1e319
3bbbac5
71421d8
11800f8
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 |
---|---|---|
@@ -1,5 +1,5 @@ | ||
{ | ||
"presets": ["env", "react"], | ||
"presets": ["env", "stage-0", "react"], | ||
"plugins": [ | ||
"transform-runtime" | ||
] | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,140 @@ | ||
// 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> | ||
`; | ||
|
||
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> | ||
`; | ||
|
||
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> | ||
`; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import path from 'path'; | ||
import { mount } from 'enzyme'; | ||
import toJSON from 'enzyme-to-json'; | ||
import initStoryshots from '../src'; | ||
|
||
initStoryshots({ | ||
framework: 'react', | ||
configPath: path.join(__dirname, '..', '.storybook'), | ||
renderer: mount, | ||
serializer: toJSON, | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -39,6 +39,9 @@ | |
"@storybook/components": "^3.3.0-alpha.4", | ||
"@storybook/react": "^3.3.0-alpha.4", | ||
"babel-jest": "^21.2.0", | ||
"enzyme": "^3.2.0", | ||
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. We need to have a single enzyme instance across the codebase, so it shouldn’t be added to package dependencies 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. i know. but i figured an "example project" should include the necessary dependencies? its a lot more difficult to understand if i need to look outside of the project for its code to work. thats why i included enzyme setup there 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. OK, makes sense |
||
"enzyme-adapter-react-16": "^1.1.0", | ||
"enzyme-to-json": "^3.2.2", | ||
"jest": "^21.2.1", | ||
"react-scripts": "1.0.17" | ||
}, | ||
|
@@ -50,6 +53,12 @@ | |
"transform": { | ||
".*": "babel-jest" | ||
}, | ||
"snapshotSerializers": [ | ||
"enzyme-to-json/serializer" | ||
], | ||
"setupFiles": [ | ||
"<rootDir>/src/enzyme.js" | ||
], | ||
"moduleNameMapper": { | ||
"\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$": "<rootDir>/__mocks__/fileMock.js", | ||
"\\.s?css$": "<rootDir>/__mocks__/styleMock.js" | ||
|
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.
Why is it needed? Can we include the particular transform instead?
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.
for the destructuring assignment here: https://github.com/storybooks/storybook/pull/2414/files#diff-75fdf0f2c6757366489b97c6898ea585R6
i would have used stage-2, but storybook itself pulls in stage-0, so i went with that to stay consistent
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 I see. I wonder if we can remove this nested
.babelrc
to avoid confusion@ndelangen what do you think?