GitXplorerGitXplorer
r

example-msw-vite

public
1 stars
0 forks
0 issues

Commits

List of commits on branch main.
Unverified
8650aa791149b24c69bdca5e7a71e52b50819037

docs: update readme

rraisiqueira committed 2 years ago
Unverified
ec3fbb6e6edd974470a0547932afa6dec9d873f2

test: msw in test file

rraisiqueira committed 2 years ago
Unverified
018721a96f304602739441c9923d147c94bdac24

chore: update demo msw

rraisiqueira committed 2 years ago
Verified
39288d0184aec92c3c5eba8b93bbffbffee6166c

project base (#1)

rraisiqueira committed 2 years ago
Verified
1ea9fb42c091feb99bb0a55325039712f78b0f6a

Initial commit

rraisiqueira committed 2 years ago

README

The README file for this repository.

example-msw-vite

A real-world example of using MSW with Vite and @tanstack/react-query.

Getting started

Clone the repository and install the dependencies:

git clone https://github.com/raisiqueira/example-msw-vite
cd example-msw-vite
pnpm install

Start the development server:

pnpm dev

Testing the project

Run the tests:

pnpm run test

Project structure

This project is based on the Eruption template.

This project is a simple example of a React application that uses MSW to mock API requests. All requests are mocked in the src/mocks/handlers.ts file.

To fetch data from the API, the application uses the @tanstack/react-query (former react-query).

The MSW files are located in the mocks folder. The src/mocks/browser.ts file is the entry point for the MSW worker. The src/mocks/handlers.ts file contains the handlers for the mocked requests.

The other related files are:

  • src/App/services: the file that contains an axios instance to fetch data from the API.
  • src/App/hooks: the file that contains the useQuery hook to fetch data from the API.
  • src/App/components/HLTVMatches: the file that contains the component that renders the fetched data.

License

MIT @ Raí Siqueira