agents-cli-automation 1.0.5 → 1.0.7

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,196 @@
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 follow the interactive prompts:
27
+ ```bash
28
+ npx agents-cli-automation init
29
+ ```
30
+
31
+ ### Step 1: Select Framework Type
32
+ Choose your testing type:
33
+ 1. **Playwright UI Testing** - Browser automation, E2E tests, component testing
34
+ 2. **Playwright API Testing** - REST API tests, integration testing, backend validation
35
+
36
+ ### Step 2: Select Your Language (for UI Testing)
37
+ Choose your preferred language:
38
+ - **TypeScript** (Recommended) - Latest & Type Safe
39
+ - **JavaScript** - ES Modules, modern syntax
40
+ - **Java** - Maven + JUnit5
41
+ - **C#** - NUnit + .NET
42
+
43
+ Your scalable, production-ready framework will be generated automatically!
44
+
45
+ ## Available Agents
46
+
47
+ ### 📊 Playwright UI Testing Framework
48
+ Creates a production-ready Playwright framework for UI automation with support for **TypeScript, JavaScript, Java, and C#**.
49
+
50
+ **Core Features:**
51
+ - ✅ **Page Object Model (POM)** - Reusable page classes with best practices
52
+ - ✅ **Fixtures & Setup** - Built-in browser lifecycle management
53
+ - ✅ **Parallel Execution** - Run tests simultaneously (4 workers by default)
54
+ - ✅ **Chromium Only** - Single browser for consistency and speed
55
+ - ✅ **Test Data Readers** - Support for JSON, CSV, and YAML files
56
+ - ✅ **Form Helpers** - Handle dropdowns, radio buttons, checkboxes, text inputs
57
+ - ✅ **BDD Support** - Cucumber/Gherkin feature files for scenario-based testing
58
+ - ✅ **Latest APIs** - Uses latest Playwright versions with full type safety
59
+
60
+ **Language Options:**
61
+ - **TypeScript** - Full tsconfig with strict mode and path aliases (@pages/@utils/@fixtures/@data)
62
+ - **JavaScript** - ES Modules with modern syntax (no build step required)
63
+ - **Java** - Maven-based structure with JUnit 5 and all dependencies
64
+ - **C#** - .NET 8 with NUnit and async/await patterns
65
+
66
+ ### 🔌 Playwright API Testing
67
+ Creates a production-ready Playwright framework for API automation with:
68
+ - ✅ Complete API test project structure
69
+ - ✅ REST API request handling
70
+ - ✅ Response validation templates
71
+ - ✅ Authentication fixtures
72
+ - ✅ Database integration helpers
73
+ - ✅ Sample API tests (GET, POST, etc.)
74
+ - ✅ CI/CD ready configuration
75
+
76
+ The generated agent will include everything you need to start automating tests immediately!
77
+
78
+ ## What Gets Created
79
+
80
+ When you run `agents init`, a `.github/agents` directory is created in your project with language-specific framework files.
81
+
82
+ ### For UI Testing (Choose Your Language)
83
+
84
+ **TypeScript**
85
+ - `playwright-ui-testing-typescript-agent.md`
86
+ - Complete TypeScript framework with strict type checking
87
+ - tsconfig.json with path aliases
88
+ - Full type definitions for all utilities
89
+ - ES2020 module syntax
90
+
91
+ **JavaScript**
92
+ - `playwright-ui-testing-javascript-es-modules-agent.md`
93
+ - Modern ES Modules syntax (Node.js 18+)
94
+ - No build step required
95
+ - Same features as TypeScript without type annotations
96
+
97
+ **Java**
98
+ - `playwright-ui-testing-java-agent.md`
99
+ - Maven-based project structure
100
+ - JUnit 5 test framework
101
+ - Complete pom.xml with all dependencies
102
+ - Maven parallel execution support
103
+
104
+ **C#**
105
+ - `playwright-ui-testing-c#-agent.md`
106
+ - .NET 8+ project structure
107
+ - NUnit test framework
108
+ - Complete .csproj configuration
109
+ - Async/await patterns throughout
110
+
111
+ ### For API Testing
112
+ - `playwright-api-testing-agent.md` - Complete API framework setup
113
+
114
+ ## Framework Structure (All Languages)
115
+
116
+ Each generated framework includes:
117
+
118
+ **📂 Project Structure**
119
+ ```
120
+ framework/
121
+ ├── pages/ # Page Object Model classes
122
+ ├── utils/ # DataReader, FormHelper, TestDataManager
123
+ ├── fixtures/ # Browser setup and fixtures
124
+ ├── tests/ # Test files
125
+ ├── features/ # Gherkin/BDD scenarios
126
+ ├── data/ # Test data (JSON, CSV, YAML)
127
+ ├── config files # Language-specific (tsconfig.json, pom.xml, etc.)
128
+ └── Sample tests # Working examples ready to run
129
+ ```
130
+
131
+ **✨ Included in Every Framework:**
132
+ - Page Object Model classes with selectors
133
+ - Form helpers for complex form interactions
134
+ - Test data readers for JSON, CSV, YAML
135
+ - BDD/Gherkin feature files
136
+ - Browser fixtures with proper cleanup
137
+ - Parallel execution configuration
138
+ - Sample tests with SauceDemo app
139
+ - Complete setup and run instructions
140
+
141
+ ## Requirements
142
+
143
+ ### To Run CLI
144
+ - Node.js 18+
145
+ - npm or yarn
146
+
147
+ ### To Run Generated Frameworks
148
+
149
+ **TypeScript & JavaScript:**
150
+ - Node.js 18+
151
+ - npm or yarn
152
+
153
+ **Java:**
154
+ - Java 11+
155
+ - Maven 3.8+
156
+
157
+ **C#:**
158
+ - .NET 8 SDK
159
+ - Visual Studio 2022 or VS Code with C# extension
160
+
161
+ ## Why Choose This Framework?
162
+
163
+ ✅ **Multi-Language Support** - Use TypeScript, JavaScript, Java, or C#
164
+ ✅ **Minimal Setup** - Fully scaffolded projects, developers focus on tests, not setup
165
+ ✅ **Page Object Model** - Reusable, maintainable test code patterns
166
+ ✅ **Scalable Architecture** - Ready for enterprise-grade test suites
167
+ ✅ **Parallel Execution** - Run tests faster across multiple workers
168
+ ✅ **BDD Ready** - Cucumber/Gherkin support for business-readable scenarios
169
+ ✅ **Test Data Management** - JSON, CSV, YAML support out of the box
170
+ ✅ **Form Helpers** - Handle complex forms, dropdowns, checkboxes easily
171
+ ✅ **Latest Playwright** - Always using cutting-edge Playwright features
172
+ ✅ **Production Ready** - Fixtures, proper cleanup, error handling included
173
+
174
+ ## Framework Quick Features
175
+
176
+ Each generated framework provides:
177
+
178
+ **For UI Testing:**
179
+ - SauceDemo test examples (login, shopping cart)
180
+ - Complete page objects with all selectors
181
+ - Form interaction helpers for any element type
182
+ - Test data loading from multiple formats
183
+ - BDD scenario examples with step definitions
184
+ - Parallel execution (4 workers by default)
185
+ - Chromium-only for reliability
186
+
187
+ **For API Testing:**
188
+ - Writing GET, POST, PUT, DELETE tests
189
+ - Response validation patterns
190
+ - Authentication and headers setup
191
+ - Environment variables configuration
192
+ - Database integration examples
193
+
194
+ ---
195
+
196
+ **Happy automating! 🚀**
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "agents-cli-automation",
3
- "version": "1.0.5",
3
+ "version": "1.0.7",
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",
@@ -7,22 +7,87 @@ const __filename = fileURLToPath(import.meta.url);
7
7
  const __dirname = path.dirname(__filename);
8
8
 
9
9
  export default async function initCommand() {
10
- console.log("\n🚀 Agents CLI setup\n");
10
+ console.log("\n🚀 Agents CLI - Scalable Test Framework Setup\n");
11
11
 
12
12
  const { setup } = await inquirer.prompt([
13
13
  {
14
14
  type: "list",
15
15
  name: "setup",
16
- message: "Select setup",
17
- choices: ["Add Playwright Agent"]
16
+ message: "Select framework setup",
17
+ choices: [
18
+ "Playwright UI Testing (Recommended)",
19
+ "Playwright 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 UI Testing (Recommended)") {
25
+ // Ask for language preference
26
+ const { language } = await inquirer.prompt([
27
+ {
28
+ type: "list",
29
+ name: "language",
30
+ message: "Select your preferred language",
31
+ choices: [
32
+ "TypeScript (Recommended - Latest & Type Safe)",
33
+ "JavaScript (ES Modules)",
34
+ "Java (Maven + JUnit)",
35
+ "C# (NUnit + .NET)"
36
+ ]
37
+ }
38
+ ]);
39
+
40
+ let templateFile;
41
+ let templateName;
42
+
43
+ if (language.includes("TypeScript")) {
44
+ templateFile = "playwright-agent-ts.md";
45
+ templateName = "TypeScript";
46
+ } else if (language.includes("JavaScript")) {
47
+ templateFile = "playwright-agent-js.md";
48
+ templateName = "JavaScript ES Modules";
49
+ } else if (language.includes("Java")) {
50
+ templateFile = "playwright-agent-java.md";
51
+ templateName = "Java";
52
+ } else if (language.includes("C#")) {
53
+ templateFile = "playwright-agent-csharp.md";
54
+ templateName = "C#";
55
+ }
56
+
57
+ const templatePath = path.resolve(__dirname, `../templates/${templateFile}`);
58
+
59
+ // Check if template exists
60
+ if (!fs.existsSync(templatePath)) {
61
+ console.error(
62
+ `\n❌ Template not found: ${templateFile}\n`
63
+ );
64
+ return;
65
+ }
66
+
67
+ // Target folder in user's project
68
+ const userProjectRoot = process.cwd();
69
+ const agentsDir = path.join(userProjectRoot, ".github", "agents");
70
+
71
+ // Ensure folder exists
72
+ await fs.ensureDir(agentsDir);
73
+
74
+ // Save file with .agent extension
75
+ const fileName = `playwright-ui-testing-${templateName.toLowerCase().replace(/\s/g, "-")}-agent.md`;
76
+ const destFile = path.join(agentsDir, fileName);
77
+
78
+ // Copy template content
79
+ await fs.copyFile(templatePath, destFile);
80
+
81
+ console.log(`\n✅ Playwright UI Testing Framework created!`);
82
+ console.log(`📝 Language: ${templateName}`);
83
+ console.log(`📍 Location: ${destFile}\n`);
84
+ }
85
+
86
+ if (setup === "Playwright API Testing") {
87
+ // Template for API testing
23
88
  const templatePath = path.resolve(
24
89
  __dirname,
25
- "../templates/playwright-agent.md"
90
+ "../templates/playwright-agent-api.md"
26
91
  );
27
92
 
28
93
  // Target folder **inside the user's project**
@@ -33,13 +98,13 @@ export default async function initCommand() {
33
98
  await fs.ensureDir(agentsDir);
34
99
 
35
100
  // Save file with .agent extension
36
- const destFile = path.join(agentsDir, "playwrightsetup-agent.md");
101
+ const destFile = path.join(agentsDir, "playwright-api-testing-agent.md");
37
102
 
38
103
  // Copy template content
39
104
  await fs.copyFile(templatePath, destFile);
40
105
 
41
- console.log(`\n✅ Playwright agent created at ${destFile}\n`);
106
+ console.log(`\n✅ Playwright API Testing agent created at ${destFile}\n`);
42
107
  }
43
108
 
44
- console.log("Setup complete 🎉\n");
109
+ console.log("🎉 Setup complete!\n");
45
110
  }
@@ -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! 🚀**