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

Better snapshot tests #57

Open
mikeyhogarth opened this issue Jun 9, 2019 · 4 comments
Open

Better snapshot tests #57

mikeyhogarth opened this issue Jun 9, 2019 · 4 comments
Labels
enhancement New feature or request help wanted Extra attention is needed

Comments

@mikeyhogarth
Copy link
Owner

We have some snapshot tests, but theyr'e not particularly good - specifically;

  • We don't have 100% coverage
  • Theyr'e only 'shallow' tests
  • Things like the cocktailList/cocktailItem should be really easy to test

We want snapshot tests, but cant' really get those on things like the cocktailItem without introducing enzyme to use its mount functionality, or introducing things like the react-router MemoryRouter functionaity into the tests.

Lets spend some time making this good :)

@mikeyhogarth mikeyhogarth added enhancement New feature or request help wanted Extra attention is needed labels Jun 9, 2019
@bolivier
Copy link

Any particular reason you're interested in snapshot tests over unit tests with something like react-testing-library?

I haven't experimented with it before, but it should be possible to mock the modules that import those routing components and replace them with trivial implementations that don't really work, but are testable nonetheless.

@mikeyhogarth
Copy link
Owner Author

mikeyhogarth commented Jun 28, 2019

So when it comes to testing UIs, I find they become insanely brittle and so I prefer to test them with the ol' head cameras rather than being declarative about it. That said, the whole thing here is totally lacking in the test department and I know that needs to improve - this ticket was just to cover the fact that we want to have full snapshot coverage and right now we don't.

These tests have actually saved me from a few silly mistakes during development, despite being something I've not put too much effort into.

To clarify then: you are absolutely right, I need to add some unit tests for the UIs (I do have unit tests for the non-UI stuff) but this ticket is purely about snapshot tests.

@bolivier
Copy link

That testing lib I linked is supposed to be less brittle than most because it only lets you test things as if you were using the ol' head cameras. There's no testing internal state, most tests I've used it for don't even use css selectors. I can whip up a few tests with it and you can see how you like them, but I've found it immensely helpful for unit testing UIs. I've refactored huge chunks of stuff and not had to touch a single test, because it eschews testing internals.

@mikeyhogarth
Copy link
Owner Author

Cheers m8 :) I will take a look.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants