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

[CWM] Add front-end UTs for Redux reducers #17

Open
3 tasks
rogup opened this issue Oct 7, 2024 · 2 comments
Open
3 tasks

[CWM] Add front-end UTs for Redux reducers #17

rogup opened this issue Oct 7, 2024 · 2 comments

Comments

@rogup
Copy link
Contributor

rogup commented Oct 7, 2024

Description

Redux reducers are something that it's worth UTing since it's easy to write tests and they're a key piece of logic that is supposed to be very reliable.

We don't have any UTs yet, so we should write them for all our Redux slices. There's some demo Counter code with UTs that we can use as examples, then we can probably delete that demo code.

There isn't much logic yet, so it shouldn't take too long to write these UTs, then we can make writing them a requirement for all future features. This work includes doing some research to work out if it's possible to add UTs for async thunks, and our custom selectors in mapSlice.ts

The testing library

On the LX backend, we use Mocha as our testing library. It's apparently possible to use Mocha for this too, but I think we should just stick with Vitest + React Testing Library, as used in the demo code. This is what Redux provides documentation for, and it's a similar syntax to Mocha anyway https://redux.js.org/usage/writing-tests
The benefits of having more documentation and the library's React-specific functionality outweighs the benefit of using Mocha throughout all our codebases.

Acceptance Criteria

  • We have a full set of UTs for all our Redux reducers
  • The UTs are run automatically in a GitHub CI pipeline for all PRs and pushes to main
  • We have a testing doc which outlines how to write a UT. We can probably copy most of this from the https://github.com/DigitalCommons/land-explorer-front-end Wiki
@ColmDC
Copy link

ColmDC commented Dec 4, 2024

Should we do this before or after the UI behaviour review?

@rogup
Copy link
Contributor Author

rogup commented Dec 5, 2024

Probably after the review, so that we can write these UTs alongside UI changes that we make. It will be efficient to write UTs for areas of code that we're already looking at and needing to make sense of.

I think we also should do a general call to prioritise tech debt though, before getting stuck in to writing lots of UTs, since there might be more important things

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants