用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
直接命令不会经过审查 Prompt;运行前请先检查来源。
npx skills add https://github.com/mkaraivanov/invoice-processor --skill write-e2e命令会保持在同一行。复制前请横向滚动并检查完整内容。
想先保存到本地?可下载 SkillsMP 当前能够提供的文件。
正在显示 SKILL.md
基于 SOC 职业分类
| name | write-e2e |
| description | Write a Playwright E2E test for a specified flow using the project's auth setup pattern |
| disable-model-invocation | true |
| argument-hint | [flow-description] |
Write a Playwright E2E test for: $ARGUMENTS
Read docs/TESTING_STRATEGY.md Phase 4 before writing.
Auth is established ONCE by tests/e2e/auth.setup.ts. Individual tests do NOT perform login.
The storageState: 'playwright/.auth/user.json' is set globally in playwright.config.ts — do NOT add test.use({ storageState }) in your test file unless you need a DIFFERENT auth state.
import { test, expect } from '@playwright/test'
// storageState already loaded — user is pre-authenticated
test.describe('$ARGUMENTS', () => {
test('happy path', async ({ page }) => {
await page.goto('/dashboard')
// ...
})
})
Unauthenticated test (exception):
test('unauthenticated user redirects to login', async ({ page, context }) => {
await context.clearCookies()
await page.goto('/dashboard')
await expect(page).toHaveURL('/login')
})
All E2E tests live in tests/e2e/. Name the file after the flow:
invoices-upload.spec.tsauth-guard.spec.ts// Redirect assertion
await expect(page).toHaveURL('/dashboard')
// Visible element (auto-waits)
await expect(page.getByRole('heading', { name: 'Invoices' })).toBeVisible()
// File upload
await page.locator('input[type="file"]').setInputFiles({
name: 'test.pdf',
mimeType: 'application/pdf',
buffer: Buffer.from('%PDF-1.4 test'),
})
// Network error simulation
await page.route('**/api/invoices', route => route.abort('failed'))
When testing that user A cannot access user B's data, use a SEPARATE browser context for user B:
test('cannot access another user\'s invoice', async ({ page, context }) => {
// page is user A (pre-authenticated via storageState)
// Create a fully isolated context for user B
const secondCtx = await context.browser()!.newContext()
const secondPage = await secondCtx.newPage()
// ... register/login second user, try to access first user's resource
await secondCtx.close()
})
process.env['TEST_USER_EMAIL'] // bracket notation required (TS strict)
process.env['TEST_USER_PASSWORD']
process.env['TEST_BASE_URL'] // default: http://localhost:3000
page.route() to simulate server errors)# If playwright/.auth/user.json is missing:
npx playwright test --project=setup
# Run the new test
npx playwright test tests/e2e/<your-file>.spec.ts --project=chromium
Implement a numbered testing strategy phase from docs/testing_strategy_phases/phase_$ARGUMENTS_*.md step by step
Implement a numbered phase from docs/phases/phase-$ARGUMENTS.md step by step
Review changed code for correctness, security, and project conventions. Invoke this skill automatically whenever a complete unit of work is done — a full implementation phase, a complete feature (repository + service + route + component all connected), or just before creating a PR. Do NOT invoke after editing a single file or mid-way through a feature. If the user says "done", "finished", "phase complete", "ready to commit", or similar, trigger this review immediately.