agents-cli-automation 1.0.3 → 1.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
package/src/commands/init.js
CHANGED
|
@@ -33,7 +33,7 @@ export default async function initCommand() {
|
|
|
33
33
|
await fs.ensureDir(agentsDir);
|
|
34
34
|
|
|
35
35
|
// Save file with .agent extension
|
|
36
|
-
const destFile = path.join(agentsDir, "playwrightsetup.
|
|
36
|
+
const destFile = path.join(agentsDir, "playwrightsetup-agent.md");
|
|
37
37
|
|
|
38
38
|
// Copy template content
|
|
39
39
|
await fs.copyFile(templatePath, destFile);
|
|
@@ -1,16 +1,112 @@
|
|
|
1
|
-
name:
|
|
2
|
-
description:
|
|
3
|
-
argument-hint:
|
|
1
|
+
name: Create Playwright Framework
|
|
2
|
+
description: Creates a production-ready Playwright automation framework with all dependencies, fixtures, and test configurations properly set up.
|
|
3
|
+
argument-hint: "framework requirements, e.g., 'JavaScript with API and UI tests'"
|
|
4
4
|
|
|
5
5
|
---
|
|
6
6
|
|
|
7
|
+
# Playwright Automation Framework Setup
|
|
8
|
+
|
|
7
9
|
This agent creates a production-ready Playwright automation framework.
|
|
8
10
|
|
|
9
|
-
Capabilities
|
|
11
|
+
## Capabilities
|
|
10
12
|
- Playwright setup (JS / TS)
|
|
11
13
|
- API, DB, UI structure
|
|
12
|
-
- Fixtures
|
|
13
|
-
- Sample tests
|
|
14
|
+
- Fixtures with proper configuration
|
|
15
|
+
- Sample tests (headless & headed modes)
|
|
14
16
|
- Scalable folder structure
|
|
17
|
+
- WebServer configuration for running tests against local servers
|
|
18
|
+
- Complete package.json with all required scripts
|
|
19
|
+
|
|
20
|
+
## Prerequisites
|
|
21
|
+
- Node.js 18+ installed
|
|
22
|
+
- npm or yarn
|
|
23
|
+
|
|
24
|
+
## Setup Instructions
|
|
25
|
+
|
|
26
|
+
### 1. Install Dependencies
|
|
27
|
+
```bash
|
|
28
|
+
npm install
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
### 2. Required package.json Scripts
|
|
32
|
+
Ensure your `package.json` includes these scripts:
|
|
33
|
+
```json
|
|
34
|
+
{
|
|
35
|
+
"scripts": {
|
|
36
|
+
"start": "node server.js",
|
|
37
|
+
"test": "playwright test",
|
|
38
|
+
"test:headed": "playwright test --headed",
|
|
39
|
+
"test:debug": "playwright test --debug",
|
|
40
|
+
"test:ui": "playwright test --ui"
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
### 3. Playwright Configuration
|
|
46
|
+
Your `playwright.config.js` must include:
|
|
47
|
+
```javascript
|
|
48
|
+
{
|
|
49
|
+
webServer: {
|
|
50
|
+
command: 'npm start',
|
|
51
|
+
url: 'http://localhost:3000',
|
|
52
|
+
reuseExistingServer: !process.env.CI,
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
### 4. Sample UI Test (Ready to Use)
|
|
58
|
+
For testing UI automation, use this demo application:
|
|
59
|
+
|
|
60
|
+
**Application:** https://www.saucedemo.com/
|
|
61
|
+
**Credentials:**
|
|
62
|
+
- Username: `standard_user`
|
|
63
|
+
- Password: `secret_sauce`
|
|
64
|
+
|
|
65
|
+
Example test file (`tests/saucedemo.spec.js`):
|
|
66
|
+
```javascript
|
|
67
|
+
import { test, expect } from '@playwright/test';
|
|
68
|
+
|
|
69
|
+
test('Login to SauceDemo', async ({ page }) => {
|
|
70
|
+
await page.goto('https://www.saucedemo.com/');
|
|
71
|
+
await page.fill('[data-test="username"]', 'standard_user');
|
|
72
|
+
await page.fill('[data-test="password"]', 'secret_sauce');
|
|
73
|
+
await page.click('[data-test="login-button"]');
|
|
74
|
+
await expect(page).toHaveURL('**/inventory.html');
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
test('Add product to cart', async ({ page }) => {
|
|
78
|
+
await page.goto('https://www.saucedemo.com/');
|
|
79
|
+
await page.fill('[data-test="username"]', 'standard_user');
|
|
80
|
+
await page.fill('[data-test="password"]', 'secret_sauce');
|
|
81
|
+
await page.click('[data-test="login-button"]');
|
|
82
|
+
await page.click('[data-test="add-to-cart-sauce-labs-backpack"]');
|
|
83
|
+
await expect(page.locator('[data-test="shopping-cart-badge"]')).toContainText('1');
|
|
84
|
+
});
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
### 5. Run Tests
|
|
88
|
+
```bash
|
|
89
|
+
# Run all tests
|
|
90
|
+
npm test
|
|
91
|
+
|
|
92
|
+
# Run tests with UI
|
|
93
|
+
npm run test:headed
|
|
94
|
+
|
|
95
|
+
# Debug mode
|
|
96
|
+
npm run test:debug
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
## Verification Checklist
|
|
100
|
+
✅ All dependencies installed (`npm install`)
|
|
101
|
+
✅ "start" script defined in package.json
|
|
102
|
+
✅ Local server running on configured port
|
|
103
|
+
✅ Playwright config has webServer setup
|
|
104
|
+
✅ Tests execute without webServer errors
|
|
105
|
+
|
|
106
|
+
## Use Cases
|
|
107
|
+
- New automation projects
|
|
108
|
+
- E2E testing frameworks
|
|
109
|
+
- Integration testing setup
|
|
110
|
+
- CI/CD pipeline automation
|
|
15
111
|
|
|
16
|
-
|
|
112
|
+
**Note:** If you see "Missing script: start" error, add the `start` script to your package.json before running tests.
|