Onboarding: Testing - brownfield-team/anacapa-github-linker GitHub Wiki
Onboarding: Testing
Testing is a weak spot in this code base, compared to best practices:
For the Ruby/Rails part of the code:
- You can run the existing test suite with
rake test
- You can run a single test file with
rake test TEST=path/to/the/file.rb
- We are using
minitest
test framework, which is built into rails, rather than the more popularrspec
framework (which is what most tutorials cover.) - There are relatively few tests.
- The tests mostly use fixtures for the test objects, which can be confusing and unreliable. A few newer tests are using FactoryBot, which is a more reliable way of setting up tests objects.
- We don't have any measures of test coverage set up.
- We don't have any tests set up for the API part of the backend that supports the React front end
For the React side:
- You can run the existing tests with
yarn jest
- We have test coverage set up via
yarn run coverage
, but the coverage levels are below 5%
End to End testing:
- We have a minimal start at doing full end-to-end black box testing via Playwright, but it's only a proof-of-concept; it hasn't yet been integrated into our practices.
Work to be done
Rails side:
- Migrate tests using fixtures to use factory bot instead
- Add some way to compute test coverage for rails code
- Add tests for API for the backend that supports the React code
- Add Rspec support side by side with minitest
- This article may help
- Migrate tests from minitest to rspec
React side
- Add tests for uncovered components (but first make sure the component is really being used or needed.)
End-to-end (Black Box) testing:
- Add more meaningful tests that use playwright. This will likely involve dealing with a number of challenges, including, but not limited to, handling authentication, and database issues.