Brief example of testing react + effect-rx application using react-testing-library.
src/services/UserRepoService.ts- repo service for fetching user by id from the DBsrc/infrastructure/Db.ts- a-la live database layersrc/rx/index.ts- reactive function, fetching user via UserRepoServicesrc/rx/runtime.ts- Live layer and Rx runtime to enable Rx access to UserRepoServicesrc/Application.tsx- the application componenttests/utils.tsx- utility test functiondescribeMockto make providing service mocks less verbosesrc/__tests__/Application.test.tsx- tests for Application component
bun i
Run the app via bun dev
Run tests via bun run test