-
-
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
Addon-contexts: component tests and readability improvements #6716
Conversation
This pull request is automatically deployed with Now. Latest deployment for this branch: https://monorepo-git-add-addon-contextscomponent-tests.storybook.now.sh |
For some reason the build was failed but it was okay on my local machine... WIP |
2579d85
to
191d294
Compare
Codecov Report
@@ Coverage Diff @@
## next #6716 +/- ##
==========================================
+ Coverage 39.92% 40.11% +0.18%
==========================================
Files 645 645
Lines 8884 8885 +1
Branches 666 667 +1
==========================================
+ Hits 3547 3564 +17
+ Misses 5238 5221 -17
- Partials 99 100 +1
Continue to review full report at Codecov.
|
1 similar comment
Codecov Report
@@ Coverage Diff @@
## next #6716 +/- ##
==========================================
+ Coverage 39.92% 40.11% +0.18%
==========================================
Files 645 645
Lines 8884 8885 +1
Branches 666 667 +1
==========================================
+ Hits 3547 3564 +17
+ Misses 5238 5221 -17
- Partials 99 100 +1
Continue to review full report at Codecov.
|
describe('Tests on addon-contexts component: ToolBar', () => { | ||
it('should render nothing if receive an empty contextNodes', () => { | ||
// when | ||
const result = shallow(<ToolBar nodes={[]} state={{}} setSelected={jest.fn} />); |
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.
Are these better expressed as storybook stories & tested with storyshots?
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.
@shilman, I was thinking about this previously, and even try to use react-testing-library
at very beginning... But later I found if I really want to test them, I have to find its ThemeProvider first; otherwise, I will get some object node missed and React get crashed.
That is why I roll it back to more traditional shallow testing approach (to stay inside the addon itself). Right now everything is in the monorepo and user will have to use @storybook/theme
implicitly so I guess it should be fine?! But I somehow think the @storybook/components
should have some components out-of-the-box for the addon creator.
To be more specific on the scope here, the only thing really need to get tested is the ToolBarControl
component. This component is responsible for validating the selected name (and some states as you may see there). I added other testing for parity.
There are some part I want to test but not get it tested. Anyway I will need to rethink about testing here. Thanks for suggestion though 🙏.
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.
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.
Woo nice, I will take a look, I will also migrate @storybook/components
first, and reach you out 👍
Issue: #6559
What I did
How to test
$ yarn test
.