agents-cli-automation 1.0.16 → 1.0.17

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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agents-cli-automation",
3
- "version": "1.0.16",
3
+ "version": "1.0.17",
4
4
  "description": "Agents CLI",
5
5
  "type": "module",
6
6
  "bin": {
@@ -4,163 +4,157 @@ description: Snapshot and quick guide for the Playwright + TypeScript+BDD setup
4
4
  argument-hint: "(no args)"
5
5
 
6
6
  ----
7
- # Playwright + TypeScript — repo snapshot
8
- **Current Setup**
9
- - **@playwright/test**: pinned to a verified stable version
10
- - **playwright-bdd**: used in this repo; the `test` script runs `bddgen` to convert Gherkin features into Playwright specs
11
- - **TypeScript**: pinned to a verified stable version
7
+ # Playwright + TypeScript (BDD) — repo snapshot
12
8
 
13
- This scaffold uses a generator-based BDD flow: Gherkin feature files in `tests/features/` are converted to Playwright specs by `bddgen` (from `playwright-bdd`), and those specs are executed with `@playwright/test`.
9
+ ## Current Setup
14
10
 
15
- Key points
16
- - Generator flow: the `test` script runs `npx bddgen` followed by `npx playwright test` to generate specs and run them.
17
- - Features: put Gherkin files in `tests/features/*.feature`.
18
- - Steps: add step definitions in `tests/steps/*.ts`. Include fixtures (for example `tests/fixtures/**/*.ts`) in the generator `steps` pattern so `bddgen` can connect them to the test instance.
19
- - Fixtures: `tests/fixtures/base.fixture.ts` provides typed page-object fixtures used by generated specs and step handlers.
11
+ - **@playwright/test**: v1.36.0 (or later)
12
+ - **playwright-bdd**: v8.4.2 (latest) generator that converts Gherkin `.feature` files into Playwright specs
13
+ - **TypeScript**: v5.1.0 (or later)
14
+
15
+ This repository uses a **generator-based BDD flow**: Gherkin feature files in `tests/features/` are converted to Playwright specs by `bddgen`, and those specs are executed with `@playwright/test`.
16
+
17
+ ## Key Points
18
+
19
+ - **Generator flow**: the `test` script runs `npx bddgen` (generates specs from features) followed by `npx playwright test` (runs generated specs).
20
+ - **Features**: place Gherkin files in `tests/features/*.feature`.
21
+ - **Steps**: implement step definitions in `tests/steps/*.ts`.
22
+ - **Fixtures**: `tests/fixtures/base.fixture.ts` extends the `playwright-bdd` `test` with custom fixtures like `loginPage`, and is included in the `steps` pattern so `bddgen` can wire fixtures to step handlers.
23
+ - **Config**: `playwright.config.ts` defines BDD config with `defineBddConfig()`, specifying `features`, `steps` (including fixtures first), and `outputDir`.
24
+
25
+ ## Quick Files to Review
20
26
 
21
- Quick files to review
22
27
  - Playwright config: [playwright.config.ts](playwright.config.ts)
23
28
  - TypeScript config: [tsconfig.json](tsconfig.json)
24
29
  - Page object example: [tests/pages/login.page.ts](tests/pages/login.page.ts)
25
- - JSON data utility: [tests/utils/data.ts](tests/utils/data.ts)
26
30
  - Fixtures: [tests/fixtures/base.fixture.ts](tests/fixtures/base.fixture.ts)
27
31
  - Steps: [tests/steps/loginSteps.ts](tests/steps/loginSteps.ts)
28
32
  - Features: [tests/features/login.feature](tests/features/login.feature)
29
33
 
30
- Quick runnable example (Sauce Demo)
31
- ----------------------------------
34
+ ## Setup & Run Tests
32
35
 
33
- Use https://www.saucedemo.com/ with these demo credentials to get a working test quickly:
34
-
35
- - username: `standard_user`
36
- - password: `secret_sauce`
37
-
38
- Here's a minimal Playwright test that performs a login and asserts the inventory page loads:
39
-
40
- ```ts
41
- import { test, expect } from '@playwright/test';
42
-
43
- test('saucedemo login works', async ({ page }) => {
44
- await page.goto('https://www.saucedemo.com/');
45
- await page.fill('[data-test="username"]', 'standard_user');
46
- await page.fill('[data-test="password"]', 'secret_sauce');
47
- await page.click('[data-test="login-button"]');
48
- await expect(page).toHaveURL(/inventory.html/);
49
- await expect(page.locator('.inventory_list')).toBeVisible();
50
- });
51
- ```
52
-
53
- To run this example locally:
36
+ Install dependencies:
54
37
 
55
38
  ```bash
56
- npx playwright test tests/example.spec.ts # or run `npm test`
39
+ npm install
40
+ npx playwright install
57
41
  ```
58
42
 
59
- If you want, I can update the existing `tests/example.spec.ts` and `tests/pages/login.page.ts` to use this Sauce Demo flow and run the tests here.
60
-
61
-
62
43
  Run the tests (generator BDD flow):
63
44
 
64
45
  ```bash
65
- npm install
66
- npm install -D playwright-bdd
67
- # Playwright + TypeScript — repo snapshot
46
+ npm test
47
+ ```
68
48
 
69
- ## Current setup
49
+ This runs `npx bddgen` to generate Playwright specs from `.feature` files, then `npx playwright test` to execute them.
70
50
 
71
- - **@playwright/test** pinned to a verified stable version.
72
- - **playwright-bdd** — optional generator used in this repo; the `test` script runs `bddgen` to convert Gherkin features into Playwright specs.
73
- - **TypeScript** — pinned to a verified stable version.
51
+ ## Example: Sauce Demo Login
74
52
 
75
- This repository uses a generator-based BDD flow: Gherkin feature files in `tests/features/` are converted to Playwright specs by `bddgen` (from `playwright-bdd`), and those specs are executed with `@playwright/test`.
53
+ A working example is included that tests login at https://www.saucedemo.com/ using demo credentials:
54
+ - username: `standard_user`
55
+ - password: `secret_sauce`
76
56
 
77
- ## Key points
57
+ **Feature file** (`tests/features/login.feature`):
58
+ ```gherkin
59
+ Feature: Login
60
+ Scenario: Successful login to SauceDemo
61
+ Given I open the login page
62
+ When I login with "standard_user" and "secret_sauce"
63
+ Then I should see the inventory page
64
+ ```
78
65
 
79
- - **Generator flow**: the `test` script runs `npx bddgen` followed by `npx playwright test` to generate specs and run them.
80
- - **Features**: place Gherkin files in `tests/features/*.feature`.
81
- - **Steps**: implement step definitions in `tests/steps/*.ts`. Include fixtures (for example `tests/fixtures/**/*.ts`) in the generator `steps` pattern so `bddgen` can wire them to the test instance.
82
- - **Fixtures**: `tests/fixtures/base.fixture.ts` provides typed page-object fixtures used by generated specs and step handlers.
66
+ **Step definitions** (`tests/steps/loginSteps.ts`):
67
+ ```ts
68
+ import { createBdd } from 'playwright-bdd';
69
+ import { expect } from '@playwright/test';
70
+ import { test } from '../fixtures/base.fixture';
83
71
 
84
- ## Quick files to review
72
+ const { Given, When, Then } = createBdd(test);
85
73
 
86
- - Playwright config: [playwright.config.ts](playwright.config.ts)
87
- - TypeScript config: [tsconfig.json](tsconfig.json)
88
- - Page object example: [tests/pages/login.page.ts](tests/pages/login.page.ts)
89
- - JSON data utility: [tests/utils/data.ts](tests/utils/data.ts)
90
- - Fixtures: [tests/fixtures/base.fixture.ts](tests/fixtures/base.fixture.ts)
91
- - Steps: [tests/steps/loginSteps.ts](tests/steps/loginSteps.ts)
92
- - Features: [tests/features/login.feature](tests/features/login.feature)
74
+ Given('I open the login page', async ({ page }) => {
75
+ await page.goto('/');
76
+ });
93
77
 
94
- ## Run the tests (generator BDD flow)
78
+ When('I login with {string} and {string}', async ({ loginPage }, username: string, password: string) => {
79
+ await loginPage.login(username, password);
80
+ });
95
81
 
96
- ```bash
97
- npm install
98
- npm install -D playwright-bdd
99
- npx playwright install
100
- npm test
82
+ Then('I should see the inventory page', async ({ page }) => {
83
+ await expect(page).toHaveURL(/inventory.html/);
84
+ });
101
85
  ```
102
86
 
103
- Handling missing bddgen
104
- -----------------------
87
+ **Fixtures** (`tests/fixtures/base.fixture.ts`):
88
+ ```ts
89
+ import { test as base } from 'playwright-bdd';
90
+ import { LoginPage } from '../pages/login.page';
105
91
 
106
- If you see the message "To get \"bddgen\" CLI please install \"playwright-bdd\" package", you have two options:
92
+ type Fixtures = {
93
+ loginPage: LoginPage;
94
+ };
107
95
 
108
- - Install the generator (recommended if you use Gherkin features):
96
+ export const test = base.extend<Fixtures>({
97
+ loginPage: async ({ page }, use) => {
98
+ await use(new LoginPage(page));
99
+ },
100
+ });
109
101
 
110
- ```bash
111
- npm install -D playwright-bdd
112
- npx playwright install
113
- npm test
102
+ export { expect } from '@playwright/test';
114
103
  ```
115
104
 
116
- - Skip the generator and run Playwright directly (if you don't use Gherkin features):
117
-
118
- 1. Remove `npx bddgen &&` from your `test` script in `package.json`, or run Playwright directly:
105
+ ## Playwright Config
119
106
 
120
- ```bash
121
- npx playwright test
122
- ```
123
-
124
- 2. Example `package.json` scripts without `bddgen`:
107
+ **Key sections** (`playwright.config.ts`):
108
+ ```ts
109
+ import { defineConfig } from '@playwright/test';
110
+ import { defineBddConfig } from 'playwright-bdd';
111
+
112
+ export default defineConfig({
113
+ testDir: 'tests',
114
+ timeout: 30_000,
115
+ use: {
116
+ headless: true,
117
+ viewport: { width: 1280, height: 720 },
118
+ baseURL: 'https://www.saucedemo.com'
119
+ }
120
+ });
125
121
 
126
- ```json
127
- "scripts": {
128
- "test": "npx playwright test",
129
- "playwright:install": "npx playwright install"
130
- }
122
+ export const bdd = defineBddConfig({
123
+ features: 'tests/features/**/*.feature',
124
+ steps: ['tests/fixtures/**/*.ts', 'tests/steps/**/*.ts'],
125
+ outputDir: 'tests',
126
+ });
131
127
  ```
132
128
 
129
+ **Important**: Include `tests/fixtures/**/*.ts` **before** `tests/steps/**/*.ts` in the `steps` pattern so fixtures are loaded first and available to step definitions.
133
130
 
134
- ## Notes
131
+ ## Common Patterns
135
132
 
136
- - The `test` script runs `npx bddgen` and then `npx playwright test`. If `playwright-bdd` is not installed, you'll be prompted to run `npm install -D playwright-bdd`.
137
- - Generated specs are written to the configured output directory (commonly `.features-gen`) and then executed by Playwright.
133
+ ### Using Fixtures in Steps
138
134
 
139
- ## How to enable generator-based BDD later
135
+ To use a custom fixture in step definitions, import the fixture-extended `test` from your fixture file and pass it to `createBdd()`:
140
136
 
141
- - Install `playwright-bdd` as a dev dependency and add `npx bddgen` to the `test` script.
142
- - Add step definitions under `tests/steps/` and include fixtures in the generator `steps` pattern.
143
-
144
- ## Ways I can help
145
-
146
- - Add `playwright-bdd` to `devDependencies` and update `package.json` so `npm install` installs it automatically.
147
- - Add a GitHub Actions workflow that runs `npm test` on push.
148
- - Expand page objects, feature coverage, or step definitions.
137
+ ```ts
138
+ import { createBdd } from 'playwright-bdd';
139
+ import { test } from '../fixtures/base.fixture';
149
140
 
150
- ---
141
+ const { Given, When, Then } = createBdd(test);
151
142
 
152
- _Generated: Playwright + TypeScript snapshot and quick guide._
143
+ When('I do something', async ({ myCustomFixture }) => {
144
+ // myCustomFixture is now available
145
+ });
146
+ ```
153
147
 
154
- ## Data utilities (read JSON / YAML)
148
+ ### Data Utilities
155
149
 
156
- You can add a small utility to load test data from JSON or YAML. Install the YAML parser and optional types:
150
+ Load test data from JSON or YAML files:
157
151
 
158
152
  ```bash
159
153
  npm install js-yaml
160
154
  npm install -D @types/js-yaml
161
155
  ```
162
156
 
163
- Example TypeScript utility (`tests/utils/readData.ts`):
157
+ Example utility (`tests/utils/readData.ts`):
164
158
 
165
159
  ```ts
166
160
  import fs from 'fs';
@@ -168,58 +162,56 @@ import path from 'path';
168
162
  import yaml from 'js-yaml';
169
163
 
170
164
  export function readData(filePath: string): any {
171
- const ext = path.extname(filePath).toLowerCase();
172
- const raw = fs.readFileSync(filePath, 'utf8');
173
- if (ext === '.json') return JSON.parse(raw);
174
- if (ext === '.yml' || ext === '.yaml') return yaml.load(raw);
175
- throw new Error(`Unsupported data format: ${ext}`);
165
+ const ext = path.extname(filePath).toLowerCase();
166
+ const raw = fs.readFileSync(filePath, 'utf8');
167
+ if (ext === '.json') return JSON.parse(raw);
168
+ if (ext === '.yml' || ext === '.yaml') return yaml.load(raw);
169
+ throw new Error(`Unsupported data format: ${ext}`);
176
170
  }
177
171
  ```
178
172
 
179
- Usage example in a test or step definition:
173
+ Usage in steps:
180
174
 
181
175
  ```ts
182
176
  import { readData } from '../utils/readData';
183
177
 
184
- const login = readData('tests/data/login.yaml');
185
- // use `login.username`, `login.password` in your steps
178
+ const loginData = readData('tests/data/users.yaml');
179
+ When('I login as {string}', async ({ page }, username: string) => {
180
+ const user = loginData[username];
181
+ // use user.password, etc.
182
+ });
186
183
  ```
187
184
 
188
- Tips
189
-
190
- - If you prefer importing JSON directly, enable `resolveJsonModule` in `tsconfig.json`.
191
- - For large or frequently-modified data files, consider caching the parsed result in the utility.
192
-
193
- ## Dependency updates & provisioning
185
+ ## Dependency Updates
194
186
 
195
- To update dev dependencies in `package.json` to the latest compatible versions you can use `npm-check-updates` (ncu). The command below updates `devDependencies` in `package.json`:
187
+ To update dev dependencies to compatible latest versions:
196
188
 
197
189
  ```bash
198
- # update devDependencies in package.json
199
190
  npx npm-check-updates -u '/.*/' --dep dev
200
-
201
- # install updates
202
191
  npm install
203
192
  ```
204
193
 
205
- Notes and troubleshooting
206
-
207
- - `npx npm-check-updates -u` only modifies `package.json`. If `package-lock.json` or `node_modules` pin old versions, run a fresh install:
194
+ If you encounter peer dependency conflicts or need a fresh install:
208
195
 
209
196
  ```bash
210
- # remove lockfile and node_modules then reinstall (cross-platform idea)
197
+ # Windows PowerShell:
198
+ Remove-Item -Recurse -Force node_modules
199
+ Remove-Item package-lock.json
200
+ npm install
201
+
202
+ # Or on macOS/Linux:
211
203
  rm -rf node_modules package-lock.json
212
204
  npm install
213
205
  ```
214
206
 
215
- - On Windows PowerShell use:
207
+ ## Troubleshooting
216
208
 
217
- ```powershell
218
- Remove-Item -Recurse -Force node_modules
219
- Remove-Item package-lock.json
220
- npm install
221
- ```
209
+ **"BDD config not found" error**: Ensure `playwright.config.ts` exports `bdd = defineBddConfig({...})` and the `testDir` matches your `outputDir`.
210
+
211
+ **"Unknown parameter" in generated tests**: Make sure custom fixture files are included in the `steps` pattern **before** step definition files, so fixtures are loaded and available.
222
212
 
223
- - If `npm install` reports peer dependency conflicts or fails, it's usually due to incompatible major versions; I can help resolve those selectively.
213
+ **Tests not found**: Verify `outputDir` in `defineBddConfig()` points to a directory inside (or at) Playwright's `testDir`, typically `'tests'`.
214
+
215
+ ---
224
216
 
225
- Would you like me to run the `npx npm-check-updates -u '/.*/' --dep dev` and `npm install` commands now, or create a commit/update `package.json` myself? If you prefer, I can also open a PR with the changes.
217
+ _Updated: Playwright + TypeScript + BDD setup snapshot_