plugin-test-coverage
This skill guides agents through expanding Vitest unit tests and Playwright e2e tests for plugins in a monorepo.
Identity proven by GitHub's verified organisation badge (sanity-io)
- Agents
- Claude Code, Codex, Cursor, Gemini CLI, GitHub Copilot, OpenCode, claude.ai and API
- License
- MIT (permissive)
- Pin
- a80a997pinned Oct 9, 2026
- Context cost
- about 1,200 tokenswhen the skill loads
- GitHub stars
- 20on sanity-io/plugins
- Scripts
- None found
What it does
“Guides agents through expanding Vitest and Playwright e2e coverage for a monorepo plugin. Use when adding or improving plugin tests, wiring e2e-studio, or following the internationalized-array / document-internationalization coverage playbook.”
Generated summary from the skill's own text
This skill guides agents through expanding Vitest unit tests and Playwright e2e tests for plugins in a monorepo. It covers inventory of use cases, test mapping strategies, co-locating tests with source code, wiring plugins into e2e-studio, and following established patterns from reference implementations like document-internationalization and internationalized-array.
When to use it
- Adding or improving unit and integration test coverage for published plugins
- Integrating a plugin into e2e-studio and writing Playwright end-to-end specs
- Porting an established test coverage workflow to a new plugin
When not to
- Testing one-off tooling like migrations or banners unrelated to authoring
- When a plugin is not located in the plugins directory of the monorepo
Install
These commands install from the publisher's repository and need no account.
skills CLI
npx skills add sanity-io/plugins --skill plugin-test-coverageInstalls from the repository's default branch, which may have changed since the commit we checked.
GitHub CLI 2.90 or later
gh skill install sanity-io/plugins plugin-test-coverage@a80a997e3d11d188f9639ac3efab1d8f93a276efInstalls the commit we checked (a80a997).
Copy by hand
Download the folder at a80a997 and put it in .claude/skills/plugin-test-coverage for Claude Code and in .agents/skills/plugin-test-coverage for Codex, Cursor, Gemini CLI, GitHub Copilot and OpenCode.
Claude Code plugin
/plugin install sanity@claude-plugins-officialThe publisher's plugin in Claude's official marketplace. It may hold more than this skill, and we have not pinned it.
Copy for your agent
A prompt for any coding agent. It installs this skill from GitHub at the pinned commit, copies the files as they are, and runs nothing unless you ask.
Prompt
Install the agent skill "plugin-test-coverage" by Sanity. Source, pinned to commit a80a997e3d11d188f9639ac3efab1d8f93a276ef: https://github.com/sanity-io/plugins/tree/a80a997e3d11d188f9639ac3efab1d8f93a276ef/.agents/skills/plugin-test-coverage 1. Download that folder at exactly this commit. Do not use the default branch. 2. Copy every file unchanged, keeping the folder structure, into .claude/skills/plugin-test-coverage/ for Claude Code and .agents/skills/plugin-test-coverage/ for Codex, Cursor, Gemini CLI, GitHub Copilot and OpenCode. Create the folders if they do not exist. 3. Do not edit the files, and do not run any script in the folder unless I ask you to. 4. When you are done, list the files you copied and where you put them. Listing and checks: https://www.agentnative.dev/skills/sanity/plugin-test-coverage
SKILL.md at the pin
---
name: plugin-test-coverage
description: Guides agents through expanding Vitest and Playwright e2e coverage for a monorepo plugin. Use when adding or improving plugin tests, wiring e2e-studio, or following the internationalized-array / document-internationalization coverage playbook.
---
# Plugin Test Coverage
Use this skill when expanding **Vitest** and/or **Playwright e2e** coverage for a plugin under `plugins/`.
Reference implementations:
- `@sanity/document-internationalization` — Vitest + e2e under `e2e/tests/document-internationalization/`
- `sanity-plugin-internationalized-array` — Vitest + e2e under `e2e/tests/internationalized-array/`
Also read [`e2e/README.md`](../../../e2e/README.md) before writing Playwright specs.
## When to use
- Filling unit/integration gaps for a published plugin
- Wiring a plugin into `dev/e2e-studio` and adding Playwright specs
- Porting the doc-i18n / internationalized-array coverage process to another plugin
## Workflow
1. **Inventory use cases** from README + source (authoring loops, config knobs, integrations).
2. **Map each use case** to Vitest (pure logic, components with mocks) vs Playwright (studio UX that needs a real form).
3. **Fill Vitest gaps** co-located under `plugins/<pkg>/src/` — plugin assembly, context/providers, utils, components.
4. **Wire e2e-studio** — `definePlugin` example file, register in **both** chromium/firefox workspaces.
5. **Add helpers + specs** — `e2e/helpers/<plugin>/`, `e2e/tests/<plugin>/`.
6. **Changesets** — separate patch changeset per published package that gained `data-testid`s or runtime changes. Private e2e/studio files need none.
7. **Verify** — `pnpm format && pnpm lint && pnpm knip && pnpm build && pnpm test` (and targeted e2e when secrets allow).
8. **PR** — draft, `🤖 bot` label, inventory + e2e test table in the description.
Skip one-off tooling (migrations, banners) unless they are part of the main authoring loop.
## Vitest patterns
- Co-locate `*.test.ts(x)` next to source; use jsdom via the package `vitest.config.ts`.
- Shared mocks/fixtures in `src/test/helpers.ts` and `src/test/component-helpers.tsx` (`ThemeWrapper` for `@sanity/ui`).
- Plugin assembly tests: call the plugin factory, assert schema type names, document layout, form input wrappers, nested plugins.
- Context/provider tests: mock `useClient` / `useWorkspace` / pane hooks; use `Suspense` + `act` for async `React.use` language resolution; call any module-level `clear()` between tests.
- Timeouts: `test('name', {timeout: 30_000}, async () => { … })` — options object as second arg.
- Keep the package-exports snapshot test; update with `pnpm test -u` only when exports intentionally change.
- React Compiler is on — do not add unnecessary `useMemo` / `useCallback`.
Run a single package:
```bash
pnpm --filter <package-name> test run
```
## E2e structure
```
e2e/
├── tests/
│ ├── smoke.spec.ts # studio-wide only
│ └── <plugin-name>/
│ └── <plugin-name>.spec.ts
└── helpers/
└── <plugin-name>/
└── <helpers>.ts
```
Do not dump plugin specs at the top level of `tests/`.
## E2e-studio wiring
1. Add `dev/e2e-studio/src/<example>.ts` with `definePlugin` that registers schema + the plugin under test.
2. Import and add it to **both** workspaces in `dev/e2e-studio/sanity.config.ts`.
3. Ensure the workspace `package.json` already depends on the plugin (`workspace:*`).
4. Update the “Currently wired” list in `e2e/README.md`.
## Hard-won Playwright lessons
- Project `baseURL` must end with a **trailing slash** (`…/chromium/`, `…/firefox/`).
- Navigate with **relative** intents: `intent/edit/id=…;type=…`. Never host-absolute `/intent/…` (drops workspace basePath → “Workspace not found”).
- Auth: Playwright `storageState` seeds `__studio_auth_token_<projectId>`; preflight `/users/me`. Never use `SANITY_DEPLOY_TOKEN` for e2e session auth.
- Local pitfall: stale server on `:3333` + `reuseExistingServer` → signed-out studio. Kill and restart.
- Prefer accessible role/name locators; add `data-testid` + a **patch** changeset only when selectors are flaky or ambiguous (e.g. duplicate add-button grids).
- Seed documents via the Content Lake API; always `try/finally` cleanup.
- Video: `SANITY_E2E_VIDEO=on` when debugging.
- Document existence matters: some plugins only auto-seed after `_rev` exists — seed empty persisted docs, don’t rely on brand-new unsaved drafts.
## PR checklist
- [ ] Separate changeset per published package touched
- [ ] Draft PR with `🤖 bot` label
- [ ] Use-case inventory + e2e test table in the description
- [ ] `pnpm format` / `lint` / `knip` / `build` / `test` green
- [ ] CI e2e (chromium + firefox) green when studio wiring changed
## Pointers
- [`e2e/README.md`](../../../e2e/README.md)
- [`AGENTS.md`](../../../AGENTS.md) — CI commands, changesets, Node version notes
- Doc-i18n + internationalized-array as living examples
From sanity-io/plugins at a80a997, shown as plain text under its license: MIT (permissive). The license text is in LICENSE.
View SKILL.md on GitHub at a80a997Files
- SKILL.md5.0 KB · 774804bed918
1 file, 5.0 KB in total. Each file has a sha256 in the pin's manifest; the first 12 characters are shown.
Skill folder on GitHub at a80a997More from Sanity
sanity-live-cache-components
Integrates Sanity Live with Next.js Cache Components in next-sanity v13+ apps, setting up shared cached data fetching through sanityFetch, live content…
Claude Code, Codex, Cursor +4 · about 4K tokens · pinned 6 days ago
content-experimentation-best-practices
This skill provides guidance for designing and running content experiments using A/B and multivariate testing.
Claude Code, Codex, Cursor +4 · about 360 tokens · pinned 6 days ago
content-modeling-best-practices
Guides agents through structured content modeling principles for headless CMSes like Sanity, covering schema design, content reuse strategies, and field…
Claude Code, Codex, Cursor +4 · about 340 tokens · pinned 6 days ago
portable-text-conversion
Converts HTML and Markdown content into Portable Text blocks for Sanity using markdownToPortableText, htmlToBlocks, or manual construction.
Claude Code, Codex, Cursor +4 · about 510 tokens · pinned 6 days ago
portable-text-serialization
This skill enables rendering Portable Text content across multiple frameworks and output formats using the @portabletext library family.
Claude Code, Codex, Cursor +4 · about 940 tokens · pinned 6 days ago
sanity-best-practices
This skill provides best practices for Sanity headless CMS development across schema design, GROQ queries, framework integrations (Next.js, Nuxt, Astro…
Claude Code, Codex, Cursor +4 · about 1.1K tokens · pinned 6 days ago
Related in Testing and QA
triaging-visual-review-runs
Inspects PostHog Visual Review screenshot regression runs that gate pull requests, helping engineers triage diff results, identify flaky stories, and decide…
by PostHogOfficial publisher
Claude Code, Codex, Cursor +4 · about 8.9K tokens · pinned 6 days ago
webapp-testing
This skill enables agents to test local web applications using Playwright by writing Python automation scripts.
by SnykOfficial publisher
Contains scripts
Claude Code, Codex, Cursor +3 · about 890 tokens · pinned 6 days ago
emulate
This skill runs local emulated APIs for 14+ third-party services including Vercel, GitHub, Google, Slack, AWS, Stripe, and others.
by VercelOfficial publisher
Claude Code, Codex, Cursor +4 · about 4.7K tokens · pinned 6 days ago
browser-probe
This skill probes a URL with escalating headless browser configurations to detect CDN bot protection systems like Akamai and Cloudflare, then generates a…
by Adobe, Inc.Official publisher
Contains scripts
Claude Code · about 1K tokens · pinned 6 days ago
offload-onboard
This skill onboards a repository to use Offload, a parallel test runner that executes tests across Modal cloud sandboxes.
by ImbueOfficial publisher
Claude Code · about 7.1K tokens · pinned 6 days ago
browser-navigation
This skill enables agents to automate browser interactions including navigation, form filling, element clicking, screenshots, and data extraction from web…
by FactoryOfficial publisher
Claude Code, Codex, Cursor +3 · about 2.5K tokens · pinned 6 days ago