Use self explanatory test rather than snapshot testing.
yujonglee opened this issue · 1 comments
Hi. I'm having good time reading code from dooboo-ui
.
But I think some test code in dooboo-ui needs improvements.
Is your feature request related to a problem? Please describe.
Quite a lot of test code is not self-explanatory, it's just snapshot testing.
// every test code is almost same as below
testingLib = render(component);
const json = testingLib.toJSON();
expect(json).toMatchSnapshot();
Describe the solution you'd like
I think it might be better if components are tested using assertions in testing-library, context, given.
Describe alternatives you've considered
If there are reasons to stick to snapshot testing(ofcourse there's some situation hard to test without it), I think at least code organizing with context/given
, and removing let
might be great.
// ex
let props: any;
let component: ReactElement;
let testingLib: RenderAPI;
Additional context
I found article which is similar to my opinion. Maybe it will let you understand my point.
I'm not experienced programmer so maybe there's something I missed. Then please let me know. If you think part of my idea is acceptable, I'll be working on it.
Thanks.
@yujong-lee Thanks for the great issue! I've learned from you. Yes, your insight is really blazing and I really wish to see your work and refactoring test code.