cra-template-redux
cra-template-redux copied to clipboard
Convert unit tests to integration tests
Context
- The Writing Tests page page recently has major updates to advocate integration tests over unit tests (test reducers/ selectors/ action creators individually).
- This PR removes all the unit tests and replaces them with new integration tests.
How to test
git clone https://github.com/nvh95/cra-template-redux
git checkout convert-to-integration-tests
npx create-react-app redux-js file:./cra-template-redux
cd redux-js
npm install
npm run test
Need discussion
For the integration tests for Add Async
. We can speed up the execution time by using jest.useFakeTimers()
. However, there is a caveat to use jest.useFakeTimers()
with @testing-library/user-event
version 14. So I haven't opted-in to use jest-useFakeTimers()
yet. I think for the small tests like this template, to avoid the complexity, we do not need to optimize execution time by using jest.useFakeTimers()
.
Please let me know your thoughts @markerikson. We can keep it as is, or do we want to workaround to opt-in jest.useFakeTimers
?
Tweet about the caveat: https://twitter.com/hung_dev/status/1542448259683479558
Following https://redux.js.org/usage/writing-tests to work on this PR, I also opened a PR to update the docs as well:
- https://github.com/reduxjs/redux/pull/4381
We've migrated the CRA+JS template over to https://github.com/reduxjs/redux-templates, and I've opened up https://github.com/reduxjs/redux-templates/issues/90 to cover rewriting the tests . About to archive this repo, so I'll close this PR.
Thank you for keeping the "unofficial Vite Redux+TS" template repo going, and for filing this PR!
@markerikson Thank you very much. Let me see if I can give a hand on that.