agents-cli-automation 1.0.12 → 1.0.14
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
|
@@ -6,6 +6,14 @@ argument-hint: "(no args)"
|
|
|
6
6
|
|
|
7
7
|
# Playwright + TypeScript (BDD-capable) — repo snapshot
|
|
8
8
|
|
|
9
|
+
**Current Setup (Feb 2026) — Latest Pinned**
|
|
10
|
+
- **@playwright/test**: pinned to verified stable version
|
|
11
|
+
- **playwright-bdd**: pinned to verified stable version
|
|
12
|
+
- **typescript**: pinned to verified stable version
|
|
13
|
+
- **@types/node**: pinned to verified stable version
|
|
14
|
+
|
|
15
|
+
Initial setup installs latest versions, then locks them to prevent unexpected updates.
|
|
16
|
+
|
|
9
17
|
This document explains the current Playwright + TypeScript scaffold and details the recommended layout for:
|
|
10
18
|
- Page Object Models using `@playwright/test`
|
|
11
19
|
- A small JSON data util
|
|
@@ -13,13 +21,15 @@ This document explains the current Playwright + TypeScript scaffold and details
|
|
|
13
21
|
- Step definitions that consume fixtures via `playwright-bdd`
|
|
14
22
|
|
|
15
23
|
**Key points (current state and recommended layout)**
|
|
16
|
-
- Playwright config
|
|
24
|
+
- Playwright config uses `defineBddConfig()` from `playwright-bdd` to export the BDD configuration: see [playwright.config.ts](playwright.config.ts). The config includes `features`, `steps`, and `outputDir` patterns with reporter configuration for HTML, JSON, and JUnit outputs.
|
|
25
|
+
- The `ui` project has `testDir: '.features-gen'` and `testMatch: '**/*.feature.spec.{ts,js}'` to discover generated specs.
|
|
17
26
|
- Place Gherkin features in `tests/features/*.feature` (example: [tests/features/login.feature](tests/features/login.feature)).
|
|
18
27
|
- Page Objects: implement page classes under `tests/pages/` (example: `tests/pages/login.page.ts`) and import `Page` from `@playwright/test`.
|
|
19
28
|
- Test data util: add a JSON reader like `tests/utils/data.ts` that loads `tests/data/*.json` so tests/steps can read credentials and fixtures.
|
|
20
|
-
- Fixtures: create `tests/fixtures/base.fixture.ts` that extends `test` from
|
|
29
|
+
- Fixtures: create `tests/fixtures/base.fixture.ts` that extends `test` from `playwright-bdd` with proper TypeScript type definitions via `CustomFixtures` interface. This ensures fixtures are properly typed (for example `loginPage`). Include the fixtures file in the `steps` pattern in `bddConfig` so the generator can discover them.
|
|
21
30
|
- Steps: implement step definitions under `tests/steps/*.ts`. Use `createBdd(test)` from `playwright-bdd` and register Given/When/Then handlers that accept fixtures (e.g., `loginPage`) and call page object methods.
|
|
22
|
-
- Generated specs: the generator writes Playwright specs into `.features-gen`
|
|
31
|
+
- Generated specs: the generator writes Playwright specs into `.features-gen` (configured via `outputDir` in `bddConfig`) when using `npx bddgen`. The generated files are `.feature.spec.js` (or `.ts`) and are discovered by the `ui` project via `testMatch: '**/*.feature.spec.{ts,js}'`.
|
|
32
|
+
- Reporters: HTML (in `playwright-report/`), JSON (for CI integration), and JUnit (for CI/CD pipelines) are configured by default.
|
|
23
33
|
|
|
24
34
|
Files to inspect or add quickly
|
|
25
35
|
- Playwright config: [playwright.config.ts](playwright.config.ts)
|
|
@@ -35,35 +45,49 @@ Files to inspect or add quickly
|
|
|
35
45
|
How the flow works here
|
|
36
46
|
- Create page classes that import `Page` from `@playwright/test`; page methods should perform simple interactions and checks (for example, `LoginPage.goto()`, `LoginPage.login()`, `LoginPage.isInventoryVisible()`).
|
|
37
47
|
- Add a small data helper `readTestData(path)` that loads JSON from `tests/data/` so credentials are not hard-coded in steps or specs.
|
|
38
|
-
- Implement `tests/fixtures/base.fixture.ts` that extends Playwright's `test` to provide page-object fixtures (e.g., `loginPage`)
|
|
48
|
+
- Implement `tests/fixtures/base.fixture.ts` that extends Playwright's `test` to provide page-object fixtures (e.g., `loginPage`) with proper TypeScript types using a `CustomFixtures` type definition. This ensures type safety and IDE support for all fixtures.
|
|
39
49
|
- Write step definitions in `tests/steps/*.ts` using `playwright-bdd`'s `createBdd(test)` helper. Example pattern:
|
|
40
50
|
- import `createBdd` and your `test` fixture: `const { Given, When, Then } = createBdd(test)`
|
|
41
51
|
- register steps that accept fixtures: `Given('I open login page', async ({ loginPage }) => { await loginPage.goto(); })`.
|
|
42
|
-
- Option A — Generator flow: use `npx bddgen` to turn `.feature` files into Playwright specs in `.features-gen` (generator reads `bddConfig` in `playwright.config.ts`).
|
|
52
|
+
- Option A — Generator flow: use `npx bddgen` to turn `.feature` files into Playwright specs in `.features-gen` (generator reads `bddConfig` in `playwright.config.ts`). The `bddConfig` must include:
|
|
53
|
+
- `features`: glob pattern pointing to `.feature` files
|
|
54
|
+
- `steps`: glob patterns for step definitions **and fixtures** (e.g., `['tests/steps/**/*.ts', 'tests/fixtures/**/*.ts']`)
|
|
55
|
+
- `outputDir`: where generated specs are written (default `.features-gen`)
|
|
43
56
|
- Option B — Direct spec flow (recommended for quick runs): write a small `tests/specs/*.ts` Playwright test that imports your fixtures and page objects (no generation). This bypasses generator compatibility issues and runs immediately with `npx playwright test`.
|
|
57
|
+
- Test reports are automatically generated in `playwright-report/` (HTML), `test-results/results.json` (JSON), and `test-results/results.xml` (JUnit) after each run.
|
|
44
58
|
|
|
45
59
|
Run the direct Playwright spec (no generator required):
|
|
46
60
|
|
|
47
61
|
```bash
|
|
48
|
-
npm install
|
|
49
62
|
npx playwright install
|
|
50
63
|
npx playwright test --project=ui tests/specs/login.spec.ts
|
|
64
|
+
npx playwright show-report # View HTML report
|
|
65
|
+
npx playwright test --project=ui tests/specs/login.spec.ts
|
|
51
66
|
```
|
|
52
67
|
|
|
53
|
-
|
|
68
|
+
Or use the npm test script (auto-runs bddgen + test together):
|
|
54
69
|
|
|
55
70
|
```bash
|
|
56
|
-
npm
|
|
57
|
-
npx bddgen
|
|
58
|
-
npx playwright test --project=ui
|
|
71
|
+
npm test
|
|
59
72
|
```
|
|
60
|
-
|
|
61
|
-
|
|
73
|
+
2"`) to lock dependencies. This prevents unexpected breaking changes on future installs while still allowing patch/minor updates.
|
|
74
|
+
- **Initial Setup Flow**:
|
|
75
|
+
1. Install with `"latest"` to get current stable versions
|
|
76
|
+
2. Verify tests pass with `npm test` or `npx playwright test`
|
|
77
|
+
3. Replace `"latest"` with the installed versions (run `npm list` to see them)
|
|
78
|
+
4. Commit pinned versions to version control
|
|
79
|
+
- **Type Safety for Fixtures**: Always create a `CustomFixtures` type interface in `tests/fixtures/base.fixture.ts` that defines all custom fixtures. Extend `test.extend<CustomFixtures>()` for proper TypeScript support.
|
|
62
80
|
- Keep fixtures stable: generated specs import your fixture module, so keep `tests/fixtures/base.fixture.ts` API stable.
|
|
63
|
-
-
|
|
81
|
+
- Always include fixtures in the `steps` pattern (e.g., `steps: [..., 'tests/fixtures/**/*.ts']`) so the generator can detect and use your custom `test` instance.
|
|
82
|
+
- Steps should not import `@playwright/test` directly for test helpers — they should use the fixtures passed by `playwright-bdd` (the `test` instance you pass to `createBdd(test)`). Page objects, however, should import `Page` and be created inside fixtures.
|
|
83
|
+
- The `testMatch` in the `ui` project should match `**/*.feature.spec.{ts,js}` to discover generated specs regardless of language (TypeScript or JavaScript output).
|
|
84
|
+
- Do not spread `bddConfig` properties directly into `defineConfig()` — let `bddConfig` handle its own routing; just pass it as `...bddConfig` and define projects separately to avoid TypeScript conflicts.
|
|
85
|
+
- View reports after test runs: run `npx playwright show-report` to open the HTML report in your browser
|
|
64
86
|
- Steps should not import `@playwright/test` directly for test helpers — they should use the fixtures passed by `playwright-bdd` (the `test` instance you pass to `createBdd(test)`). Page objects, however, should import `Page` and be created inside fixtures.
|
|
87
|
+
- The `testMatch` in the `ui` project should match `**/*.feature.spec.{ts,js}` to discover generated specs regardless of language (TypeScript or JavaScript output).
|
|
65
88
|
|
|
66
89
|
If you'd like, I can now:
|
|
67
|
-
- Run the direct spec and show results
|
|
68
|
-
-
|
|
69
|
-
-
|
|
90
|
+
- Run the direct spec and show results: `npm run test`
|
|
91
|
+
- Troubleshoot BDD generation or test failures
|
|
92
|
+
- Add more page objects and step definitions
|
|
93
|
+
- Initialize Git + CI and wire automation tests into GitHub Actions workflow
|