@test2doc/playwright 0.9.0 → 0.11.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/README.md CHANGED
@@ -204,7 +204,7 @@ describe(withDocMeta("Title of Page", {
204
204
  ### Adding Docusaurus Category Routes
205
205
  Docusaurus supports grouping docs by [category](https://docusaurus.io/docs/sidebar/autogenerated#category-item-metadata).
206
206
 
207
- By using the `withDocCategory` function for a describe block's title, this will add the metadata to allow Test2Doc to generate a new directory and a `__category__.json` file. It will then place all subsequent describes and tests under this new route.
207
+ By using the `withDocCategory` function for a describe block's title, this will add the metadata to allow Test2Doc to generate a new directory and a `_category_.json` file. It will then place all subsequent describes and tests under this new route.
208
208
 
209
209
  ```ts
210
210
 
@@ -353,6 +353,20 @@ To style the highlight and label we expose a few properties on the `annotation`
353
353
  - **Type**: `"above" | "below" | "left" | "right"`
354
354
  - **Description**: Determines the position of the label text relative to the highlighted element.
355
355
  - **Default**: `"below"` - automatically repositioned if insufficient space below the element.
356
+ - **`showArrow`**:
357
+ - **Type**: `boolean`
358
+ - **Description**: Whether to display an arrow pointing from the label to the highlighted element. When enabled, creates a visual connection between the annotation text and the target element.
359
+ - **Default**: `false`
360
+
361
+ - **`arrowStrokeStyle`**:
362
+ - **Type**: `string`
363
+ - **Description**: The color of the arrow line and arrowhead. Accepts any valid CSS color value, including hex codes, RGB, RGBA, HSL, or HSLA.
364
+ - **Default**: `rgba(255, 0, 0, 1)` (red)
365
+
366
+ - **`arrowLineWidth`**:
367
+ - **Type**: `number`
368
+ - **Description**: The thickness of the arrow line. The arrowhead size automatically scales based on this value.
369
+ - **Default**: `2`
356
370
 
357
371
  ```ts
358
372
  test.describe(withDocMeta("describe block"), async () => {
@@ -375,10 +389,41 @@ test.describe(withDocMeta("describe block"), async () => {
375
389
  highlightFillStyle: "rgba(255, 165, 0, 0.3)",
376
390
  highlightStrokeStyle: "#FFA500",
377
391
  highlightLineWidth: 2,
378
- position: "above"
392
+ position: "above",
393
+ showArrow: true,
394
+ arrowStrokeStyle: "rgba(255, 0, 0, 0.8)",
395
+ arrowLineWidth: 3
379
396
  }}
380
397
  ))
381
398
  })
382
399
  })
383
400
  })
384
401
  ```
402
+
403
+ ##### Configure Annotation Defaults
404
+ If you want to set default values for the annotation object you can do so in your `playwright-test2doc.config.ts`. Just set the `annotationDefaults` object in the `test2doc` playwright global options. These defaults will be applied to all screenshots, but can still be overridden on a per-screenshot basis.
405
+ ```ts
406
+ import { defineConfig, ... } from "@playwright/test"
407
+ import "@test2doc/types" // Add this import to add test2doc to the global options
408
+
409
+ export default defineConfig({
410
+ ...
411
+ use: {
412
+ ...
413
+ test2doc: {
414
+ annotationDefaults: {
415
+ fillStyle: "white",
416
+ labelBoxFillStyle: "rgba(0, 123, 255, 0.6)",
417
+ font: "bold 16px Helvetica, Arial, sans-serif",
418
+ highlightStrokeStyle: "rgba(0, 123, 255, 1)",
419
+ highlightFillStyle: "rgba(0, 0, 0, 0)",
420
+ highlightLineWidth: 3,
421
+ showArrow: true,
422
+ arrowStrokeStyle: "rgba(0, 123, 255, 1)",
423
+ },
424
+ },
425
+ ...
426
+ },
427
+ ...
428
+ })
429
+ ```
@@ -1,5 +1,6 @@
1
1
  import type { Locator, Page, PageScreenshotOptions, TestInfo } from "@playwright/test";
2
- interface AnnotationOptions {
2
+ type Position = "above" | "below" | "left" | "right";
3
+ export interface AnnotationOptions {
3
4
  text?: string;
4
5
  fillStyle?: string;
5
6
  font?: string;
@@ -11,11 +12,14 @@ interface AnnotationOptions {
11
12
  highlightFillStyle?: string;
12
13
  highlightStrokeStyle?: string;
13
14
  highlightLineWidth?: number;
14
- position?: "above" | "below" | "left" | "right";
15
+ position?: Position;
16
+ showArrow?: boolean;
17
+ arrowStrokeStyle?: string;
18
+ arrowLineWidth?: number;
15
19
  }
16
20
  interface ScreenshotOptions extends PageScreenshotOptions {
17
21
  annotation?: AnnotationOptions;
18
22
  }
19
- export declare const screenshot: (testInfo: TestInfo, target: Page | Locator, { annotation, ...options }?: ScreenshotOptions) => Promise<void>;
23
+ export declare const screenshot: (testInfo: TestInfo, target: Page | Locator, { annotation: overrideAnnotations, ...options }?: ScreenshotOptions) => Promise<void>;
20
24
  export {};
21
25
  //# sourceMappingURL=screenshots.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"screenshots.d.ts","sourceRoot":"","sources":["../src/screenshots.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,OAAO,EACP,IAAI,EACJ,qBAAqB,EACrB,QAAQ,EACT,MAAM,kBAAkB,CAAA;AAIzB,UAAU,iBAAiB;IACzB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,iBAAiB,CAAC,EAAE,MAAM,CAAA;IAC1B,mBAAmB,CAAC,EAAE,MAAM,CAAA;IAC5B,iBAAiB,CAAC,EAAE,MAAM,CAAA;IAC1B,kBAAkB,CAAC,EAAE,MAAM,CAAA;IAC3B,oBAAoB,CAAC,EAAE,MAAM,CAAA;IAC7B,kBAAkB,CAAC,EAAE,MAAM,CAAA;IAC3B,QAAQ,CAAC,EAAE,OAAO,GAAG,OAAO,GAAG,MAAM,GAAG,OAAO,CAAA;CAChD;AAED,UAAU,iBAAkB,SAAQ,qBAAqB;IACvD,UAAU,CAAC,EAAE,iBAAiB,CAAA;CAC/B;AAED,eAAO,MAAM,UAAU,GACrB,UAAU,QAAQ,EAClB,QAAQ,IAAI,GAAG,OAAO,EACtB,6BAA4B,iBAAsB,kBAoKnD,CAAA"}
1
+ {"version":3,"file":"screenshots.d.ts","sourceRoot":"","sources":["../src/screenshots.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,OAAO,EACP,IAAI,EACJ,qBAAqB,EACrB,QAAQ,EACT,MAAM,kBAAkB,CAAA;AAIzB,KAAK,QAAQ,GAAG,OAAO,GAAG,OAAO,GAAG,MAAM,GAAG,OAAO,CAAA;AAEpD,MAAM,WAAW,iBAAiB;IAChC,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,iBAAiB,CAAC,EAAE,MAAM,CAAA;IAC1B,mBAAmB,CAAC,EAAE,MAAM,CAAA;IAC5B,iBAAiB,CAAC,EAAE,MAAM,CAAA;IAC1B,kBAAkB,CAAC,EAAE,MAAM,CAAA;IAC3B,oBAAoB,CAAC,EAAE,MAAM,CAAA;IAC7B,kBAAkB,CAAC,EAAE,MAAM,CAAA;IAC3B,QAAQ,CAAC,EAAE,QAAQ,CAAA;IACnB,SAAS,CAAC,EAAE,OAAO,CAAA;IACnB,gBAAgB,CAAC,EAAE,MAAM,CAAA;IACzB,cAAc,CAAC,EAAE,MAAM,CAAA;CACxB;AAED,UAAU,iBAAkB,SAAQ,qBAAqB;IACvD,UAAU,CAAC,EAAE,iBAAiB,CAAA;CAC/B;AAED,eAAO,MAAM,UAAU,GACrB,UAAU,QAAQ,EAClB,QAAQ,IAAI,GAAG,OAAO,EACtB,kDAAiD,iBAAsB,kBAuPxE,CAAA"}
@@ -1,5 +1,9 @@
1
1
  let screenshotCounter = 0;
2
- export const screenshot = async (testInfo, target, { annotation, ...options } = {}) => {
2
+ export const screenshot = async (testInfo, target, { annotation: overrideAnnotations, ...options } = {}) => {
3
+ const annotation = {
4
+ ...(testInfo.project?.use?.test2doc?.annotationDefaults ?? {}),
5
+ ...overrideAnnotations,
6
+ };
3
7
  const filename = `test2doc-${Date.now()}-${++screenshotCounter}.png`;
4
8
  let screenshot;
5
9
  if ("highlight" in target) {
@@ -39,66 +43,104 @@ export const screenshot = async (testInfo, target, { annotation, ...options } =
39
43
  ctx.font = annotation?.font ?? "14px Arial";
40
44
  const { width: textWidth, actualBoundingBoxAscent, actualBoundingBoxDescent, } = ctx.measureText(annotation.text);
41
45
  const textHeight = actualBoundingBoxAscent + actualBoundingBoxDescent;
46
+ const margin = annotation.showArrow ? 24 : 4;
42
47
  const padding = 4;
43
- let position = annotation.position;
44
- if (!position) {
45
- console.log({
46
- x: box.x,
47
- width: box.width,
48
- textWidth,
49
- innerWidth: window.innerWidth,
50
- });
51
- console.log({
52
- y: box.y,
53
- height: box.height,
54
- textHeight,
55
- scrollY: window.scrollY,
56
- innerHeight: window.innerHeight,
57
- });
48
+ const getPosition = (pos) => {
49
+ if (pos)
50
+ return pos;
51
+ // TODO: adding padding/margin to calculations
58
52
  if (box.y - window.scrollY > window.innerHeight * 0.6) {
59
- position = "above";
53
+ return "above";
60
54
  }
61
- else if (box.y - textHeight < window.scrollY &&
55
+ if (box.y - textHeight < window.scrollY &&
62
56
  box.y + box.height + textHeight >
63
57
  window.innerHeight + window.scrollY) {
64
58
  if (box.x + box.width + textWidth < window.innerWidth) {
65
- position = "right";
59
+ return "right";
66
60
  }
67
- else if (box.x - textWidth > 0) {
68
- position = "left";
61
+ if (box.x - textWidth > 0) {
62
+ return "left";
69
63
  }
70
64
  }
71
- else {
72
- position = "below";
73
- }
74
- }
65
+ return "below";
66
+ };
67
+ const position = getPosition(annotation.position);
75
68
  let labelPosition;
76
69
  switch (position) {
77
70
  case "above":
78
71
  labelPosition = {
79
72
  x: box.x + box.width / 2 - textWidth / 2,
80
- y: box.y - textHeight / 2,
73
+ y: box.y - textHeight / 2 - padding / 2 - margin,
81
74
  };
82
75
  break;
83
76
  case "left":
84
77
  labelPosition = {
85
- x: box.x - textWidth - padding * 2 - 5,
78
+ x: box.x - textWidth - padding - margin,
86
79
  y: box.y + box.height / 2 + textHeight / 2,
87
80
  };
88
81
  break;
89
82
  case "right":
90
83
  labelPosition = {
91
- x: box.x + box.width + padding * 2 + 5,
84
+ x: box.x + box.width + padding + margin,
92
85
  y: box.y + box.height / 2 + textHeight / 2,
93
86
  };
94
87
  break;
95
88
  default:
96
89
  labelPosition = {
97
90
  x: box.x + box.width / 2 - textWidth / 2,
98
- y: box.y + box.height + 20,
91
+ y: box.y + box.height + textHeight + padding + margin,
99
92
  };
100
93
  break;
101
94
  }
95
+ // Render arrow if enabled
96
+ if (annotation.showArrow) {
97
+ const arrowLabelEndX = position === "left"
98
+ ? labelPosition.x + textWidth + padding
99
+ : position === "right"
100
+ ? labelPosition.x - padding / 2
101
+ : // top or bottom
102
+ labelPosition.x + textWidth / 2;
103
+ const arrowLabelEndY = position === "above"
104
+ ? labelPosition.y + padding / 2
105
+ : position === "below"
106
+ ? labelPosition.y - textHeight - padding / 2
107
+ : // left or right
108
+ box.y + box.height / 2;
109
+ const arrowStartX = position === "left"
110
+ ? box.x
111
+ : position === "right"
112
+ ? box.x + box.width
113
+ : // top or bottom
114
+ box.x + box.width / 2;
115
+ const arrowStartY = position === "above"
116
+ ? box.y
117
+ : position === "below"
118
+ ? box.y + box.height
119
+ : // left or right
120
+ box.y + box.height / 2;
121
+ const arrowColor = annotation.arrowStrokeStyle ?? "rgba(255, 0, 0, 1)";
122
+ ctx.strokeStyle = arrowColor;
123
+ ctx.lineWidth = annotation.arrowLineWidth ?? 2;
124
+ ctx.beginPath();
125
+ ctx.moveTo(arrowLabelEndX, arrowLabelEndY);
126
+ ctx.lineTo(arrowStartX, arrowStartY);
127
+ ctx.stroke();
128
+ // Draw arrowhead
129
+ const angle = Math.atan2(arrowStartY - arrowLabelEndY, arrowStartX - arrowLabelEndX);
130
+ const headLength = (annotation.arrowLineWidth ?? 2) * 5; // Length of the arrowhead
131
+ ctx.fillStyle = arrowColor;
132
+ ctx.lineJoin = "round";
133
+ ctx.lineCap = "round";
134
+ ctx.beginPath();
135
+ ctx.moveTo(arrowStartX, arrowStartY);
136
+ ctx.lineTo(arrowStartX - headLength * Math.cos(angle - Math.PI / 6), arrowStartY - headLength * Math.sin(angle - Math.PI / 6));
137
+ ctx.lineTo(arrowStartX - headLength * Math.cos(angle + Math.PI / 6), arrowStartY - headLength * Math.sin(angle + Math.PI / 6));
138
+ ctx.closePath();
139
+ ctx.fill();
140
+ ctx.stroke();
141
+ ctx.resetTransform();
142
+ }
143
+ // Draw label box
102
144
  if (annotation.labelBoxFillStyle ||
103
145
  annotation.labelBoxStrokeStyle) {
104
146
  ctx.fillStyle =
@@ -106,8 +148,18 @@ export const screenshot = async (testInfo, target, { annotation, ...options } =
106
148
  ctx.strokeStyle =
107
149
  annotation.labelBoxStrokeStyle ?? "rgba(0, 0, 0, 0)";
108
150
  ctx.lineWidth = annotation.labelBoxLineWidth ?? 2;
109
- ctx.fillRect(labelPosition.x - padding, labelPosition.y - textHeight - padding, textWidth + padding * 2, textHeight + padding * 2);
151
+ const paddingBothSides = padding * 2;
152
+ const labelBoxX = labelPosition.x - padding;
153
+ const labelBoxY = labelPosition.y -
154
+ textHeight +
155
+ actualBoundingBoxDescent -
156
+ padding;
157
+ const labelBoxWidth = textWidth + paddingBothSides;
158
+ const labelBoxHeight = textHeight + paddingBothSides;
159
+ ctx.fillRect(labelBoxX, labelBoxY, labelBoxWidth, labelBoxHeight);
160
+ ctx.strokeRect(labelBoxX, labelBoxY, labelBoxWidth, labelBoxHeight);
110
161
  }
162
+ // Draw label text
111
163
  ctx.strokeStyle = annotation?.strokeStyle ?? "rgba(0, 0, 0, 0.1)";
112
164
  ctx.lineWidth = annotation?.lineWidth ?? 2;
113
165
  ctx.strokeText(annotation.text, labelPosition.x, labelPosition.y);
@@ -1 +1 @@
1
- {"version":3,"file":"screenshots.js","sourceRoot":"","sources":["../src/screenshots.ts"],"names":[],"mappings":"AAOA,IAAI,iBAAiB,GAAG,CAAC,CAAA;AAqBzB,MAAM,CAAC,MAAM,UAAU,GAAG,KAAK,EAC7B,QAAkB,EAClB,MAAsB,EACtB,EAAE,UAAU,EAAE,GAAG,OAAO,KAAwB,EAAE,EAClD,EAAE;IACF,MAAM,QAAQ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,CAAC,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,CAAA;YACnC,CAAC,EACD,EAAE,WAAW,EAAE,UAAU,EAAE,CAC5B,CAAA;YAED,UAAU,GAAG,MAAM,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,CAAA;YAE3C,kBAAkB;YAClB,MAAM,IAAI,CAAC,QAAQ,CAAC,GAAG,EAAE;gBACvB,MAAM,MAAM,GAAG,QAAQ,CAAC,cAAc,CAAC,2BAA2B,CAAC,CAAA;gBACnE,IAAI,MAAM;oBAAE,MAAM,CAAC,MAAM,EAAE,CAAA;YAC7B,CAAC,CAAC,CAAA;QACJ,CAAC;aAAM,CAAC;YACN,UAAU,GAAG,MAAM,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,CAAA;QAC7C,CAAC;IACH,CAAC;SAAM,CAAC;QACN,2BAA2B;QAC3B,UAAU,GAAG,MAAM,MAAM,CAAC,UAAU,CAAC,OAAO,CAAC,CAAA;IAC/C,CAAC;IAED,MAAM,QAAQ,CAAC,MAAM,CAAC,QAAQ,EAAE;QAC9B,IAAI,EAAE,UAAU;QAChB,WAAW,EAAE,WAAW;KACzB,CAAC,CAAA;AACJ,CAAC,CAAA"}
@@ -0,0 +1,10 @@
1
+ import type { AnnotationOptions } from "./screenshots.js";
2
+ export interface Test2DocConfig {
3
+ annotationDefaults?: Partial<AnnotationOptions>;
4
+ }
5
+ declare module "@playwright/test" {
6
+ interface PlaywrightTestOptions {
7
+ test2doc?: Test2DocConfig;
8
+ }
9
+ }
10
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAA;AAEzD,MAAM,WAAW,cAAc;IAC7B,kBAAkB,CAAC,EAAE,OAAO,CAAC,iBAAiB,CAAC,CAAA;CAChD;AAED,OAAO,QAAQ,kBAAkB,CAAC;IAChC,UAAU,qBAAqB;QAC7B,QAAQ,CAAC,EAAE,cAAc,CAAA;KAC1B;CACF"}
package/dist/types.js ADDED
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":""}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@test2doc/playwright",
3
- "version": "0.9.0",
3
+ "version": "0.11.0",
4
4
  "description": "A reporter that generates docs based off playwright test files",
5
5
  "keywords": [
6
6
  "documentation",
@@ -40,6 +40,11 @@
40
40
  "import": "./dist/screenshots.js",
41
41
  "require": "./dist/screenshots.js",
42
42
  "types": "./dist/screenshots.d.ts"
43
+ },
44
+ "./types": {
45
+ "types": "./dist/types.d.ts",
46
+ "import": "./dist/types.js",
47
+ "require": "./dist/types.js"
43
48
  }
44
49
  },
45
50
  "main": "dist/index.js",
@@ -60,17 +65,18 @@
60
65
  },
61
66
  "devDependencies": {
62
67
  "@playwright/test": "^1.55.0",
63
- "@types/node": "^24.0.4",
68
+ "@types/node": "^24.5.0",
64
69
  "typescript": "^5.9.2",
65
70
  "vitest": "^3.2.4"
66
71
  },
67
72
  "scripts": {
68
- "clean": "rm -rf dist",
73
+ "clean": "rm -rf dist && rm -rf tsconfig.tsbuildinfo",
69
74
  "build": "tsc --project tsconfig.json",
70
75
  "build:watch": "tsc --project tsconfig.json --watch",
71
- "test": "vitest run && pnpm int",
76
+ "test": "vitest run && pnpm int && pnpm int:a",
72
77
  "unit": "vitest",
73
78
  "int": "playwright test",
79
+ "int:a": "playwright test --config=playwright-annotation.config.ts",
74
80
  "lint": "biome lint .",
75
81
  "format": "biome format --write ."
76
82
  }