Skip to content
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

Setup JavaScript tests for Nuage provider #122

Merged
merged 2 commits into from
Aug 7, 2018

Conversation

miha-plesko
Copy link
Contributor

With this commit we setup two libraries for javascript tests:

  • jest (pojo javascript tests)
  • enzyme (React component tests)

For each of them we provide a single dummy test just to be sure configuration is valid.

Depends on: #121

/cc @Hyperkid123

With this commit we provide nothing but configuration files
needed for Nuage React Components.

Signed-off-by: Miha Pleško <[email protected]>
@miha-plesko
Copy link
Contributor Author

Note: only 2nd commit is important here

package.json Outdated
@@ -15,6 +15,9 @@
"homepage": "https://github.com/ManageIQ/manageiq#readme",
"dependencies": {
"@manageiq/react-ui-components": "~0.9.5",
"chai": "^4.1.2",

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there any reason why you want to use this library? I don't think you will need this at all. Jest already has pretty good assertions.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool, was looking at enzyme example and they are using it. Let me remove.

describe('<Spinner/>', () => {
it('renders three <Foo /> components', () => {
const wrapper = shallow(<Spinner loading />);
expect(wrapper.find('.spinner')).to.have.length(1);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So this is basically one the most annoying things about testing react components. Hopefully you can use snapshot testing with Jest https://jestjs.io/docs/en/snapshot-testing (also i would recommend using enzime-to-json instead of the react-renderer in the example).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for pointing out, will come up with something tomorrow. Also, I need to configure Travis to actually run them, almost forgot 🐷

@miha-plesko miha-plesko force-pushed the react-setup-tests branch 4 times, most recently from ee8e524 to f9c03c8 Compare August 7, 2018 06:50
package.json Outdated
"homepage": "https://github.com/ManageIQ/manageiq#readme",
"dependencies": {
"@manageiq/react-ui-components": "~0.9.5",
"enzyme": "^3.3.0",

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

enzyme, enzyme-adapter-react-16, enzyme-to-json should be dev-dependencies

@miha-plesko miha-plesko force-pushed the react-setup-tests branch 2 times, most recently from 80240aa to 902ac26 Compare August 7, 2018 07:09
describe('<Spinner/>', () => {
it('renders three <Foo /> components', () => {
const wrapper = shallow(<Spinner loading />);
expect(wrapper.find('.spinner')).toHaveLength(1);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would maybe add a snapshot test here to show off how it works:

import toJson from 'enzyme-to-json';
...
  expect(toJson(wrapper)).toMatchSnapshot();
...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup, I owe you this from yesterday, as soon as Travis configuration works I'll do it.

@miha-plesko miha-plesko force-pushed the react-setup-tests branch 2 times, most recently from fb15be4 to eacd971 Compare August 7, 2018 07:33
With this commit we setup two libraries for javascript tests:

- jest (pojo javascript tests)
- enzyme (React component tests)

For each of them we provide a single dummy test just to be sure
configuration is valid. Also, we provide Travis configuration to
actually run the tests.

Signed-off-by: Miha Pleško <[email protected]>
@miq-bot
Copy link
Member

miq-bot commented Aug 7, 2018

Checked commits miha-plesko/manageiq-providers-nuage@46b2bf4~...36131df with ruby 2.3.3, rubocop 0.52.1, haml-lint 0.20.0, and yamllint 1.10.0
1 file checked, 0 offenses detected
Everything looks fine. 🍪

@miha-plesko
Copy link
Contributor Author

@Hyperkid123 thanks for help, I think we're almost done - Travis is green and we have snapshot test showcase. Please let me know if there is something else we can improve.

@Hyperkid123
Copy link

I think this should be enough.

Copy link

@Hyperkid123 Hyperkid123 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTMT

@agrare agrare self-assigned this Aug 7, 2018
@agrare agrare merged commit 36131df into ManageIQ:master Aug 7, 2018
agrare added a commit that referenced this pull request Aug 7, 2018
Setup JavaScript tests for Nuage provider
@agrare agrare added this to the Sprint 92 Ending Aug 13, 2018 milestone Aug 7, 2018
@miha-plesko miha-plesko deleted the react-setup-tests branch August 8, 2018 06:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants