-
Notifications
You must be signed in to change notification settings - Fork 154
Component unit tests #309
Comments
I'm working on this. I'll create two branches one with Enzyme and one with I've started with Enzyme. My WIP is pushed. Progressbar component test with 100% coverage is added. I have some questions to my setup:
|
@AWolf81 are there any decisions regarding the testing library? I can give a hand with writing tests once it's decided. |
@idoberko2 no, not decided yet. I like the idea of not testing implementation details with testing-lib but I'm not sure and I tend to Enzyme as it's more mature & widely used. Would be great if you could add an example in a testing-lib branch for another component. |
@AWolf81, I knew enzyme from before and only heard about |
@idoberko2 I'm writing a test for the Button component - I'll add it to the todolist above. |
@AWolf81 I'm starting off with the |
At the moment, we're having no component tests and that makes it difficult to make the coverage diff/patch of codecov pass.
We're having pretty good coverage at reducers & sagas but not at the components. That's why the overall coverage was just around 20%. See codecov for the current coverage.
So some things to discuss before this can be started:
We don't need to test every component e.g. the WhimsicalInstaller needs no component tests as it's something that could be easily replaced or disabled with-out affecting the work of the user.
List of components that I think are less important to be tested:
Where I wrote
check usage
above it would be good to check where and if they're used. I haven't seen them in use but maybe I've missed them.Describe the solution you'd like
After picking the testing utility we can start to work on this.
Some rules to follow - we should add them to the docs later
shallow
overmount
- use mount only if it includes Redux & you need the store or you're testing styled-components. Example of a connected component test (seeProjectPage.test
)simulate
instead of usinginstance.clickHandler
- so we're also testing that the handler is called correctly.Tips
console.log(wrapper.debug())
can help debugging or use the built-in debugger in VS codeconst instance = wrapper.instance()
can be used to test instance methods or life-cycle hooks.The text was updated successfully, but these errors were encountered: