Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/johnpooch/rtk-query-example-app
https://github.com/johnpooch/rtk-query-example-app
Last synced: about 2 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/johnpooch/rtk-query-example-app
- Owner: johnpooch
- Created: 2021-07-29T11:16:08.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2022-01-18T11:08:06.000Z (almost 3 years ago)
- Last Synced: 2023-03-09T03:11:30.432Z (almost 2 years ago)
- Language: TypeScript
- Size: 267 KB
- Stars: 12
- Watchers: 2
- Forks: 11
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# RTK Query Example App
This is an example app to demonstrate adding basic tests to a simple [RTK Query][rtk-query] implementation.
## Tests
* The test script [here][service-tests] provides an approach for adding basic tests to your RTK Query service. The tests cover success and error scenarios a query endpoint and a mutation endpoint.
* The test script [here][hooks-tests] provides an approach for adding tests for your RTK Query service's automatically generated React hooks.
* There are some [other tests][tests-dir] which demonstrate testing basic redux functionality like selectors and actions.## Prerequisites
Install dev requirements by running `yarn` in the project root.
## Running the tests
In the project root run `yarn test`.
## Starting the app
This project includes a very primitive applcation which exercises the RTK Query implementation. The implementation uses [MSW][msw] as a mock service. You can alter the behavior of the mock service [here][handlers]
In the project root run `yarn start`. The application will be available on port 3000 by default.
[rtk-query]: https://redux-toolkit.js.org/rtk-query/overview
[msw]: https://mswjs.io/
[tests-dir]: https://github.com/johnpooch/rtk-query-example-app/tree/main/src/store/__tests__
[service-tests]: https://github.com/johnpooch/rtk-query-example-app/tree/main/src/store/__tests__/service.test.ts
[hooks-tests]: https://github.com/johnpooch/rtk-query-example-app/blob/main/src/hooks/__tests__/service.test.tsx
[handlers]: https://github.com/johnpooch/rtk-query-example-app/blob/main/src/mockService/handlers.js