@immense/vue-pom-generator 1.0.46 → 1.0.48
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 +45 -11
- package/RELEASE_NOTES.md +38 -27
- package/class-generation/index.ts +1421 -682
- package/dist/class-generation/index.d.ts +8 -0
- package/dist/class-generation/index.d.ts.map +1 -1
- package/dist/index.cjs +1501 -691
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +1504 -694
- package/dist/index.mjs.map +1 -1
- package/dist/manifest-generator.d.ts.map +1 -1
- package/dist/method-generation.d.ts +2 -0
- package/dist/method-generation.d.ts.map +1 -1
- package/dist/plugin/create-vue-pom-generator-plugins.d.ts.map +1 -1
- package/dist/plugin/support/build-plugin.d.ts +3 -1
- package/dist/plugin/support/build-plugin.d.ts.map +1 -1
- package/dist/plugin/support/dev-plugin.d.ts +3 -1
- package/dist/plugin/support/dev-plugin.d.ts.map +1 -1
- package/dist/plugin/support-plugins.d.ts +3 -1
- package/dist/plugin/support-plugins.d.ts.map +1 -1
- package/dist/plugin/types.d.ts +32 -7
- package/dist/plugin/types.d.ts.map +1 -1
- package/dist/tests/fixtures/generated-tsc/BasePage.full.d.ts +19 -0
- package/dist/tests/fixtures/generated-tsc/BasePage.full.d.ts.map +1 -0
- package/dist/tests/fixtures/generated-tsc/BasePage.minimal.d.ts +8 -0
- package/dist/tests/fixtures/generated-tsc/BasePage.minimal.d.ts.map +1 -0
- package/dist/tests/fixtures/generated-tsc/Pointer.d.ts +6 -0
- package/dist/tests/fixtures/generated-tsc/Pointer.d.ts.map +1 -0
- package/dist/transform.d.ts +1 -0
- package/dist/transform.d.ts.map +1 -1
- package/dist/typescript-codegen.d.ts +34 -0
- package/dist/typescript-codegen.d.ts.map +1 -0
- package/package.json +2 -1
package/README.md
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
`@immense/vue-pom-generator` is a Vite plugin for Vue 3 that does two compile-time jobs:
|
|
4
4
|
|
|
5
5
|
1. it injects a test-id attribute into interactive elements in `.vue` templates
|
|
6
|
-
2. it turns the collected ids into
|
|
6
|
+
2. it turns the collected ids into a Page Object Model library for Playwright, with aggregated or split TypeScript output, optional Playwright fixtures, and optional C# output
|
|
7
7
|
|
|
8
8
|
If you already use Playwright with `getByTestId`, the point is simple: this package removes the repetitive work of keeping test ids in sync with Vue templates and then hand-writing page objects around those ids.
|
|
9
9
|
|
|
@@ -11,8 +11,9 @@ If you already use Playwright with `getByTestId`, the point is simple: this pack
|
|
|
11
11
|
|
|
12
12
|
- **Injects test ids during Vue compilation, not at runtime.** It hooks into the Vue template compiler and rewrites the compiled template output.
|
|
13
13
|
- **Uses real template signals to name ids and methods.** Click handlers, `v-model`, `id`/`name`, `:to`, wrapper configuration, and a few targeted fallbacks all feed the generated API.
|
|
14
|
-
- **Generates one
|
|
14
|
+
- **Generates TypeScript POM output as either one aggregate or split per class, always with a stable `index.ts` barrel.**
|
|
15
15
|
- **Can generate Playwright fixtures** so tests can request `userListPage` instead of constructing `new UserListPage(page)` manually.
|
|
16
|
+
- **Can fail fast on unnameable wrapper-button actions** so complex inline handlers do not silently degrade into low-signal generated APIs.
|
|
16
17
|
- **Can emit a single C# POM file** for Playwright .NET consumers.
|
|
17
18
|
- **Exposes `virtual:testids`** so your app can import the current collected test-id manifest at runtime.
|
|
18
19
|
- **Ships ESLint rules** to remove legacy manually-authored test ids, ban raw `page` fixture usage in spec callbacks, and discourage raw locator actions on generated getters.
|
|
@@ -73,6 +74,7 @@ The generator does not use one naming trick. It layers several signals.
|
|
|
73
74
|
- **Router links / `:to` bindings** can contribute route-based naming and typed navigation return types when the target can be resolved.
|
|
74
75
|
- **Wrapper components** can be explicit (`nativeWrappers`) or inferred from simple local SFC templates.
|
|
75
76
|
- **Fallback naming exists, but it is intentionally conservative.** That is why `generation.nameCollisionBehavior` exists.
|
|
77
|
+
- **You can opt into stricter wrapper-action generation.** `errorBehavior: "error"` blocks button-like wrapper `:handler` expressions that the generator cannot turn into a semantic action name.
|
|
76
78
|
|
|
77
79
|
Important limit: wrapper inference is helpful, not magical. The current implementation recursively inspects simple local SFC templates for the first inferable primitive (`input`, `textarea`, `select`, `button`, `vselect`, radio/checkbox inputs). It also recognizes some naming patterns like `*Button`. For anything more complex, configure `nativeWrappers` explicitly.
|
|
78
80
|
|
|
@@ -200,6 +202,7 @@ const pomConfig = defineVuePomGeneratorConfig({
|
|
|
200
202
|
script: { defineModel: true, propsDestructure: true },
|
|
201
203
|
},
|
|
202
204
|
logging: { verbosity: "info" },
|
|
205
|
+
errorBehavior: "error",
|
|
203
206
|
injection: {
|
|
204
207
|
attribute: "data-testid",
|
|
205
208
|
viewsDir: "src/views",
|
|
@@ -231,6 +234,7 @@ const pomConfig = defineVuePomGeneratorConfig({
|
|
|
231
234
|
},
|
|
232
235
|
playwright: {
|
|
233
236
|
fixtures: true,
|
|
237
|
+
outputStructure: "split",
|
|
234
238
|
customPoms: {
|
|
235
239
|
dir: "tests/playwright/pom/custom",
|
|
236
240
|
importAliases: {
|
|
@@ -291,9 +295,13 @@ By default, generation writes to `tests/playwright/__generated__`.
|
|
|
291
295
|
|
|
292
296
|
TypeScript output:
|
|
293
297
|
|
|
294
|
-
- `
|
|
295
|
-
- `
|
|
296
|
-
- `
|
|
298
|
+
- default (`generation.playwright.outputStructure: "aggregated"`):
|
|
299
|
+
- `page-object-models.g.ts` — aggregated generated classes
|
|
300
|
+
- `index.ts` — stable barrel re-exporting `page-object-models.g`
|
|
301
|
+
- split mode (`generation.playwright.outputStructure: "split"`):
|
|
302
|
+
- one `*.g.ts` file per generated class
|
|
303
|
+
- `index.ts` — stable barrel re-exporting the split files
|
|
304
|
+
- `_pom-runtime/` — copied runtime support files used by the generated TypeScript output in either mode
|
|
297
305
|
|
|
298
306
|
Optional Playwright fixture output:
|
|
299
307
|
|
|
@@ -310,7 +318,7 @@ If you emit outside a `__generated__` path, the generator also manages `.gitattr
|
|
|
310
318
|
|
|
311
319
|
This is important if you are deciding whether the tool will fit into a real codebase.
|
|
312
320
|
|
|
313
|
-
- **Dev server:** on startup, it scans the configured `scanDirs`, compiles each `.vue` file into a snapshot, writes the
|
|
321
|
+
- **Dev server:** on startup, it scans the configured `scanDirs`, compiles each `.vue` file into a snapshot, writes the configured TypeScript outputs once, then batches add/change/delete events and regenerates incrementally.
|
|
314
322
|
- **Build:** it generates from the richest build pass it sees, which matters because Vite can run multiple passes (for example SSR plus client). The generator avoids letting a thinner pass clobber a richer one.
|
|
315
323
|
- **Always-on virtual module:** `virtual:testids` is registered whether generation is enabled or disabled.
|
|
316
324
|
- **Generation can be disabled:** `generation: false` still keeps compile-time test-id injection and the virtual module, but skips emitted POM files.
|
|
@@ -380,7 +388,7 @@ These two directories solve different problems.
|
|
|
380
388
|
|
|
381
389
|
Default: `tests/playwright/pom/custom`
|
|
382
390
|
|
|
383
|
-
This directory is for handwritten helper classes that the
|
|
391
|
+
This directory is for handwritten helper classes that the generated TypeScript output can import.
|
|
384
392
|
|
|
385
393
|
It is the default helper directory even if you omit `generation.playwright.customPoms` entirely.
|
|
386
394
|
|
|
@@ -389,7 +397,7 @@ Actual current behavior:
|
|
|
389
397
|
- the generator scans the directory **non-recursively**
|
|
390
398
|
- it imports top-level `.ts` files only
|
|
391
399
|
- it expects the file basename to match the exported class name (`Grid.ts` → `export class Grid {}`)
|
|
392
|
-
- the helper files are
|
|
400
|
+
- the helper files are available to generated output; they are **not** automatically attached everywhere
|
|
393
401
|
|
|
394
402
|
What it is for:
|
|
395
403
|
|
|
@@ -431,7 +439,7 @@ A typical override looks like this:
|
|
|
431
439
|
|
|
432
440
|
```ts
|
|
433
441
|
// tests/playwright/pom/overrides/UserListPage.ts
|
|
434
|
-
import { UserListPage as GeneratedUserListPage } from "../../__generated__
|
|
442
|
+
import { UserListPage as GeneratedUserListPage } from "../../__generated__";
|
|
435
443
|
|
|
436
444
|
export class UserListPage extends GeneratedUserListPage {
|
|
437
445
|
async openFirstUser() {
|
|
@@ -446,7 +454,10 @@ This is where most people need precision.
|
|
|
446
454
|
|
|
447
455
|
### Helper imports
|
|
448
456
|
|
|
449
|
-
Every `.ts` file in `customPoms.dir`
|
|
457
|
+
Every `.ts` file in `customPoms.dir` is available for import from the generated TypeScript output.
|
|
458
|
+
|
|
459
|
+
- in aggregated mode, helper files become imports in the shared aggregate
|
|
460
|
+
- in split mode, each generated file imports only the helpers it actually needs
|
|
450
461
|
|
|
451
462
|
Benefits:
|
|
452
463
|
|
|
@@ -804,6 +815,18 @@ The sections below follow the actual `VuePomGeneratorPluginOptions` shape from `
|
|
|
804
815
|
logging: { verbosity: "debug" }
|
|
805
816
|
```
|
|
806
817
|
|
|
818
|
+
#### `errorBehavior`
|
|
819
|
+
|
|
820
|
+
- **What it does:** Controls strict/error behavior for generator checks.
|
|
821
|
+
- **Why it exists:** complex inline handlers can otherwise fall through to generic naming, which makes generated APIs harder to discover and review.
|
|
822
|
+
- **Benefit:** `"error"` lets you opt into fail-fast behavior globally, while the object form lets you turn on only the checks you care about.
|
|
823
|
+
- **Without it:** the default is `"ignore"`, so existing permissive fallback behavior remains in place.
|
|
824
|
+
- **Accepted values:**
|
|
825
|
+
- `"ignore"` — keep permissive defaults for all supported checks
|
|
826
|
+
- `"error"` — enable error-on-failure behavior for all supported checks
|
|
827
|
+
- `{ missingSemanticNameBehavior: "error" }` — enable only the button-wrapper semantic-name check
|
|
828
|
+
- **Current scope:** this first pass is intentionally narrow. The object form currently supports `missingSemanticNameBehavior`, which targets button-like wrappers with `:handler`; value/model-driven wrappers still use their existing naming flow.
|
|
829
|
+
|
|
807
830
|
### `injection`
|
|
808
831
|
|
|
809
832
|
`injection` controls compile-time test-id derivation and template rewriting.
|
|
@@ -1022,6 +1045,17 @@ This object holds Playwright-specific additions on top of the generated TypeScri
|
|
|
1022
1045
|
- `"path"` — if the string ends in `.ts` / `.tsx` / `.mts` / `.cts`, it is treated as a file path; otherwise as an output directory
|
|
1023
1046
|
- `{ outDir }` — emit to a custom directory
|
|
1024
1047
|
|
|
1048
|
+
#### `generation.playwright.outputStructure`
|
|
1049
|
+
|
|
1050
|
+
- **What it does:** Chooses whether generated TypeScript POMs are emitted as one aggregate or split per class.
|
|
1051
|
+
- **Why it exists:** very large generated files are harder to browse, inspect, and discover in editors.
|
|
1052
|
+
- **Benefit:** `"split"` keeps the same stable barrel and fixtures surface while making individual classes and methods easier to find.
|
|
1053
|
+
- **Without it:** the default is `"aggregated"`.
|
|
1054
|
+
- **Accepted values:**
|
|
1055
|
+
- `"aggregated"` — emit `page-object-models.g.ts` plus `index.ts`
|
|
1056
|
+
- `"split"` — emit one `*.g.ts` file per class plus `index.ts`
|
|
1057
|
+
- **Current limit:** this setting only affects the generated TypeScript Playwright output; C# output remains a single aggregated file.
|
|
1058
|
+
|
|
1025
1059
|
#### `generation.playwright.customPoms`
|
|
1026
1060
|
|
|
1027
1061
|
- **What it does:** Configures handwritten helper imports and attachments.
|
|
@@ -1048,7 +1082,7 @@ This object holds Playwright-specific additions on top of the generated TypeScri
|
|
|
1048
1082
|
#### `customPoms.importNameCollisionBehavior`
|
|
1049
1083
|
|
|
1050
1084
|
- **What it does:** Controls how helper import names behave when they collide with generated class names.
|
|
1051
|
-
- **Why it exists:**
|
|
1085
|
+
- **Why it exists:** generated files still need a conflict-free local import namespace.
|
|
1052
1086
|
- **Benefit:** lets you fail hard or auto-alias based on team preference.
|
|
1053
1087
|
- **Without it:** the default is `"error"`.
|
|
1054
1088
|
|
package/RELEASE_NOTES.md
CHANGED
|
@@ -1,42 +1,53 @@
|
|
|
1
|
-
●
|
|
1
|
+
● # Release Notes: v1.0.48
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
-
|
|
6
|
-
|
|
7
|
-
-
|
|
3
|
+
## Highlights
|
|
4
|
+
|
|
5
|
+
- **Split Playwright POM Output**: Added new option to generate split/modular Page Object Models
|
|
6
|
+
for improved discoverability and maintainability
|
|
7
|
+
- **ts-morph Integration**: Migrated TypeScript code generation to use ts-morph library for more
|
|
8
|
+
robust and maintainable type emission
|
|
9
|
+
- **Fail-Fast Error Handling**: Now fails immediately when encountering unnameable wrapper
|
|
10
|
+
handlers instead of generating invalid code
|
|
11
|
+
- **Enhanced Type Safety**: Improved TypeScript code generation structure with dedicated
|
|
12
|
+
emitters and better type definitions
|
|
8
13
|
|
|
9
14
|
## Changes
|
|
10
15
|
|
|
11
|
-
|
|
12
|
-
-
|
|
16
|
+
### Features
|
|
17
|
+
- Add split Playwright POM output for improved discoverability (#12)
|
|
18
|
+
- Fail fast on unnameable wrapper handlers instead of silently generating invalid code (#11)
|
|
13
19
|
|
|
14
|
-
|
|
15
|
-
-
|
|
16
|
-
-
|
|
17
|
-
-
|
|
20
|
+
### Refactoring & Code Quality
|
|
21
|
+
- Migrate to ts-morph for TypeScript code generation
|
|
22
|
+
- Structure ts-morph emitters into dedicated modules
|
|
23
|
+
- Clean up split stub generation logic
|
|
24
|
+
- Address PR feedback on split output implementation
|
|
25
|
+
- Remove duplicate rebase leftovers
|
|
18
26
|
|
|
19
|
-
|
|
20
|
-
-
|
|
21
|
-
-
|
|
27
|
+
### Configuration & Types
|
|
28
|
+
- Add ts-morph dependency to package.json
|
|
29
|
+
- Update plugin types to support split output options
|
|
30
|
+
- Enhance manifest generator for split POM structure
|
|
22
31
|
|
|
23
|
-
|
|
32
|
+
### Testing
|
|
33
|
+
- Add comprehensive tests for generated TypeScript output
|
|
34
|
+
- Add test fixtures for BasePage (full/minimal), Pointer, and playwright-test declarations
|
|
35
|
+
- Update class generation coverage tests
|
|
36
|
+
- Add option tests for new split output configuration
|
|
24
37
|
|
|
25
|
-
|
|
38
|
+
### Documentation
|
|
39
|
+
- Update README with split output documentation and usage examples
|
|
26
40
|
|
|
27
41
|
## Pull Requests Included
|
|
28
42
|
|
|
29
|
-
- #
|
|
30
|
-
(https://github.com/immense/vue-pom-generator/pull/
|
|
31
|
-
- #
|
|
32
|
-
(https://github.com/immense/vue-pom-generator/pull/
|
|
33
|
-
- #5 fix: dev-mode POM generation parity with build mode
|
|
34
|
-
(https://github.com/immense/vue-pom-generator/pull/5)
|
|
35
|
-
- #4 Fix keyed POM dedupe and C# navigation returns
|
|
36
|
-
(https://github.com/immense/vue-pom-generator/pull/4)
|
|
37
|
-
- #1 Add PR release-notes preview comments (https://github.com/immense/vue-pom-generator/pull/1)
|
|
43
|
+
- #12 feat: add split Playwright POM output for discoverability
|
|
44
|
+
(https://github.com/immense/vue-pom-generator/pull/12)
|
|
45
|
+
- #11 feat: fail fast on unnameable wrapper handlers
|
|
46
|
+
(https://github.com/immense/vue-pom-generator/pull/11)
|
|
38
47
|
|
|
39
48
|
## Testing
|
|
40
49
|
|
|
41
|
-
Added
|
|
50
|
+
Added 173+ lines of new tests for TypeScript code generation, including fixtures for BasePage
|
|
51
|
+
and Pointer types. Updated existing test suites to cover split output scenarios and plugin
|
|
52
|
+
options.
|
|
42
53
|
|