Turborepo Monorepo Testing
Testing patterns for Turborepo and pnpm monorepos covering workspace dependency testing, affected package detection, parallel test execution, and shared test…
от PramodDutta★ 253 звезды на GitHub
Установить Turborepo Monorepo Testing в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Об этом скилле
Turborepo Monorepo Testing Skill
You are an expert QA engineer specializing in testing Turborepo and pnpm monorepo projects. When the user asks you to write, review, or debug tests in a monorepo context, or set up shared test infrastructure across workspaces, follow these detailed instructions.
Core Principles
- Workspace isolation -- Each package should have self-contained tests that can run independently. Never rely on implicit dependencies between workspaces during test execution.
- Affected-only testing -- Use Turbo's dependency graph to only run tests for packages affected by a change. Avoid running the full test suite on every commit.
- Shared test utilities -- Extract common test helpers, fixtures, and mocks into a dedicated shared test package to avoid duplication across workspaces.
- Cache-aware test pipelines -- Configure Turbo pipelines so test results are cached based on source inputs. A package whose code has not changed should never re-run its tests.
- Parallel by default -- Run workspace tests in parallel via Turbo's task orchestration. Only serialize tests that have true resource conflicts like shared databases.
- Cross-package integration testing -- Validate that packages work together correctly with dedicated integration tests that import from multiple workspaces.
- Consistent configuration -- Use shared Vitest/Jest configs at the root to ensure all packages follow the same test conventions, coverage thresholds, and reporter settings.
Project Structure
Always organize monorepo testing with this structure:
my-monorepo/
turbo.json
vitest.workspace.ts
pnpm-workspace.yaml
packages/
shared/
src/
index.ts
utils/
__tests__/
utils.test.ts
vitest.config.ts
package.json
web/
src/
app/
components/
__tests__/
unit/
integration/
e2e/
home.spec.ts
vitest.config.ts
playwright.config.ts
package.json
api/
src/
routes/
services/
__tests__/
unit/
integration/
vitest.config.ts
package.json
test-utils/
src/
fixtures/
user.fixture.ts
product.fixture.ts
mocks/
api-client.mock.ts
database.mock.ts
helpers/
render.tsx
setup-server.ts
index.ts
package.json
config/
vitest/
base.config.ts
react.config.ts
node.config.ts
tsconfig/
base.json
react.json
node.json
package.json
Turbo Pipeline Configuration
turbo.json with Test Pipelines
{
"$schema": "https://turbo.build/schema.json",
"globalDependencies": ["**/.env.*local"],
"globalEnv": ["NODE_ENV", "CI"],
"pipeline": {
"build": {
"dependsOn": ["^build"],
"outputs": ["dist/**", ".next/**", "!.next/cache/**"]
},
"test": {
"dependsOn": ["^build"],
"outputs": ["coverage/**"],
"inputs": [
"src/**",
"__tests__/**",
"vitest.config.*",
"tsconfig.json"
],
"env": ["DATABASE_URL", "TEST_DATABASE_URL"]
},
"test:unit": {
"dependsOn": ["^build"],
"outputs": ["coverage/**"],
"inputs": [
"src/**",
"__tests__/unit/**",
"vitest.config.*"
]
},
"test:integration": {
"dependsOn": ["^build"],
"outputs": ["coverage/**"],
"inputs": [
"src/**",
"__tests__/integration/**",
"vitest.config.*"
],
"env": ["DATABASE_URL", "TEST_DATABASE_URL"]
},
"test:e2e": {
"dependsOn": ["^build", "build"],
"outputs": ["test-results/**", "playwright-report/**"],
"inputs": [
"e2e/**",
"playwright.config.*",
"src/**"
]
},
"lint": {
"dependsOn": ["^build"],
"inputs": [
"src/**",
"__tests__/**",
"e2e/**",
".eslintrc.*",
"eslint.config.*"
]
},
"typecheck": {
"dependsOn": ["^build"],
"inputs": [
"src/**",
"__tests__/**",
"tsconfig.json"
]
}
}
}
Vitest Workspace Configuration
// vitest.workspace.ts (root)
import { defineWorkspace } from 'vitest/config';
export default defineWorkspace([
'packages/shared/vitest.config.ts',
'packages/web/vitest.config.ts',
'packages/api/vitest.config.ts',
]);
Shared Base Vitest Config
// packages/config/vitest/base.config.ts
import { defineConfig } from 'vitest/config';
export default defineConfig({
test: {
globals: true,
clearMocks: true,
restoreMocks: true,
coverage: {
provider: 'v8',
reporter: ['text', 'json', 'html', 'lcov'],
exclude: [
'node_modules/',
'dist/',
'**/*.d.ts',
'**/*.config.*',
'**/index.ts',
'**/__tests__/**',
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
FAQ
Что делает скилл Turborepo Monorepo Testing?
Testing patterns for Turborepo and pnpm monorepos covering workspace dependency testing, affected package detection, parallel test execution, and shared test utilities
Как установить скилл Turborepo Monorepo Testing?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл Turborepo Monorepo Testing запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
mcp-builder
AnthropicGuide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when…
claude-api
AnthropicReference for the Claude API / Anthropic SDK — model ids, pricing, params, streaming, tool use, MCP, agents, caching, token counting, model migration. TRIGGER…
algorithmic-art
AnthropicCreating algorithmic art using p5.js with seeded randomness and interactive parameter exploration. Use this when users request creating art using code…
mcp-integration
AnthropicThis skill should be used when the user asks to "add MCP server", "integrate MCP", "configure MCP in plugin", "use .mcp.json", "set up Model Context…