@vijaypjavvadi/pw-emit 1.0.0 → 1.1.0
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/CHANGELOG.md +16 -0
- package/dist/testEmitter.js +21 -4
- package/dist/testEmitter.js.map +1 -1
- package/dist/types.d.ts +17 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -9,6 +9,22 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
9
9
|
|
|
10
10
|
_Nothing yet._
|
|
11
11
|
|
|
12
|
+
## [1.1.0] — 2026-05-12
|
|
13
|
+
|
|
14
|
+
### Added (consumed by `@vijaypjavvadi/bdd2pw@3.0.0`)
|
|
15
|
+
|
|
16
|
+
- `TestSpecIR.playwrightImports?: string[]` — extra named imports
|
|
17
|
+
merged into the emitted `import { test, expect, ... } from "@playwright/test";`
|
|
18
|
+
line. bdd2pw uses this to surface `type APIResponse` when the
|
|
19
|
+
feature has any API step.
|
|
20
|
+
- `TestSpecIR.describeBodyPrelude?: string` — pre-rendered TS lines
|
|
21
|
+
emitted inside `test.describe(...)` before any hooks or tests.
|
|
22
|
+
bdd2pw uses this to declare describe-scoped state for API tests
|
|
23
|
+
(`let apiResponse: APIResponse | null = null;`, etc.).
|
|
24
|
+
|
|
25
|
+
Both additions are optional. Existing pure-UI emission paths are
|
|
26
|
+
byte-stable across the 1.0 → 1.1 upgrade. SemVer minor.
|
|
27
|
+
|
|
12
28
|
## [1.0.0] — 2026-05-03
|
|
13
29
|
|
|
14
30
|
First public npm release. Consumed by `@vijaypjavvadi/bdd2pw@1.0.0` from day one;
|
package/dist/testEmitter.js
CHANGED
|
@@ -28,8 +28,11 @@ const indent_1 = require("./indent");
|
|
|
28
28
|
function emitTestSpec(ir) {
|
|
29
29
|
const warnings = [];
|
|
30
30
|
const lines = [];
|
|
31
|
-
// Imports
|
|
32
|
-
|
|
31
|
+
// Imports — playwrightImports (v1.1.0) merges extra named imports into
|
|
32
|
+
// the @playwright/test line. E.g. `["type APIResponse"]` produces
|
|
33
|
+
// `import { test, expect, type APIResponse } from "@playwright/test";`.
|
|
34
|
+
const playwrightNames = ["test", "expect", ...(ir.playwrightImports ?? [])];
|
|
35
|
+
lines.push(`import { ${playwrightNames.join(", ")} } from "@playwright/test";`);
|
|
33
36
|
if (ir.pomImports && ir.pomImports.length) {
|
|
34
37
|
for (const imp of ir.pomImports) {
|
|
35
38
|
lines.push(`import { ${imp.className} } from "${imp.fromPath}";`);
|
|
@@ -41,6 +44,14 @@ function emitTestSpec(ir) {
|
|
|
41
44
|
}
|
|
42
45
|
lines.push("");
|
|
43
46
|
lines.push(`test.describe(${JSON.stringify(ir.describeName)}, () => {`);
|
|
47
|
+
// describeBodyPrelude (v1.1.0) — describe-scoped state declarations
|
|
48
|
+
// (e.g. `let apiResponse: APIResponse | null = null;`) emitted before
|
|
49
|
+
// any hooks. Indented one level deeper than the describe call.
|
|
50
|
+
if (ir.describeBodyPrelude && ir.describeBodyPrelude.trim().length > 0) {
|
|
51
|
+
for (const line of ir.describeBodyPrelude.split("\n")) {
|
|
52
|
+
lines.push(line.length ? ` ${line}` : "");
|
|
53
|
+
}
|
|
54
|
+
}
|
|
44
55
|
// Hooks
|
|
45
56
|
emitHooks(lines, "test.beforeAll", ir.beforeAll);
|
|
46
57
|
emitHooks(lines, "test.beforeEach", ir.beforeEach);
|
|
@@ -48,8 +59,14 @@ function emitTestSpec(ir) {
|
|
|
48
59
|
for (const t of ir.tests) {
|
|
49
60
|
lines.push("");
|
|
50
61
|
if (t.tags && t.tags.length) {
|
|
51
|
-
|
|
52
|
-
|
|
62
|
+
// v1.1.0 — tag names sometimes arrive with `@` already attached
|
|
63
|
+
// (Gherkin parser convention: tag.name returns "@api", not "api").
|
|
64
|
+
// Strip a single leading `@` to avoid double-`@@` in the emitted
|
|
65
|
+
// comment.
|
|
66
|
+
for (const tag of t.tags) {
|
|
67
|
+
const clean = tag.startsWith("@") ? tag.slice(1) : tag;
|
|
68
|
+
lines.push(` // @${clean}`);
|
|
69
|
+
}
|
|
53
70
|
}
|
|
54
71
|
if (t.jsdoc) {
|
|
55
72
|
for (const docLine of t.jsdoc.split("\n")) {
|
package/dist/testEmitter.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"testEmitter.js","sourceRoot":"","sources":["../src/testEmitter.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;;AAKH,
|
|
1
|
+
{"version":3,"file":"testEmitter.js","sourceRoot":"","sources":["../src/testEmitter.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;;AAKH,oCAmFC;AArFD,qCAA2C;AAE3C,SAAgB,YAAY,CAAC,EAAc;IACzC,MAAM,QAAQ,GAAiB,EAAE,CAAC;IAClC,MAAM,KAAK,GAAa,EAAE,CAAC;IAE3B,uEAAuE;IACvE,kEAAkE;IAClE,wEAAwE;IACxE,MAAM,eAAe,GAAG,CAAC,MAAM,EAAE,QAAQ,EAAE,GAAG,CAAC,EAAE,CAAC,iBAAiB,IAAI,EAAE,CAAC,CAAC,CAAC;IAC5E,KAAK,CAAC,IAAI,CACR,YAAY,eAAe,CAAC,IAAI,CAAC,IAAI,CAAC,6BAA6B,CACpE,CAAC;IACF,IAAI,EAAE,CAAC,UAAU,IAAI,EAAE,CAAC,UAAU,CAAC,MAAM,EAAE,CAAC;QAC1C,KAAK,MAAM,GAAG,IAAI,EAAE,CAAC,UAAU,EAAE,CAAC;YAChC,KAAK,CAAC,IAAI,CAAC,YAAY,GAAG,CAAC,SAAS,YAAY,GAAG,CAAC,QAAQ,IAAI,CAAC,CAAC;QACpE,CAAC;IACH,CAAC;IACD,IAAI,EAAE,CAAC,YAAY,IAAI,EAAE,CAAC,YAAY,CAAC,MAAM,EAAE,CAAC;QAC9C,KAAK,MAAM,GAAG,IAAI,EAAE,CAAC,YAAY;YAAE,KAAK,CAAC,IAAI,CAAC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@@ export interface TestSpecIR {
|
|
|
82
82
|
tests: TestCaseIR[];
|
|
83
83
|
/** Optional extra import lines. */
|
|
84
84
|
extraImports?: string[];
|
|
85
|
+
/**
|
|
86
|
+
* v1.1.0 — extra named imports to merge into the `@playwright/test`
|
|
87
|
+
* import. E.g. `["type APIResponse"]` produces
|
|
88
|
+
* `import { test, expect, type APIResponse } from "@playwright/test";`
|
|
89
|
+
* instead of the default `import { test, expect } from ...`.
|
|
90
|
+
* Used by bdd2pw v3.0.0 to surface the APIResponse type when API steps
|
|
91
|
+
* are present in the feature.
|
|
92
|
+
*/
|
|
93
|
+
playwrightImports?: string[];
|
|
94
|
+
/**
|
|
95
|
+
* v1.1.0 — pre-rendered TS lines emitted inside `test.describe(...)`
|
|
96
|
+
* before any hooks or tests. Used for describe-scoped state — e.g.
|
|
97
|
+
* `let apiResponse: APIResponse | null = null;` shared across the
|
|
98
|
+
* tests in the block. Each line is emitted at one indent level
|
|
99
|
+
* deeper than the describe call.
|
|
100
|
+
*/
|
|
101
|
+
describeBodyPrelude?: string;
|
|
85
102
|
}
|
|
86
103
|
export interface ReviewItem {
|
|
87
104
|
severity: "info" | "warn" | "error";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vijaypjavvadi/pw-emit",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"description": "Shared emitter library that renders Playwright TypeScript Page Objects, spec files, and project scaffolds from a generic IR. Powers both @vijaypjavvadi/sel2pw and @vijaypjavvadi/bdd2pw.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|