studio-mock-api-tests
Skill by supabase
Teaches developers how to write Supabase Studio component tests that mock API requests with MSW at the network layer. Covers the customRender and addAPIMock template and common jsdom and MSW pitfalls.
Install studio-mock-api-tests
Built from the published package, never by AI.
git clone --depth 1 https://github.com/supabase/supabase /tmp/supabase && mkdir -p ~/.claude/skills && cp -r /tmp/supabase/.agents/skills/studio-mock-api-tests ~/.claude/skills/studio-mock-api-testsRun in your terminal. Claude Code loads skills from ~/.claude/skills automatically.
git clone --depth 1 https://github.com/supabase/supabase /tmp/supabase && mkdir -p ~/.gemini/antigravity-cli/skills && cp -r /tmp/supabase/.agents/skills/studio-mock-api-tests ~/.gemini/antigravity-cli/skills/studio-mock-api-testsAntigravity CLI loads skills from ~/.gemini/antigravity-cli/skills, or .agents/skills for one project.
Step-by-step: install studio-mock-api-tests in Antigravity CLI
Skills can run scripts on your machine. Some need an API key: check the README.
About
This skill is a working template for component tests in Supabase Studio. It mounts a Studio component, intercepts its network calls with MSW, and asserts on what renders and what gets sent. It covers the customRender and addAPIMock helpers, along with jsdom and MSW gotchas that the source says cost real debugging time.
The skill explains why tests should mock the network instead of using vi.mock on data modules. It describes how to handle path params, profile-gated queries, unhandled requests, permission mocks, and typed HttpResponse.json bodies. It also shows how to capture request bodies when the UI does not reflect them, and how to log MSW lifecycle events when a request is not matched. It is aimed at developers writing or reviewing React Query component tests in the Studio codebase, or migrating existing tests away from vi.mock.
Written from the project's SKILL.md and checked against it.
What it can do
- Write MSW component testsMounts a Studio component with customRender and intercepts its network calls with MSW.
- Mock endpoints with addAPIMockRegisters typed mock responses for platform and v1 API paths, scoped to the current test.
- Mock permissionsUses mockPermissions, mockPermissionsError, and NO_PERMISSIONS to control FGA permission checks.
- Provide a profile contextPasses a ProfileContextType so profile-gated React Query hooks fire in tests.
- Capture request bodiesRecords the body of a request when the server reply does not reflect what was sent.
- Debug unmatched requestsWires MSW request:unhandled and response:mocked events to log matching problems.
- Migrate away from vi.mockExplains why module mocks of @/data hooks hide bugs and how to replace them with network mocks.
What you need
- Supabase Studio codebase (apps/studio)
- MSW
- Vitest
- jsdom
Try asking
- Write an MSW component test for my organizations list in Studio
- Migrate this test from vi.mock('@/data/...') to addAPIMock
- Mock a 500 error from the projects endpoint in my component test
Good to know
- Handler paths must use :param format, not OpenAPI {param} format
- Query strings cannot be placed in handler paths
- Module mocks of data hooks are discouraged by the source
Security check
ANo download-and-run commands, hidden instructions or signs of sending keys out were found.
Checked automatically: .agents/skills/studio-mock-api-tests/SKILL.md. This looks for known risky patterns and is not a full audit. How grades work
Alternatives to studio-mock-api-tests
All alternatives →Runs a 7-stage workflow for auditing, cleaning up and reviewing GitHub repositories, plus competitor analysis. Written for developers who want a repo checked for secrets, junk files and documentation gaps.
Teaches an AI assistant to build, debug and explain Gradio web UIs and ML demos in Python. It covers the core API, components, event listeners, layouts and the MCP server option. Aimed at Python developers who work with Gradio.
Recommends menus, buttons, toolbars and disclosure controls for Apple platforms using Human Interface Guidelines conventions. Built for developers and designers making iOS, iPadOS, macOS or visionOS interfaces. Checks existing project design context before asking questions.
Creates production-ready FastAPI project structures with async patterns, dependency injection, and error handling. It is for developers starting new FastAPI applications or backend API projects.
Analyzes Android apps to find user workflows to expose as AppFunctions, so AI agents and system shortcuts can run them without opening the app UI. Generates Kotlin code and refines KDoc for Android developers.
Creates, edits, validates and runs Agent QA tests, suites and hooks through MCP or CLI. It keeps canonical IDs and schema contracts intact, for developers and QA teams using Agent QA.
Compare with openclaw-github-repo-commander, gradio or hig-components-menus
studio-mock-api-tests: common questions
Why does this skill recommend MSW over vi.mock?
The source says vi.mock bypasses the network boundary, hides bugs like renamed query keys, and skips React Query caching and callback paths. MSW mocks at the network layer instead.
Why do mutation onSuccess callbacks not fire in my test?
The source says a raw new HttpResponse with no body and no content-type can make openapi-fetch hang the mutation flow. Using HttpResponse.json avoids this.
Do I need MSW for a presentational component?
No. The source says that if the component has no data fetching, you can render and assert directly without MSW.
How do I install studio-mock-api-tests?
Run the command above to copy the skill into ~/.claude/skills/. Claude Code picks it up automatically.
Is studio-mock-api-tests free?
The code is published under the Apache-2.0 licence. The service it connects to may have its own pricing.
Is studio-mock-api-tests safe to use?
It scores 89 of 100. Grades: maintenance A, licence A, quality A. Security check: grade A, no risky patterns found in the files checked. Review the code before you install. How grades work.
What are alternatives to studio-mock-api-tests?
Similar skills: openclaw-github-repo-commander, gradio, hig-components-menus, fastapi-templates.
