-
-
Notifications
You must be signed in to change notification settings - Fork 143
Unit tests with Jest + Enzyme and updates to Tabs component #315
Conversation
}, | ||
"test": { | ||
"plugins": ["transform-object-rest-spread", "styled-jsx/babel-test"] |
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.
Here we use (a brand new) plugin babel-test
, so that Jest will use Babel and styled-jsx, but won't parse the classes to jsx-1324
or whatever, so that we can make assertions on them!
command: | | ||
. venv/bin/activate | ||
python --version | ||
npm run test-unit |
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.
This is the only real difference apart from formatting - running the new unit tests in CircleCI.
src/components/Tabs.react.js
Outdated
this.NoChildrenError = { | ||
name: 'NoChildrenError', | ||
message: 'Tabs did not have any children Tab components!', | ||
}; |
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.
Not really sure about this - if you have suggestions on how to do error handling here in a better way, please let me know!
Just curious, what bugs did you find that weren't covered in the integration tests? |
I was getting an exception when the |
I think I broke dash 0.28.0 😞
|
@rmarren1 Actually no it doesn't. I was thinking about it, and thought that the Tabs component should throw an error if there are no children. What would it render? Thinking about it now, perhaps the Tabs component should not throw an exception when there are no children, in the cases where you set the children later through a callback... |
I think either would be acceptable, but let's use |
@rmarren1 Ah you're right, thanks! I'll update that. |
The Selenium tests are failing here because of this issue: plotly/dash-renderer#84 |
@rmarren1 So I can remove these errors I'm throwing in favour of |
If you have |
@rmarren1 Yeah that's what I expected, but if I set it to |
a9b3b40
to
e7272a9
Compare
requirements-dev.txt
Outdated
@@ -8,6 +8,7 @@ tox | |||
tox-pyenv | |||
six | |||
plotly>=2.0.8 | |||
urllib3<=1.22 |
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.
This caused the Python 2.7 tests to fail, got this fix from #333
@@ -18,7 +18,7 @@ Tab.propTypes = { | |||
/** | |||
* The tab's label | |||
*/ | |||
label: PropTypes.children, | |||
label: PropTypes.string, |
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.
Support for components/something else than a string for label will have to come later, anything else than a string doesn't really work now anyways, so best to set it to string for now.
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.
Let's also bump the versions and ship a release as soon as this is merged
… into unit_tests_with_jest
This is a work-in-progress PR, rebased of off #299 - that needs to be merged first.
I'm comparing this branch to the
update_scripts
branch, so the commits are easier to reason about.This adds support for Jest, a JS test runner, and Enzyme, testing tools for React. It allows us to write unit tests in JS for the components, hopefully lightening the load/dependency on our Selenium integration tests, and allowing for a more test-driven approach by running Jest in watch mode or as a VS-Code/Atom plugin.
I've written some basic unit tests for the Tabs component, and caught a couple of bugs that I've also fixed.
@plotly/dash