Skip to content

Commit 43865f4

Browse files
committed
-ajustes del read.me
1 parent 4e0ccc6 commit 43865f4

File tree

1 file changed

+146
-171
lines changed

1 file changed

+146
-171
lines changed

README.md

Lines changed: 146 additions & 171 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,112 @@
1-
Aquí tienes un ejemplo de un archivo README.md para un proyecto de Playwright con Allure en TypeScript. Incluye información sobre el propósito del proyecto, el uso del Page Object Model (POM), la integración con Allure, cómo ver reportes, y una lista de comandos útiles, incluyendo --ui.
2-
Proyecto de Automatización con Playwright, TypeScript y Allure
3-
Este proyecto implementa pruebas automatizadas de interfaz de usuario usando Playwright con TypeScript como lenguaje principal y Allure para la generación de reportes detallados. El enfoque sigue el patrón Page Object Model (POM) para mantener las pruebas organizadas, mantenibles y reutilizables.
4-
Propósito
1+
# README - Playwright Automation Project with TypeScript and Allure
2+
3+
## English
4+
5+
### Project Overview
6+
This project implements automated UI tests using Playwright with TypeScript as the primary language and Allure for generating detailed reports. The approach follows the Page Object Model (POM) to keep tests organized, maintainable, and reusable.
7+
8+
### Purpose
9+
Automate functional tests for a web application (e.g., a form at https://v0-classic-registration-form-u8ghow.vercel.app/) to validate behaviors such as:
10+
- Required and optional fields.
11+
- Format validations (email, phone).
12+
- Success or error messages after form submission.
13+
14+
### Technologies Used
15+
- **Playwright**: Browser automation tool.
16+
- **TypeScript**: Statically typed language for better maintainability.
17+
- **Allure**: Generates visual and interactive reports.
18+
- **Node.js**: Execution environment.
19+
20+
### Project Structure
21+
```
22+
project-root/
23+
├── Pages/ # POM classes for pages
24+
│ └── FormPage.ts # Example: Class to interact with the form
25+
├── tests/ # Test files
26+
│ └── registration.spec.ts # Test cases for the form
27+
├── allure-results/ # Allure-generated results (git ignored)
28+
├── allure-report/ # Generated HTML report (git ignored)
29+
├── test-results/ # Playwright traces and screenshots (git ignored)
30+
├── playwright.config.ts # Playwright configuration
31+
├── package.json # Dependencies and scripts
32+
├── tsconfig.json # TypeScript configuration
33+
└── README.md # This file
34+
```
35+
36+
### Installation
37+
Clone the repository:
38+
```bash
39+
git clone <REPOSITORY_URL>
40+
cd <PROJECT_NAME>
41+
```
42+
Install dependencies:
43+
```bash
44+
npm install
45+
```
46+
Install Playwright browsers:
47+
```bash
48+
npx playwright install
49+
```
50+
51+
### Prerequisites
52+
- **Node.js**: v16 or higher.
53+
- **Java**: v8 or higher (required for Allure CLI).
54+
55+
### Running Tests
56+
Execute all tests:
57+
```bash
58+
npm run test
59+
# or
60+
npx playwright test
61+
```
62+
Run a specific test file:
63+
```bash
64+
npx playwright test tests/registration.spec.ts
65+
```
66+
Run in headed mode:
67+
```bash
68+
npx playwright test --headed
69+
```
70+
Use Playwright's UI mode:
71+
```bash
72+
npx playwright test --ui
73+
```
74+
75+
### Generating Allure Reports
76+
Run tests and generate a report:
77+
```bash
78+
npm run test-and-report
79+
```
80+
Manually generate a report:
81+
```bash
82+
npx allure generate allure-results --clean -o allure-report
83+
```
84+
Open the report:
85+
```bash
86+
npx allure open allure-report
87+
```
88+
89+
---
90+
91+
## Español
92+
93+
### Descripción del Proyecto
94+
Este proyecto implementa pruebas automatizadas de interfaz de usuario utilizando Playwright con TypeScript como lenguaje principal y Allure para la generación de reportes detallados. El enfoque sigue el patrón Page Object Model (POM) para mantener las pruebas organizadas, mantenibles y reutilizables.
95+
96+
### Propósito
597
Automatizar pruebas funcionales en una aplicación web (por ejemplo, un formulario en https://v0-classic-registration-form-u8ghow.vercel.app/) para validar comportamientos como:
6-
Campos obligatorios y no obligatorios.
7-
Validaciones de formato (email, teléfono).
8-
Mensajes de éxito o error tras el envío del formulario.
9-
Tecnologías
10-
Playwright: Herramienta de automatización de navegadores.
11-
TypeScript: Lenguaje para tipado estático y mejor mantenibilidad.
12-
Allure: Generación de reportes visuales e interactivos.
13-
Node.js: Entorno de ejecución.
14-
Estructura del Proyecto
98+
- Campos obligatorios y opcionales.
99+
- Validaciones de formato (correo electrónico, teléfono).
100+
- Mensajes de éxito o error tras el envío del formulario.
101+
102+
### Tecnologías Usadas
103+
- **Playwright**: Herramienta de automatización de navegadores.
104+
- **TypeScript**: Lenguaje con tipado estático para mejor mantenibilidad.
105+
- **Allure**: Generación de reportes visuales e interactivos.
106+
- **Node.js**: Entorno de ejecución.
107+
108+
### Estructura del Proyecto
109+
```
15110
project-root/
16111
├── Pages/ # Clases POM para las páginas
17112
│ └── FormPage.ts # Ejemplo: Clase para interactuar con el formulario
@@ -24,177 +119,57 @@ project-root/
24119
├── package.json # Dependencias y scripts
25120
├── tsconfig.json # Configuración de TypeScript
26121
└── README.md # Este archivo
27-
Page Object Model (POM)
28-
Este proyecto usa el patrón POM para encapsular la lógica de interacción con las páginas web:
29-
Ubicación: Las clases POM están en la carpeta Pages/.
30-
Ejemplo: FormPage.ts contiene métodos como fillName(), submitForm(), y expectErrorForField() para interactuar con un formulario.
31-
Ventajas:
32-
Código reutilizable.
33-
Separación de lógica de pruebas y elementos de la UI.
34-
Fácil mantenimiento si la UI cambia.
35-
Instalación
36-
Clona el repositorio:
37-
bash
122+
```
123+
124+
### Instalación
125+
Clonar el repositorio:
126+
```bash
38127
git clone <URL_DEL_REPOSITORIO>
39128
cd <NOMBRE_DEL_PROYECTO>
40-
Instala las dependencias:
41-
bash
129+
```
130+
Instalar dependencias:
131+
```bash
42132
npm install
43-
Instala los navegadores de Playwright:
44-
bash
133+
```
134+
Instalar navegadores de Playwright:
135+
```bash
45136
npx playwright install
46-
Requisitos previos
47-
Node.js: v16 o superior.
48-
Java: v8 o superior (necesario para Allure CLI).
49-
Configuración
50-
El archivo playwright.config.ts define las opciones de ejecución:
51-
Carpeta de pruebas: ./tests.
52-
Reporteros: 'line' (consola) y 'allure-playwright' (Allure).
53-
Navegadores: Chromium por defecto.
54-
Base URL: https://v0-classic-registration-form-u8ghow.vercel.app/.
55-
Ejemplo de configuración:
56-
typescript
57-
import { defineConfig } from '@playwright/test';
58-
59-
export default defineConfig({
60-
testDir: './tests',
61-
timeout: 30000,
62-
reporter: [['line'], ['allure-playwright', { outputFolder: 'allure-results' }]],
63-
use: {
64-
baseURL: 'https://v0-classic-registration-form-u8ghow.vercel.app/',
65-
headless: true,
66-
screenshot: 'only-on-failure',
67-
trace: 'on',
68-
},
69-
projects: [
70-
{ name: 'chromium', use: { browserName: 'chromium' } },
71-
],
72-
});
73-
Uso del Proyecto
74-
Comandos más utilizados
75-
Ejecución de pruebas
76-
Correr todas las pruebas:
77-
bash
137+
```
138+
139+
### Requisitos Previos
140+
- **Node.js**: v16 o superior.
141+
- **Java**: v8 o superior (necesario para Allure CLI).
142+
143+
### Ejecución de Pruebas
144+
Ejecutar todas las pruebas:
145+
```bash
78146
npm run test
79147
# o
80148
npx playwright test
81-
Correr un archivo específico:
82-
bash
149+
```
150+
Ejecutar un archivo específico:
151+
```bash
83152
npx playwright test tests/registration.spec.ts
84-
Correr con interfaz gráfica:
85-
bash
153+
```
154+
Ejecutar en modo gráfico:
155+
```bash
86156
npx playwright test --headed
157+
```
87158
Modo UI de Playwright:
88-
Usa la interfaz gráfica de Playwright para explorar y ejecutar pruebas:
89-
bash
159+
```bash
90160
npx playwright test --ui
91-
Abre una UI en el navegador donde puedes:
92-
Ver y filtrar pruebas.
93-
Ejecutarlas individualmente.
94-
Depurar con inspector.
95-
Generación de reportes con Allure
96-
Correr pruebas y generar reporte:
97-
bash
161+
```
162+
163+
### Generación de Reportes Allure
164+
Ejecutar pruebas y generar reporte:
165+
```bash
98166
npm run test-and-report
99-
Este script:
100-
Ejecuta las pruebas (npx playwright test).
101-
Genera el reporte (npx allure generate).
102-
Abre el reporte (npx allure open).
167+
```
103168
Generar reporte manualmente:
104-
bash
169+
```bash
105170
npx allure generate allure-results --clean -o allure-report
171+
```
106172
Abrir reporte:
107-
bash
108-
npx allure open allure-report
109-
Limpieza
110-
Limpiar caché y resultados:
111-
bash
112-
npm run clean
113-
Elimina node_modules, test-results, allure-results, allure-report, y el caché de npm.
114-
Instalar desde cero:
115-
bash
116-
npm run install-fresh
117-
Depuración
118-
Depurar paso a paso:
119-
bash
120-
npx playwright test --debug
121-
Ver salida en consola:
122-
bash
123-
npx playwright test --reporter=line
124-
Scripts en package.json
125-
json
126-
{
127-
"scripts": {
128-
"test": "npx playwright test",
129-
"test-ui": "npx playwright test --ui",
130-
"clean": "rm -rf node_modules package-lock.json test-results allure-results allure-report && npm cache clean --force",
131-
"install-fresh": "npm run clean && npm install && npx playwright install",
132-
"generate-report": "npx allure generate allure-results --clean -o allure-report",
133-
"open-report": "npx allure open allure-report",
134-
"test-and-report": "npm run test && npm run generate-report && npm run open-report"
135-
}
136-
}
137-
Integración con Allure
138-
Allure se integra como reportero en Playwright para generar reportes detallados:
139-
Configuración: Definida en playwright.config.ts con 'allure-playwright'.
140-
Resultados: Guardados en allure-results tras ejecutar las pruebas.
141-
Generación: Convertidos a HTML con npx allure generate.
142-
Visualización: Abiertos con npx allure open.
143-
Ver los reportes
144-
Después de correr npm run test-and-report, el reporte se abre automáticamente en tu navegador (e.g., http://localhost:XXXX).
145-
Si no se abre, usa:
146-
bash
173+
```bash
147174
npx allure open allure-report
148-
El reporte muestra:
149-
Lista de pruebas con estado (passed, failed, skipped).
150-
Pasos detallados (test.step).
151-
Capturas y trazas (si habilitadas).
152-
Ejemplo de prueba
153-
typescript
154-
// tests/registration.spec.ts
155-
import { test } from '@playwright/test';
156-
import { FormPage } from '../Pages/FormPage';
157-
158-
test.describe('Automation testing on a form', () => {
159-
let formPage: FormPage;
160-
161-
test.beforeEach(async ({ page }) => {
162-
formPage = new FormPage(page);
163-
await test.step('Given that I navigate to the web page', async () => {
164-
await formPage.navigate();
165-
});
166-
});
167-
168-
test('Empty mandatory fields prevent form submission', async () => {
169-
await test.step('Given that I do not fill any mandatory fields', async () => {});
170-
await test.step('When I try to submit the form', async () => {
171-
await formPage.submitForm();
172-
});
173-
await test.step('Then I see errors in the mandatory fields', async () => {
174-
await formPage.expectErrorForField('El nombre debe tener al menos 2 caracteres.');
175-
});
176-
});
177-
});
178-
Notas
179-
POM: Las clases en Pages/ encapsulan localizadores y métodos, haciendo las pruebas más legibles.
180-
Allure: Requiere Java para npx allure generate. Verifica con java -version.
181-
TypeScript: Usa tsconfig.json para configurar el compilador:
182-
json
183-
{
184-
"compilerOptions": {
185-
"target": "es6",
186-
"module": "commonjs",
187-
"strict": true,
188-
"rootDir": "./",
189-
"outDir": "./dist",
190-
"esModuleInterop": true
191-
},
192-
"include": ["./tests/**/*.ts", "./Pages/**/*.ts"]
193-
}
194-
Solución de problemas
195-
Reporte Allure "unknown":
196-
Limpia: rm -rf allure-results allure-report.
197-
Re-ejecuta: npm run test-and-report.
198-
Pruebas no corren: Verifica localizadores en FormPage.ts con el HTML real.
199-
Errores de caché: Usa npm run clean y reinstala.
200-
Este README cubre lo esencial para empezar, ejecutar, y mantener el proyecto. ¿Te gustaría que añada algo más, como ejemplos específicos del formulario o detalles de CI/CD? ¡Avísame!
175+
```

0 commit comments

Comments
 (0)