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

Fixes #24336 - upgrade jest and fix errors #7555

Merged
merged 1 commit into from
Jul 24, 2018

Conversation

johnpmitsch
Copy link
Contributor

This does a few things:

  • upgrades jest to 23.4.1 and adds new snapshots
    to be compatible with the new version.
  • adds a script to run before every test that makes
    the test fail when there are console errors. This
    is helpful in catching missing propTypes from the
    tests, since those will print console errors, but
    not actually fail the test itself.
  • Fixes PropType errors.
  • Fixes unhandled promise warning.

@theforeman-bot
Copy link

Issues: #24336

@johnpmitsch
Copy link
Contributor Author

combined with #7538, this should make our tests noise-free 😎

@johnpmitsch
Copy link
Contributor Author

to test rm -rf node_modules && npm i in katello, then run npm test

@@ -39,7 +39,7 @@ class Search extends Component {
text: label.trim(),
})),
});
});
}).catch(() => {});
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@tstrachota This is empty to prevent the unhandled promise warning, but do we want to catch errors here?

Copy link
Member

Choose a reason for hiding this comment

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

If something breaks it would produce an error on each type in the field, right? In this case I'd avoid propagating the errors as toast notifications but I think it would make sense to log them into console.

Copy link
Member

@tstrachota tstrachota left a comment

Choose a reason for hiding this comment

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

Nice fixes, thanks @johnpmitsch.
With your patch tests fail for me locally as well as in jenkins. RecommendedRepositorySetsToggler › rendering › renders recommended-repository-sets-toggler doesn't match the stored snapshot (that you're changing in the PR btw).

// output and traceback for actual error.
global.console.error = (error) => {
throw new Error(error);
};
Copy link
Member

Choose a reason for hiding this comment

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

I like it 👍

@johnpmitsch johnpmitsch force-pushed the upgrade_jest branch 2 times, most recently from 355776c to f6276bb Compare July 23, 2018 14:49
@johnpmitsch
Copy link
Contributor Author

@tbrisker thanks, I guess I had something wrong with my environment, on a new environment I was able to reproduce the bad snapshot and corrected it (back to the original snapshot)

I modified the Search test to log the Promise errors to the console. To make sure nothing prints out during the test, I mocked the API.

I also added a lint:test script to package.json, since I get tired of running both lint and test 😇

@johnpmitsch johnpmitsch force-pushed the upgrade_jest branch 2 times, most recently from 1d90a5c to 62ca993 Compare July 24, 2018 13:49
@johnpmitsch
Copy link
Contributor Author

@tbrisker @waldenraines I've updated this and added fixes for the breakages in master. Since this is a small PR, I recommend we merge this if everyone is ok with it to get master branch back to a healthy state 🌡️ let me know your thoughts

Copy link
Contributor

@waldenraines waldenraines left a comment

Choose a reason for hiding this comment

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

Small comment/question, otherwise looks good.

})
.catch((error) => {
// eslint-disable-next-line no-console
console.log(error);
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do we want to console.log() this error? We should do something useful with the error or do nothing at all.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@waldenraines This is roughly the same question I asked @tbrisker here, maybe he can expand on it? (the comment was collapsed so it was hidden).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@waldenraines The reason I added the catch block is otherwise node throws a "unhandled promise" warning, but running this again, I see this is only because I was using a newer version of nodejs. I completely removed the catch block without any warnings, I think this is fine for now (until we update node versions)

This does a few things:
- upgrades jest to 23.4.1 and adds new snapshots
  to be compatible  with the new version.
- adds a script to run before every test that makes
  the test fail when there are console errors. This
  is helpful in catching missing propTypes from the
  tests, since those will print console errors, but
  not actually fail the test itself.
- Fixes PropType errors.
- Fixes unhandled promise warning.
Copy link
Contributor

@waldenraines waldenraines left a comment

Choose a reason for hiding this comment

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

LGTM, thanks @johnpmitsch!

@tbrisker
Copy link
Member

@johnpmitsch you seem to be mentioning me instead of @tstrachota ;)

@johnpmitsch
Copy link
Contributor Author

@tbrisker sorry, I think that is the 2nd time I've done that 🙈

@johnpmitsch
Copy link
Contributor Author

I'm merging this so we can fix tests in master

@johnpmitsch johnpmitsch reopened this Jul 24, 2018
@johnpmitsch
Copy link
Contributor Author

and I accidently hit "close and comment" so have to wait for jenkins again... not my day today 😅

@johnpmitsch johnpmitsch merged commit 6374606 into Katello:master Jul 24, 2018
@johnpmitsch johnpmitsch deleted the upgrade_jest branch July 24, 2018 17:15
@johnpmitsch johnpmitsch mentioned this pull request Aug 7, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
5 participants