@test2doc/playwright 0.5.7 → 0.7.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 +109 -1
- package/package.json +7 -4
package/README.md
CHANGED
|
@@ -267,4 +267,112 @@ test.describe(withDocMeta("describe block"), async () => {
|
|
|
267
267
|
})
|
|
268
268
|
})
|
|
269
269
|
})
|
|
270
|
-
```
|
|
270
|
+
```
|
|
271
|
+
|
|
272
|
+
##### Add a label while highlighting an element
|
|
273
|
+
In case the highlight is not enough, you can add a label under the highlighted element.
|
|
274
|
+
|
|
275
|
+
```ts
|
|
276
|
+
import { screenshot } from "@test2doc/playwright/screenshots"
|
|
277
|
+
...
|
|
278
|
+
|
|
279
|
+
test.describe(withDocMeta("describe block"), async () => {
|
|
280
|
+
test("test block", async ({ page }, testInfo) => {
|
|
281
|
+
...
|
|
282
|
+
test.step("step block", async () => {
|
|
283
|
+
await page.goto("http://localhost:5173/")
|
|
284
|
+
await screenshot(
|
|
285
|
+
testInfo,
|
|
286
|
+
page.getByRole("header", {name: "Page Title"},
|
|
287
|
+
{ annotation: { text: "Heading of the Page" } }
|
|
288
|
+
))
|
|
289
|
+
})
|
|
290
|
+
})
|
|
291
|
+
})
|
|
292
|
+
```
|
|
293
|
+
|
|
294
|
+
##### Annotation Object Properties
|
|
295
|
+
To style the highlight and label we expose a few properties on the `annotation` object. They're named similar to the [Canvas 2D context](https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D), which is used to render the highlight and label.
|
|
296
|
+
|
|
297
|
+
- **`text`**:
|
|
298
|
+
- **Type**: `string`
|
|
299
|
+
- **Description**: The text to display for the label. This is the main content that will be rendered on the canvas.
|
|
300
|
+
- **Default**: `""` (empty string)
|
|
301
|
+
|
|
302
|
+
- **`fillStyle`**:
|
|
303
|
+
- **Type**: `string`
|
|
304
|
+
- **Description**: The color of the label text. Accepts any valid CSS color value, including hex codes, RGB, RGBA, HSL, or HSLA.
|
|
305
|
+
- **Default**: `rgba(0, 0, 0, 1)` (black)
|
|
306
|
+
|
|
307
|
+
- **`font`**:
|
|
308
|
+
- **Type**: `string`
|
|
309
|
+
- **Description**: Specifies the font size, font-weight, and family for the label text. Follows the CSS font property syntax (e.g., `"16px Arial"`).
|
|
310
|
+
- **Default**: `"14px Arial"`
|
|
311
|
+
|
|
312
|
+
- **`strokeStyle`**:
|
|
313
|
+
- **Type**: `string`
|
|
314
|
+
- **Description**: The color of the outline around the label text. Accepts any valid CSS color value.
|
|
315
|
+
- **Default**: `rgba(0, 0, 0, 0.1)` (light black)
|
|
316
|
+
|
|
317
|
+
- **`lineWidth`**:
|
|
318
|
+
- **Type**: `number`
|
|
319
|
+
- **Description**: The thickness of the outline around the label text.
|
|
320
|
+
- **Default**: `2`
|
|
321
|
+
|
|
322
|
+
- **`labelBoxFillStyle`**:
|
|
323
|
+
- **Type**: `string`
|
|
324
|
+
- **Description**: The fill color of the label box surrounding the annotation text. Accepts any valid CSS color value, including hex codes, RGB, RGBA, HSL, or HSLA.
|
|
325
|
+
- **Default**: `rgba(0, 0, 0, 0)` (transparent)
|
|
326
|
+
|
|
327
|
+
- **`labelBoxStrokeStyle`**:
|
|
328
|
+
- **Type**: `string`
|
|
329
|
+
- **Description**: The border color of the label box. Similar to `labelBoxFillStyle`, this property accepts any valid CSS color value.
|
|
330
|
+
- **Default**: `rgba(0, 0, 0, 0)` (transparent)
|
|
331
|
+
|
|
332
|
+
- **`labelBoxLineWidth`**:
|
|
333
|
+
- **Type**: `number`
|
|
334
|
+
- **Description**: The width of the border for the label box. This property determines how thick the outline of the label box will be.
|
|
335
|
+
- **Default**: `2`
|
|
336
|
+
|
|
337
|
+
- **`highlightFillStyle`**:
|
|
338
|
+
- **Type**: `string`
|
|
339
|
+
- **Description**: The fill color of the highlight box. Accepts any valid CSS color value. **Make sure to add some transparency (`rgba()`, `hsla()`, or 8-digit hex format like `#FF000080`) else it will block the element entirely.**
|
|
340
|
+
- **Default**: `rgba(255, 165, 0, 0.3)` (orange with 30% transparency)
|
|
341
|
+
|
|
342
|
+
- **`highlightStrokeStyle`**:
|
|
343
|
+
- **Type**: `string`
|
|
344
|
+
- **Description**: The border color of the highlight box. Accepts any valid CSS color value.
|
|
345
|
+
- **Default**: `rgba(255, 165, 0, 1)` (solid orange)
|
|
346
|
+
|
|
347
|
+
- **`highlightLineWidth`**:
|
|
348
|
+
- **Type**: `number`
|
|
349
|
+
- **Description**: The width of the border for the highlight box.
|
|
350
|
+
- **Default**: `2`
|
|
351
|
+
|
|
352
|
+
```ts
|
|
353
|
+
test.describe(withDocMeta("describe block"), async () => {
|
|
354
|
+
test("test block", async ({ page }, testInfo) => {
|
|
355
|
+
...
|
|
356
|
+
test.step("step block", async () => {
|
|
357
|
+
await page.goto("http://localhost:5173/")
|
|
358
|
+
await screenshot(
|
|
359
|
+
testInfo,
|
|
360
|
+
page.getByRole("header", {name: "Page Title"},
|
|
361
|
+
{ annotation: {
|
|
362
|
+
text: "Heading of the Page",
|
|
363
|
+
fillStyle: "rgba(255, 255, 255, 1)",
|
|
364
|
+
font: "bold 16px Helvetica",
|
|
365
|
+
strokeStyle: "rgba(0, 0, 0, 0.5)",
|
|
366
|
+
lineWidth: 4,
|
|
367
|
+
labelBoxFillStyle: "rgba(0, 120, 120, 0.3)",
|
|
368
|
+
labelBoxStrokeStyle: "rgba(0, 255, 0, 1)",
|
|
369
|
+
labelBoxLineWidth: 2,
|
|
370
|
+
highlightFillStyle: "rgba(255, 165, 0, 0.3)",
|
|
371
|
+
highlightStrokeStyle: "#FFA500",
|
|
372
|
+
highlightLineWidth: 2,
|
|
373
|
+
}}
|
|
374
|
+
))
|
|
375
|
+
})
|
|
376
|
+
})
|
|
377
|
+
})
|
|
378
|
+
```
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@test2doc/playwright",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.0",
|
|
4
4
|
"description": "A reporter that generates docs based off playwright test files",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"documentation",
|
|
@@ -59,14 +59,17 @@
|
|
|
59
59
|
"@playwright/test": "^1.54.1"
|
|
60
60
|
},
|
|
61
61
|
"devDependencies": {
|
|
62
|
-
"
|
|
63
|
-
"@types/node": "^24.0.4"
|
|
62
|
+
"@playwright/test": "^1.55.0",
|
|
63
|
+
"@types/node": "^24.0.4",
|
|
64
|
+
"vitest": "^3.2.4"
|
|
64
65
|
},
|
|
65
66
|
"scripts": {
|
|
66
67
|
"clean": "rm -rf dist",
|
|
67
68
|
"build": "tsc --project tsconfig.json",
|
|
68
69
|
"build:watch": "tsc --project tsconfig.json --watch",
|
|
69
|
-
"test": "vitest",
|
|
70
|
+
"test": "vitest run && pnpm int",
|
|
71
|
+
"unit": "vitest",
|
|
72
|
+
"int": "playwright test",
|
|
70
73
|
"lint": "biome lint .",
|
|
71
74
|
"format": "biome format --write ."
|
|
72
75
|
}
|