Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add RTK Query example with Vitest configuration #3269

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

oidualc
Copy link

@oidualc oidualc commented Mar 14, 2023

Resolves #3254

This pull request adds an example of RTK Query using Vite and testing it with Vitest.
More specifically it's a variation of the basic example.

All the other examples of RTK Query currently are built using Create React App. Since CRA does a lot of configurations under the hood, generally speaking tests with RTK Query using MSW to mock data work out of the box.
Vitest doesn't come with the same configurations and needs some manual setup that I couldn't find documented anywhere.

I hope this example will turn out to be useful for anybody who is using this stack and has trouble with the setup.

@codesandbox
Copy link

codesandbox bot commented Mar 14, 2023

CodeSandbox logoCodeSandbox logo  Open in CodeSandbox Web Editor | VS Code | VS Code Insiders

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

In Vitest tests, query for mocked data throws ERR_INVALID_ARG_TYPE (RTK Query, MSW, Vitest)
2 participants