I've been working on an android app using React Native for the past couple of weeks as a side project. I haven't written any tests for it yet, for a couple of reasons. It's the first time I do something with React Native and I haven't been bothered to investigate how to test it. It also took me a bit to nail down how the app was actually supposed to work. Now, however, it's approaching completion and I thought that it might be a good idea to add tests to make sure future changes don't break it.
So that sparked the question: How do other people deal with testing in their personal projects? Do you write tests first? Last? At all? How do you go about it?
Top comments (3)
When I start a side project, my first goal is to have something up and running that sorta has the basic functionality of what I want to build. Until that point, I don't write tests.
Once I reach that point, I try to write unit and integration tests covering the work done and try to use TDD for any further work. If it's a web application, I might use cypress for end to end testing as well.
I don't do anything fancy in my side projects so I can just use mocha as a test runner and node's builtin module assert. I can be happy with those.
Testing a user interface brings a whole other realm of problems. But if do need to test some interaction in the browser I like to use DOM Testing Library.
That same testing library has React native bindings. Maybe that can help you.
About test in general, I think is good to have automated test and doesn't matter if you write first or last as long as they cover the most important parts of your code.
I'll have a look at DOM testing library, thanks!