agents-cli-automation 1.0.4 → 1.0.6

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/README.md ADDED
@@ -0,0 +1,113 @@
1
+ # Agents CLI
2
+
3
+ A simple CLI tool to bootstrap production-ready Playwright automation frameworks for UI and API testing.
4
+
5
+ ## Installation
6
+
7
+ ### Option 1: Using npx (No installation required)
8
+ ```bash
9
+ npx agents-cli-automation init
10
+ ```
11
+
12
+ ### Option 2: Install globally via npm
13
+ ```bash
14
+ npm install -g agents-cli-automation
15
+ agents init
16
+ ```
17
+
18
+ ### Option 3: Install locally in a project
19
+ ```bash
20
+ npm install agents-cli-automation
21
+ npx agents init
22
+ ```
23
+
24
+ ## Quick Start
25
+
26
+ Run the setup command and select your testing type:
27
+ ```bash
28
+ npx agents-cli-automation init
29
+ ```
30
+
31
+ Choose from:
32
+ 1. **Playwright Setup for UI Testing** - Browser automation, E2E tests, component testing
33
+ 2. **Playwright Setup for API Testing** - REST API tests, integration testing, backend validation
34
+
35
+ Follow the interactive prompts and your agent will be generated!
36
+
37
+ ## Available Agents
38
+
39
+ ### 📊 Playwright Setup for UI Testing
40
+ Creates a production-ready Playwright framework for UI automation with:
41
+ - ✅ Complete UI test project structure
42
+ - ✅ UI, component, and E2E testing templates
43
+ - ✅ Fixture configurations
44
+ - ✅ WebServer setup for local development
45
+ - ✅ All npm scripts configured
46
+ - ✅ Sample tests with SauceDemo credentials
47
+ - ✅ Headed and headless test modes
48
+
49
+ ### 🔌 Playwright Setup for API Testing
50
+ Creates a production-ready Playwright framework for API automation with:
51
+ - ✅ Complete API test project structure
52
+ - ✅ REST API request handling
53
+ - ✅ Response validation templates
54
+ - ✅ Authentication fixtures
55
+ - ✅ Database integration helpers
56
+ - ✅ Sample API tests (GET, POST, etc.)
57
+ - ✅ CI/CD ready configuration
58
+
59
+ The generated agent will include everything you need to start automating tests immediately!
60
+
61
+ ## What Gets Created
62
+
63
+ When you run `agents init`, a `.github/agents` directory is created in your project with one of these files:
64
+
65
+ ### For UI Testing
66
+ - `playwright-ui-testing-agent.md` - Complete UI framework setup
67
+ - WebServer configuration
68
+ - Sample UI tests with SauceDemo
69
+ - Fixture setup
70
+ - Headed and headless modes
71
+ - Visual regression ready
72
+
73
+ ### For API Testing
74
+ - `playwright-api-testing-agent.md` - Complete API framework setup
75
+ - REST API examples (GET, POST, etc.)
76
+ - Response validation
77
+ - Authentication fixtures
78
+ - Database integration helpers
79
+ - CI/CD ready configuration
80
+
81
+ Each agent file includes:
82
+ - Full setup instructions
83
+ - Working sample tests
84
+ - Verification checklist
85
+ - Best practices
86
+ - Environment configuration
87
+ - Ready-to-use code snippets
88
+
89
+ ## Requirements
90
+
91
+ - Node.js 18+
92
+ - npm or yarn
93
+
94
+ ## Need Help?
95
+
96
+ Each generated agent file provides comprehensive guidance:
97
+
98
+ **For UI Testing:**
99
+ - WebServer setup for local testing
100
+ - SauceDemo test examples (login, add to cart)
101
+ - How to replace with your own application
102
+ - Debugging tips for browser tests
103
+
104
+ **For API Testing:**
105
+ - Writing GET, POST, PUT, DELETE tests
106
+ - Response validation patterns
107
+ - Authentication and headers setup
108
+ - Environment variables configuration
109
+ - Database integration examples
110
+
111
+ ---
112
+
113
+ **Happy automating! 🚀**
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "agents-cli-automation",
3
- "version": "1.0.4",
3
+ "version": "1.0.6",
4
4
  "description": "Agents CLI",
5
5
  "type": "module",
6
6
  "bin": {
7
- "agents": "./bin/index.js"
7
+ "agents": "bin/index.js"
8
8
  },
9
9
  "files": [
10
10
  "bin",
@@ -14,12 +14,15 @@ export default async function initCommand() {
14
14
  type: "list",
15
15
  name: "setup",
16
16
  message: "Select setup",
17
- choices: ["Add Playwright Agent"]
17
+ choices: [
18
+ "Playwright Setup for UI Testing",
19
+ "Playwright Setup for API Testing"
20
+ ]
18
21
  }
19
22
  ]);
20
23
 
21
- if (setup === "Add Playwright Agent") {
22
- // Template inside your CLI package
24
+ if (setup === "Playwright Setup for UI Testing") {
25
+ // Template for UI testing
23
26
  const templatePath = path.resolve(
24
27
  __dirname,
25
28
  "../templates/playwright-agent.md"
@@ -33,12 +36,35 @@ export default async function initCommand() {
33
36
  await fs.ensureDir(agentsDir);
34
37
 
35
38
  // Save file with .agent extension
36
- const destFile = path.join(agentsDir, "playwrightsetup-agent.md");
39
+ const destFile = path.join(agentsDir, "playwright-ui-testing-agent.md");
37
40
 
38
41
  // Copy template content
39
42
  await fs.copyFile(templatePath, destFile);
40
43
 
41
- console.log(`\n✅ Playwright agent created at ${destFile}\n`);
44
+ console.log(`\n✅ Playwright UI Testing agent created at ${destFile}\n`);
45
+ }
46
+
47
+ if (setup === "Playwright Setup for API Testing") {
48
+ // Template for API testing
49
+ const templatePath = path.resolve(
50
+ __dirname,
51
+ "../templates/playwright-agent-api.md"
52
+ );
53
+
54
+ // Target folder **inside the user's project**
55
+ const userProjectRoot = process.cwd();
56
+ const agentsDir = path.join(userProjectRoot, ".github", "agents");
57
+
58
+ // Ensure folder exists
59
+ await fs.ensureDir(agentsDir);
60
+
61
+ // Save file with .agent extension
62
+ const destFile = path.join(agentsDir, "playwright-api-testing-agent.md");
63
+
64
+ // Copy template content
65
+ await fs.copyFile(templatePath, destFile);
66
+
67
+ console.log(`\n✅ Playwright API Testing agent created at ${destFile}\n`);
42
68
  }
43
69
 
44
70
  console.log("Setup complete 🎉\n");
@@ -0,0 +1,190 @@
1
+ name: Create Playwright Framework - API Testing
2
+ description: Creates a production-ready Playwright API testing framework with all dependencies and fixtures properly configured.
3
+ argument-hint: "framework requirements, e.g., 'REST API and webhook testing'"
4
+
5
+ ---
6
+
7
+ # Playwright API Testing Framework Setup
8
+
9
+ This agent creates a production-ready Playwright framework optimized for API automation.
10
+
11
+ ## Capabilities
12
+ - Playwright API testing setup (JS / TS)
13
+ - REST API request handling
14
+ - Response validation
15
+ - Database integration
16
+ - API fixtures and helpers
17
+ - Sample API tests
18
+ - Scalable folder structure
19
+ - CI/CD ready configuration
20
+
21
+ ## Prerequisites
22
+ - Node.js 18+ installed
23
+ - npm or yarn
24
+ - API endpoint documentation
25
+
26
+ ## Setup Instructions
27
+
28
+ ### 1. Install Dependencies
29
+ ```bash
30
+ npm install
31
+ ```
32
+
33
+ ### 2. Required package.json Scripts
34
+ Ensure your `package.json` includes these scripts:
35
+ ```json
36
+ {
37
+ "scripts": {
38
+ "test": "playwright test",
39
+ "test:api": "playwright test --grep @api",
40
+ "test:debug": "playwright test --debug",
41
+ "test:report": "playwright show-report"
42
+ }
43
+ }
44
+ ```
45
+
46
+ ### 3. Playwright Configuration
47
+ Your `playwright.config.js` should include:
48
+ ```javascript
49
+ {
50
+ testDir: './tests/api',
51
+ fullyParallel: true,
52
+ workers: process.env.CI ? 1 : undefined,
53
+ use: {
54
+ baseURL: process.env.API_BASE_URL || 'https://api.example.com',
55
+ timeout: 10000
56
+ }
57
+ }
58
+ ```
59
+
60
+ ### 4. Sample API Tests (Ready to Use)
61
+
62
+ **Login API Test** (`tests/api/auth.spec.js`):
63
+ ```javascript
64
+ import { test, expect } from '@playwright/test';
65
+
66
+ test('@api Login endpoint', async ({ request }) => {
67
+ const response = await request.post('https://api.example.com/auth/login', {
68
+ data: {
69
+ username: 'testuser',
70
+ password: 'testpass'
71
+ }
72
+ });
73
+
74
+ expect(response.status()).toBe(200);
75
+ const data = await response.json();
76
+ expect(data).toHaveProperty('token');
77
+ });
78
+ ```
79
+
80
+ **GET Request Test** (`tests/api/users.spec.js`):
81
+ ```javascript
82
+ import { test, expect } from '@playwright/test';
83
+
84
+ test('@api Get all users', async ({ request }) => {
85
+ const response = await request.get('https://api.example.com/users');
86
+
87
+ expect(response.status()).toBe(200);
88
+ const data = await response.json();
89
+ expect(Array.isArray(data)).toBeTruthy();
90
+ });
91
+
92
+ test('@api Get specific user', async ({ request }) => {
93
+ const response = await request.get('https://api.example.com/users/1');
94
+
95
+ expect(response.status()).toBe(200);
96
+ const data = await response.json();
97
+ expect(data).toHaveProperty('id');
98
+ expect(data.id).toBe(1);
99
+ });
100
+ ```
101
+
102
+ **POST Request Test** (`tests/api/create.spec.js`):
103
+ ```javascript
104
+ import { test, expect } from '@playwright/test';
105
+
106
+ test('@api Create new user', async ({ request }) => {
107
+ const response = await request.post('https://api.example.com/users', {
108
+ data: {
109
+ name: 'John Doe',
110
+ email: 'john@example.com'
111
+ }
112
+ });
113
+
114
+ expect(response.status()).toBe(201);
115
+ const data = await response.json();
116
+ expect(data.name).toBe('John Doe');
117
+ expect(data).toHaveProperty('id');
118
+ });
119
+ ```
120
+
121
+ **API Fixture Example** (`fixtures/api.js`):
122
+ ```javascript
123
+ import { test as base } from '@playwright/test';
124
+
125
+ export const test = base.extend({
126
+ apiContext: async ({ playwright }, use) => {
127
+ const context = await playwright.request.newContext({
128
+ baseURL: process.env.API_BASE_URL || 'https://api.example.com',
129
+ extraHTTPHeaders: {
130
+ 'Authorization': `Bearer ${process.env.API_TOKEN}`
131
+ }
132
+ });
133
+
134
+ await use(context);
135
+ await context.dispose();
136
+ }
137
+ });
138
+ ```
139
+
140
+ ### 5. Run Tests
141
+ ```bash
142
+ # Run all API tests
143
+ npm test
144
+
145
+ # Run only tests tagged with @api
146
+ npm run test:api
147
+
148
+ # Debug mode
149
+ npm run test:debug
150
+
151
+ # View HTML report
152
+ npm run test:report
153
+ ```
154
+
155
+ ## Best Practices
156
+ - Use fixtures for authentication tokens and common setup
157
+ - Tag tests with `@api` for easy filtering
158
+ - Use environment variables for sensitive data (API tokens, URLs)
159
+ - Implement proper error handling and response validation
160
+ - Create helper functions for common API calls
161
+ - Mock external dependencies when possible
162
+
163
+ ## Environment Variables
164
+ Create a `.env` file:
165
+ ```
166
+ API_BASE_URL=https://api.example.com
167
+ API_TOKEN=your_token_here
168
+ DB_HOST=localhost
169
+ DB_USER=admin
170
+ DB_PASS=password
171
+ ```
172
+
173
+ ## Verification Checklist
174
+ ✅ All dependencies installed (`npm install`)
175
+ ✅ API endpoint(s) accessible
176
+ ✅ Environment variables configured
177
+ ✅ Playwright config points to correct API base URL
178
+ ✅ Sample tests execute successfully
179
+ ✅ Response validation working
180
+
181
+ ## Use Cases
182
+ - Rest API testing
183
+ - Backend service validation
184
+ - Integration testing
185
+ - Microservice testing
186
+ - Contract testing
187
+
188
+ ---
189
+
190
+ **Ready to test your APIs! 🚀**
@@ -1,16 +1,113 @@
1
- name: creat playwright frmework
2
- description: Describe what this custom agent does and when to use it.
3
- argument-hint: The inputs this agent expects, e.g., "framework requirements"
1
+ name: Create Playwright Framework - UI Testing
2
+ description: Creates a production-ready Playwright UI automation framework with all dependencies, fixtures, and test configurations properly set up.
3
+ argument-hint: "framework requirements, e.g., 'JavaScript with UI tests'"
4
4
 
5
5
  ---
6
6
 
7
- This agent creates a production-ready Playwright automation framework.
7
+ # Playwright UI Testing Framework Setup
8
8
 
9
- Capabilities:
9
+ This agent creates a production-ready Playwright framework optimized for UI automation.
10
+
11
+ ## Capabilities
10
12
  - Playwright setup (JS / TS)
11
- - API, DB, UI structure
12
- - Fixtures
13
- - Sample tests
13
+ - UI, component, and end-to-end testing
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
+ - Visual regression testing ready
20
+
21
+ ## Prerequisites
22
+ - Node.js 18+ installed
23
+ - npm or yarn
24
+
25
+ ## Setup Instructions
26
+
27
+ ### 1. Install Dependencies
28
+ ```bash
29
+ npm install
30
+ ```
31
+
32
+ ### 2. Required package.json Scripts
33
+ Ensure your `package.json` includes these scripts:
34
+ ```json
35
+ {
36
+ "scripts": {
37
+ "start": "node server.js",
38
+ "test": "playwright test",
39
+ "test:headed": "playwright test --headed",
40
+ "test:debug": "playwright test --debug",
41
+ "test:ui": "playwright test --ui"
42
+ }
43
+ }
44
+ ```
45
+
46
+ ### 3. Playwright Configuration
47
+ Your `playwright.config.js` must include:
48
+ ```javascript
49
+ {
50
+ webServer: {
51
+ command: 'npm start',
52
+ url: 'http://localhost:3000',
53
+ reuseExistingServer: !process.env.CI,
54
+ }
55
+ }
56
+ ```
57
+
58
+ ### 4. Sample UI Test (Ready to Use)
59
+ For testing UI automation, use this demo application:
60
+
61
+ **Application:** https://www.saucedemo.com/
62
+ **Credentials:**
63
+ - Username: `standard_user`
64
+ - Password: `secret_sauce`
65
+
66
+ Example test file (`tests/saucedemo.spec.js`):
67
+ ```javascript
68
+ import { test, expect } from '@playwright/test';
69
+
70
+ test('Login to SauceDemo', async ({ page }) => {
71
+ await page.goto('https://www.saucedemo.com/');
72
+ await page.fill('[data-test="username"]', 'standard_user');
73
+ await page.fill('[data-test="password"]', 'secret_sauce');
74
+ await page.click('[data-test="login-button"]');
75
+ await expect(page).toHaveURL('**/inventory.html');
76
+ });
77
+
78
+ test('Add product to cart', async ({ page }) => {
79
+ await page.goto('https://www.saucedemo.com/');
80
+ await page.fill('[data-test="username"]', 'standard_user');
81
+ await page.fill('[data-test="password"]', 'secret_sauce');
82
+ await page.click('[data-test="login-button"]');
83
+ await page.click('[data-test="add-to-cart-sauce-labs-backpack"]');
84
+ await expect(page.locator('[data-test="shopping-cart-badge"]')).toContainText('1');
85
+ });
86
+ ```
87
+
88
+ ### 5. Run Tests
89
+ ```bash
90
+ # Run all tests
91
+ npm test
92
+
93
+ # Run tests with UI
94
+ npm run test:headed
95
+
96
+ # Debug mode
97
+ npm run test:debug
98
+ ```
99
+
100
+ ## Verification Checklist
101
+ ✅ All dependencies installed (`npm install`)
102
+ ✅ "start" script defined in package.json
103
+ ✅ Local server running on configured port
104
+ ✅ Playwright config has webServer setup
105
+ ✅ Tests execute without webServer errors
106
+
107
+ ## Use Cases
108
+ - New automation projects
109
+ - E2E testing frameworks
110
+ - Integration testing setup
111
+ - CI/CD pipeline automation
15
112
 
16
- Use this agent when starting a new automation project.
113
+ **Note:** If you see "Missing script: start" error, add the `start` script to your package.json before running tests.