WikiEduDashboard
WikiEduDashboard copied to clipboard
Write tests for Redux reducers that cover all action types and ensure that state is not mutated
The reducers that make up the main Redux reducer should all be pure functions that are free of side effects and do not mutate their inputs. This makes unit tests particularly easy to implement, but important for making sure we avoid state-mutation bugs.
The handful of existing specs in test/reducers
offer clear examples for how individual actions can be tested for these reducers, with deepFreeze
being called on the initial state to guarantee that nothing in the reducer is mutating it.
Choose one or more reducers, and add tests for the functionality of each action type supported by that reducer. This should be done one reducer per commit. If you're working on this, please post a comment to say which reducer you're working on, so that others can work on different reducers.
Ideally, the set of tests for each reducer will provide 100% coverage of that reducer. You can check the coverage by running npm test
and then opening coverage/lcov-report/index.html
, which includes coverages maps of each javascript file.
(GCI 2018)
I'll be making tests for uploads.js
Is it possible to get the tests working without setting up the whole env?
I tried just doing yarn
and gulp
to build, but that results in a large amount of errors from gulp concerning bundler (I have bundler installed)
@sunny-lan you must do bundle install
before gulp
will run, because one of the steps in the gulp pipeline involves calling the ruby script that generates the JS versions of the interface message translations.
That said, I don't think the javascript tests even depend on generating the assets. If you did yarn
and it ran without error, you should be able to do yarn test
to just run the jest tests.
@ragesoss can I work on adding some of the tests? I have set up the development environment (and opened a PR for #2197).
I'll take user related reducers: user_profile user_revisions user_training_status user
If someone is doing these let me know.
Here's what the current coverage on the reducers looks like:
@ragesoss I want to work for adding test for some of the reducers. Plz assign this issue to me.
@ragesoss I would like to pick up this issue, can you assign it to me.
We do not assign issues, but you can choose a reducer and work on it.
@ragesoss I opened a PR for the correction I did. Could you please confirm if my correction meets your approval? Once confirmed, I'll proceed to begin implementing tests for reducers.