brainstorming
brainstorming
You MUST use this before any creative work - creating features, building components, adding functionality, modifying behavior, or planning anything new, in software or out of it (a talk, a business, a renovation).
initConfigure o Playwright em um projeto. Use quando o usuário disser "configurar playwright", "adicionar testes e2e", "configurar playwright", "setup de testes", "iniciar playwright" ou "adicionar infraestrutura de testes".
Independent GitHub snapshot · Automated classification · Original documentation governs
name: "init" description: >- Configure o Playwright em um projeto. Use quando o usuário disser "configurar playwright", "adicionar testes e2e", "configurar playwright", "setup de testes", "iniciar playwright" ou "adicionar infraestrutura de testes". agents:
Configure um ambiente de testes Playwright pronto para produção. Detecte o framework, gere config, estrutura de pastas, teste de exemplo e pipeline de CI.
Use o subagente Explore para escanear o projeto:
package.json para identificar o framework (React, Next.js, Vue, Angular, Svelte)tsconfig.json → usar TypeScript; caso contrário, JavaScript@playwright/test nas dependências)tests/, e2e/, __tests__/).github/workflows/, .gitlab-ci.yml)Se ainda não estiver instalado:
npm init playwright@latest -- --quiet
Ou se o usuário preferir configuração manual:
npm install -D @playwright/test
npx playwright install --with-deps chromium
playwright.config.tsAdaptar ao framework detectado:
Next.js:
import { defineConfig, devices } from '@playwright/test';
export default defineConfig({
testDir: './e2e',
fullyParallel: true,
forbidOnly: !!process.env.CI,
retries: process.env.CI ? 2 : 0,
workers: process.env.CI ? 1 : undefined,
reporter: [
['html', { open: 'never' }],
['list'],
],
use: {
baseURL: 'http://localhost:3000',
trace: 'on-first-retry',
screenshot: 'only-on-failure',
},
projects: [
{ name: "chromium", use: { ...devices['Desktop Chrome'] } },
{ name: "firefox", use: { ...devices['Desktop Firefox'] } },
{ name: "webkit", use: { ...devices['Desktop Safari'] } },
],
webServer: {
command: 'npm run dev',
url: 'http://localhost:3000',
reuseExistingServer: !process.env.CI,
},
});
React (Vite):
baseURL para http://localhost:5173webServer.command para npm run devVue/Nuxt:
baseURL para http://localhost:3000webServer.command para npm run devAngular:
baseURL para http://localhost:4200webServer.command para npm run startNenhum framework detectado:
webServerbaseURL com base na entrada do usuário ou deixar como placeholdere2e/
├── fixtures/
│ └── index.ts # Fixtures personalizados
├── pages/
│ └── .gitkeep # Page object models
├── test-data/
│ └── .gitkeep # Arquivos de dados de teste
└── example.spec.ts # Primeiro teste de exemplo
import { test, expect } from '@playwright/test';
test.describe('Homepage', () => {
test('should load successfully', async ({ page }) => {
await page.goto('/');
await expect(page).toHaveTitle(/.+/);
});
test('should have visible navigation', async ({ page }) => {
await page.goto('/');
await expect(page.getByRole('navigation')).toBeVisible();
});
});
Se .github/workflows/ existir, criar playwright.yml:
name: "playwright-tests"
on:
push:
branches: [main, dev]
pull_request:
branches: [main, dev]
jobs:
test:
timeout-minutes: 60
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: lts/*
- name: "install-dependencies"
run: npm ci
- name: "install-playwright-browsers"
run: npx playwright install --with-deps
- name: "run-playwright-tests"
run: npx playwright test
- uses: actions/upload-artifact@v4
if: ${{ !cancelled() }}
with:
name: "playwright-report"
path: playwright-report/
retention-days: 30
Se .gitlab-ci.yml existir, adicionar um stage Playwright no lugar.
.gitignoreAdicionar se ainda não estiver presente:
/test-results/
/playwright-report/
/blob-report/
/playwright/.cache/
Adicionar ao package.json em scripts:
{
"test:e2e": "playwright test",
"test:e2e:ui": "playwright test --ui",
"test:e2e:debug": "playwright test --debug"
}
Executar o teste de exemplo:
npx playwright test
Reportar o resultado. Se falhar, diagnosticar e corrigir antes de concluir.
Confirmar o que foi criado:
npx playwright test ou npm run test:e2e