{"id":15661291,"url":"https://github.com/c-ehrlich/msw-trpc-example","last_synced_at":"2025-05-05T21:48:44.016Z","repository":{"id":165158682,"uuid":"640530405","full_name":"c-ehrlich/msw-trpc-example","owner":"c-ehrlich","description":null,"archived":false,"fork":false,"pushed_at":"2024-02-22T13:20:40.000Z","size":171,"stargazers_count":24,"open_issues_count":0,"forks_count":2,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-31T00:05:45.889Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/c-ehrlich.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2023-05-14T12:01:34.000Z","updated_at":"2025-03-04T10:47:05.000Z","dependencies_parsed_at":"2024-02-22T14:43:10.592Z","dependency_job_id":null,"html_url":"https://github.com/c-ehrlich/msw-trpc-example","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/c-ehrlich%2Fmsw-trpc-example","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/c-ehrlich%2Fmsw-trpc-example/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/c-ehrlich%2Fmsw-trpc-example/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/c-ehrlich%2Fmsw-trpc-example/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/c-ehrlich","download_url":"https://codeload.github.com/c-ehrlich/msw-trpc-example/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252582830,"owners_count":21771725,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-03T13:26:52.203Z","updated_at":"2025-05-05T21:48:43.992Z","avatar_url":"https://github.com/c-ehrlich.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Example for mocking a tRPC API endpoint with `msw-trpc`\n\nThis repo contains a Next.js app using tRPC, and a unit test for a component that uses Mock Service Worker with `msw-trpc` to intercept network requests.\n\nIt is reduced to the bare minimum to focus only on the msw testing setup, and should not be used as a reference on how to build an entire app.\n\nThe files you'll probably want to look at are:\n- `vitest.config.ts` is a minimal Vitest config\n- `src/__test__/setup.tsx` creates our mocked tRPC client and a function to render components with the required providers\n- `src/components/greeting.tsx` exports the Greeting component that we are testing\n- `src/components/greeting.test.tsx` tests our Greeting component\n\nTo get started:\n```\npnpm i\npnpm test\n```\n\nresources:\n- [msw-trpc](https://github.com/maloguertin/msw-trpc)\n\nTODO: \n- some imports are not using `~` because vitest couldn't traverse the import alias for some reason. fix this.\n- some sort of setup (for example dependabot, github actions, etc) to update dependencies and check in CI that everything still works.\n\nPRs welcome. Open an issue first if you're not sure, or contact me on twitter/discord/etc.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fc-ehrlich%2Fmsw-trpc-example","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fc-ehrlich%2Fmsw-trpc-example","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fc-ehrlich%2Fmsw-trpc-example/lists"}