Skip to main content

CLI de testes E2E com IA: linguagem natural vira Playwright executável.

Project description

Agente Testes

CLI para gravar fluxos E2E (Playwright codegen) e executar specs em segundos — com opção de exploração via linguagem natural e CrewAI.

Repositório: https://github.com/BrunooooPaiva/agente-testes

Instalação global (recomendado)

Pré-requisitos: Python 3.10–3.13, Node.js 18+ (npm/npx no PATH), chave OpenAI.

Opção A — PyPI (recomendado)

pip install --pre agente-testes
agente-testes setup

Com uv:

uv tool install --pre agente-testes
agente-testes setup

Opção B — uv tool a partir do repositório

cd agente_testes
uv tool install --prerelease=allow .
agente-testes setup

Opção C — repositório Git

pip install "agente-testes @ git+https://github.com/BrunooooPaiva/agente-testes.git"
agente-testes setup

O comando setup cria ~/.agente-testes/.env, instala @playwright/test e o Chromium no runtime global.

Edite a API key:

notepad $env:USERPROFILE\.agente-testes\.env

Fluxo principal (gravar → executar)

# 1. Entre no projeto que quer testar
cd C:\projetos\meu-app

# 2. Prepara workspace (tests/e2e/ + .agente-testes/)
agente-testes init

# 3. Com o app rodando (npm run dev), grave o fluxo no navegador
agente-testes record --url http://localhost:3000

# 4. Repita o teste sem IA (segundos)
agente-testes exec tests/e2e/recorded-YYYYMMDD-HHMMSS.spec.js --url http://localhost:3000

Rotas autenticadas: agente-testes auth-setup e depois record --auth ou exec com AGENTE_TESTES_STORAGE_STATE.

Exploração com IA (opcional)

agente-testes run "Validar login com e-mail inválido na rota /login"

Use run para descobrir cenários; use record + exec para repetir com custo zero de API.

Comandos

Comando Descrição
agente-testes record Grava fluxo com Playwright codegen → tests/e2e/*.spec.js
agente-testes exec <spec> Executa spec sem IA (replay em segundos)
agente-testes auth-setup Login determinístico → auth-state.json
agente-testes run "<pedido>" Exploração com IA (CrewAI) — mais lento, usa API
agente-testes init Cria tests/e2e/, .agente-testes/ e .gitignore
agente-testes doctor Valida Python, API key, npx, Playwright, URL e portas locais
agente-testes setup Instala runtime Playwright (uso global)
agente-testes --verbose run ... Logs completos do CrewAI

Exemplo determinístico (CT-02 versionado):

agente-testes exec tests/e2e/demo-login-invalid.spec.js --repo fixtures/demo-app

Flags úteis do run: --repo, --url, --skip-url-check.

Desenvolvimento local

cd agente_testes
uv sync
npm install
npx playwright install chromium
copy .env.example .env
# Edite OPENAI_API_KEY em .env

uv run agente-testes doctor
uv run python scripts/start_demo.py   # http://localhost:3000/login

Demo E2E:

cd fixtures\demo-app
uv run agente-testes init
uv run agente-testes run "Validar login com e-mail inválido na rota /login"

Smoke (sem LLM):

uv run python scripts/smoke_tools.py

Configuração

Onde Variável Uso
~/.agente-testes/.env OPENAI_API_KEY Obrigatória (instalação global)
Projeto alvo .env AGENTE_TESTES_APP_URL URL do app sob teste
CLI --url Sobrescreve URL na execução

Artefatos ficam em <projeto>/.agente-testes/ (output/, artifacts/, temp_specs/).

Estrutura

src/agente_testes/   CLI, crew, tools, self-healing
fixtures/demo-app/   App HTTP de demonstração (:3000)
scripts/             smoke, demo, hooks de commit
docs/COMMITS.md      Padrão de commits do projeto

Segurança

  • Nunca commite .env; use .env.example / ~/.agente-testes/.env
  • Tools bloqueiam leitura de secrets no repositório alvo
  • Subprocess Playwright usa env mínimo (sem OPENAI_API_KEY)

Validação em app externo (CT-05, só local)

Apps reais na sua máquina podem ser usados para teste manual (agente-testes run com --repo implícito via cwd). Isso não faz parte do CI nem dos specs versionados deste pacote. Guia: docs/CT-05.md.

Padrões Next.js + toast Sonner: fixture fixtures/nextjs-sonner-fixture/.

Fase 5 — qualidade

  • Pré-leitura de login antes da IA (login_preflight)
  • Healing proativo ao salvar specs
  • Testes: uv run --group dev pytest tests/ -q

Detalhes: docs/FASE-5.md

CI (GitHub Actions)

Licença

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

agente_testes-0.5.0.tar.gz (308.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

agente_testes-0.5.0-py3-none-any.whl (66.7 kB view details)

Uploaded Python 3

File details

Details for the file agente_testes-0.5.0.tar.gz.

File metadata

  • Download URL: agente_testes-0.5.0.tar.gz
  • Upload date:
  • Size: 308.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for agente_testes-0.5.0.tar.gz
Algorithm Hash digest
SHA256 4f059abfebf1b3c46e5f04bdd1f08ecd0ada8ef49ad09d7daa438986191a65c9
MD5 5174b1263470c612e28f2ab13151566d
BLAKE2b-256 c041eba18b952cc71a40c64f66f54e10c801286f051e300a8bb983cddc1e689f

See more details on using hashes here.

Provenance

The following attestation bundles were made for agente_testes-0.5.0.tar.gz:

Publisher: publish-pypi.yml on BrunooooPaiva/agente-testes

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file agente_testes-0.5.0-py3-none-any.whl.

File metadata

  • Download URL: agente_testes-0.5.0-py3-none-any.whl
  • Upload date:
  • Size: 66.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for agente_testes-0.5.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f3dfb033b92f19c8f148ecfd6e3e60195b245ec7fd5ed6cb04d28ad6a4936736
MD5 97b88f1a83e9fea134283f3759d0b745
BLAKE2b-256 105cc107c54664aa40b9c58d91acb1728c30c13419b739e92bbac985eec12347

See more details on using hashes here.

Provenance

The following attestation bundles were made for agente_testes-0.5.0-py3-none-any.whl:

Publisher: publish-pypi.yml on BrunooooPaiva/agente-testes

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page