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

Improve tests #541

Merged
merged 24 commits into from
Sep 5, 2016
Merged

Improve tests #541

merged 24 commits into from
Sep 5, 2016

Conversation

jackcarlisle
Copy link
Contributor

@jackcarlisle jackcarlisle commented Aug 24, 2016

ready for review

@nelsonic nelsonic changed the title [WiP] Improve test coverage [WiP] Improve tests Aug 24, 2016
@nelsonic
Copy link
Contributor

@jackcarlisle looking good so far. keep going. we ❤️ tests!

@jackcarlisle jackcarlisle changed the title [WiP] Improve tests Improve tests Aug 25, 2016
@nelsonic
Copy link
Contributor

@jackcarlisle have we lost our CodeCov test coverage report? is it still configured on CodeShip?

@lennym
Copy link
Contributor

lennym commented Aug 26, 2016

@nelsonic Istanbul reporting was lost when we shifted the ui tests to run in karma/phantom (in order to get around the issues they had with browser APIs being required to run).

The combination of compiling with babel and webpack and istanbul wasn't working and I had sunk days into trying to get it to work before giving up.

You're welcome to try to re-implement istanbul if you like.

@nelsonic
Copy link
Contributor

nelsonic commented Aug 26, 2016

@lennym oh, hadn't realised. Is there an alternative way of tracking/reporting the "completeness" of our tests with the karma/phantom approach...? (apologies, I'm haven't used Karma since angular days... thanks!)

expect(wrapper.find('FadeImage')).to.have.length(1);
expect(wrapper.find('h2')).to.have.length(1);
expect(wrapper.find('h3')).to.have.length(1);
expect(wrapper.find('h4')).to.have.length(1);
Copy link
Contributor

Choose a reason for hiding this comment

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

These tests feel a bit arbitrary.

  • Containing exactly 5 <div/>s isn't really something we care about in the slightest, and seems like it would be very fragile in future code changes, so would just add to maintenance cost without really adding any value in terms of confirming correct behaviour.
  • If we're going to assert on the headers being present, then I'd probably want to also assert that they contain the text we expect.

@lennym
Copy link
Contributor

lennym commented Aug 26, 2016

Having reviewed a good proportion of the code, there's a bit of a recurring theme of "magic number" tests, which are performing assertions on things that are not really relevant or appropriate to the actual functionality we're testing.

A particularly striking example is the following:

expect(wrapper.find('div')).to.have.length(47); - here

These don't really provide any value in terms of confirming the correct functionality of components, but will add maintenance overhead when it comes to making updates to components since the tests are incredibly sensitive to change.

I'd probably want to try to be more specific about what aspects of components are key to their functionality, which generally will mean making more assertions about components in terms of the classNames and text content, and ensuring the scope of the assertions is limited only to the aspects under tests.

@jackcarlisle
Copy link
Contributor Author

@lennym thanks for the comments! Looking into changing this now!

@jackcarlisle
Copy link
Contributor Author

TODO: refactor tests for src/components

@jackcarlisle jackcarlisle changed the title Improve tests [WiP] Improve tests Aug 26, 2016
@jackcarlisle jackcarlisle changed the title [WiP] Improve tests Improve tests Aug 30, 2016
@nelsonic
Copy link
Contributor

nelsonic commented Sep 1, 2016

@jackcarlisle can we merge this PR in? (hope your "day off" is going well...)

@jackcarlisle
Copy link
Contributor Author

@nelsonic Yeah it's good to go!

@nelsonic nelsonic merged commit 3ad8a96 into master Sep 5, 2016
@nelsonic nelsonic deleted the updateTests branch September 5, 2016 11:51
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.

3 participants