agents-cli-automation 1.0.11 → 1.0.12
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,56 +6,64 @@ argument-hint: "(no args)"
|
|
|
6
6
|
|
|
7
7
|
# Playwright + TypeScript (BDD-capable) — repo snapshot
|
|
8
8
|
|
|
9
|
-
This
|
|
9
|
+
This document explains the current Playwright + TypeScript scaffold and details the recommended layout for:
|
|
10
|
+
- Page Object Models using `@playwright/test`
|
|
11
|
+
- A small JSON data util
|
|
12
|
+
- Fixtures wired for `playwright-bdd`
|
|
13
|
+
- Step definitions that consume fixtures via `playwright-bdd`
|
|
10
14
|
|
|
11
|
-
**Key points (current state)**
|
|
12
|
-
- Playwright config exports
|
|
13
|
-
-
|
|
14
|
-
-
|
|
15
|
-
-
|
|
16
|
-
-
|
|
17
|
-
-
|
|
15
|
+
**Key points (current state and recommended layout)**
|
|
16
|
+
- Playwright config exports both the regular `PlaywrightTestConfig` and a `bddConfig` used by generators: see [playwright.config.ts](playwright.config.ts).
|
|
17
|
+
- Place Gherkin features in `tests/features/*.feature` (example: [tests/features/login.feature](tests/features/login.feature)).
|
|
18
|
+
- Page Objects: implement page classes under `tests/pages/` (example: `tests/pages/login.page.ts`) and import `Page` from `@playwright/test`.
|
|
19
|
+
- 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 `@playwright/test` and registers fixtures (for example `loginPage`) — when using BDD, expose those fixtures so step files can receive them.
|
|
21
|
+
- 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` by default when using `npx bddgen` and the exported `bddConfig` globs.
|
|
18
23
|
|
|
19
|
-
Files to inspect quickly
|
|
24
|
+
Files to inspect or add quickly
|
|
20
25
|
- Playwright config: [playwright.config.ts](playwright.config.ts)
|
|
21
26
|
- TS config / aliases: [tsconfig.json](tsconfig.json)
|
|
22
|
-
-
|
|
27
|
+
- Page object example: [tests/pages/login.page.ts](tests/pages/login.page.ts)
|
|
28
|
+
- JSON data util: [tests/utils/data.ts](tests/utils/data.ts)
|
|
29
|
+
- Test data: [tests/data/users.json](tests/data/users.json)
|
|
30
|
+
- Fixtures: [tests/fixtures/base.fixture.ts](tests/fixtures/base.fixture.ts)
|
|
23
31
|
- Steps: [tests/steps/loginSteps.ts](tests/steps/loginSteps.ts)
|
|
24
32
|
- Feature: [tests/features/login.feature](tests/features/login.feature)
|
|
25
|
-
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
-
|
|
30
|
-
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
33
|
+
- Direct Playwright spec (optional): [tests/specs/login.spec.ts](tests/specs/login.spec.ts)
|
|
34
|
+
|
|
35
|
+
How the flow works here
|
|
36
|
+
- 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
|
+
- 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`) so both direct specs and generated BDD specs can reuse them.
|
|
39
|
+
- Write step definitions in `tests/steps/*.ts` using `playwright-bdd`'s `createBdd(test)` helper. Example pattern:
|
|
40
|
+
- import `createBdd` and your `test` fixture: `const { Given, When, Then } = createBdd(test)`
|
|
41
|
+
- 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`). Note: some generator tools require specific versions of `@cucumber/cucumber` or other peer deps; if generator errors occur, either install the missing peer or use the direct-spec option below.
|
|
43
|
+
- 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`.
|
|
44
|
+
|
|
45
|
+
Run the direct Playwright spec (no generator required):
|
|
46
|
+
|
|
39
47
|
```bash
|
|
40
|
-
# install deps (first time)
|
|
41
48
|
npm install
|
|
42
|
-
npx playwright install
|
|
49
|
+
npx playwright install
|
|
50
|
+
npx playwright test --project=ui tests/specs/login.spec.ts
|
|
51
|
+
```
|
|
43
52
|
|
|
44
|
-
|
|
45
|
-
npx bddgen
|
|
46
|
-
# or (if present) npm run generate:bdd
|
|
53
|
+
Generator flow (if you want `.features-gen` generated specs):
|
|
47
54
|
|
|
48
|
-
|
|
49
|
-
|
|
55
|
+
```bash
|
|
56
|
+
npm install
|
|
57
|
+
npx bddgen
|
|
58
|
+
npx playwright test --project=ui
|
|
50
59
|
```
|
|
51
60
|
|
|
52
61
|
Notes & tips
|
|
53
|
-
-
|
|
54
|
-
-
|
|
55
|
-
-
|
|
56
|
-
- If you want me to update any generated-spec import style (e.g. prefer `.ts` vs `.js`, or use path aliases inside generator output), tell me which style you prefer and I will patch the generator and re-generate specs.
|
|
62
|
+
- Keep fixtures stable: generated specs import your fixture module, so keep `tests/fixtures/base.fixture.ts` API stable.
|
|
63
|
+
- If `npx bddgen` errors with a missing module like `@cucumber/cucumber`, install the required peer dependency (for example `npm install --save-dev @cucumber/cucumber`) or prefer the direct-spec flow until generator versions are aligned.
|
|
64
|
+
- 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.
|
|
57
65
|
|
|
58
66
|
If you'd like, I can now:
|
|
59
|
-
- Run
|
|
60
|
-
-
|
|
61
|
-
-
|
|
67
|
+
- Run the direct spec and show results, or
|
|
68
|
+
- Add full `tests/steps/*.ts` step definitions wired to the fixtures and attempt to re-run `npx bddgen` to regenerate specs, or
|
|
69
|
+
- Initialize Git + CI and wire the test into a workflow.
|