@test2doc/playwright 0.3.3 → 0.4.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 +18 -0
- package/dist/screenshots.d.ts.map +1 -1
- package/dist/screenshots.js +17 -2
- package/dist/screenshots.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -179,4 +179,22 @@ test.describe(withDocMeta("describe block"), async () => {
|
|
|
179
179
|
})
|
|
180
180
|
})
|
|
181
181
|
})
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
#### Highlight an element
|
|
185
|
+
It's possible to highlight an element by passing in a locator of an element on the page.
|
|
186
|
+
|
|
187
|
+
```ts
|
|
188
|
+
import { screenshot } from "@test2doc/playwright/screenshots"
|
|
189
|
+
...
|
|
190
|
+
|
|
191
|
+
test.describe(withDocMeta("describe block"), async () => {
|
|
192
|
+
test("test block", async ({ page }, testInfo) => {
|
|
193
|
+
...
|
|
194
|
+
test.step("step block", async () => {
|
|
195
|
+
await page.goto("http://localhost:5173/")
|
|
196
|
+
await screenshot(testInfo, page.getByRole("header", {name: "Page Title"}))
|
|
197
|
+
})
|
|
198
|
+
})
|
|
199
|
+
})
|
|
182
200
|
```
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"screenshots.d.ts","sourceRoot":"","sources":["../src/screenshots.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,OAAO,EACP,IAAI,EACJ,qCAAqC,EACrC,qBAAqB,EACrB,QAAQ,EACT,MAAM,kBAAkB,CAAA;AAIzB,eAAO,MAAM,UAAU,GACrB,UAAU,QAAQ,EAClB,QAAQ,IAAI,GAAG,OAAO,EACtB,UAAU,qBAAqB,GAAG,qCAAqC,
|
|
1
|
+
{"version":3,"file":"screenshots.d.ts","sourceRoot":"","sources":["../src/screenshots.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,OAAO,EACP,IAAI,EACJ,qCAAqC,EACrC,qBAAqB,EACrB,QAAQ,EACT,MAAM,kBAAkB,CAAA;AAIzB,eAAO,MAAM,UAAU,GACrB,UAAU,QAAQ,EAClB,QAAQ,IAAI,GAAG,OAAO,EACtB,UAAU,qBAAqB,GAAG,qCAAqC,kBA0BxE,CAAA"}
|
package/dist/screenshots.js
CHANGED
|
@@ -1,9 +1,24 @@
|
|
|
1
1
|
let screenshotCounter = 0;
|
|
2
2
|
export const screenshot = async (testInfo, target, options) => {
|
|
3
3
|
const filename = `test2doc-${Date.now()}-${++screenshotCounter}.png`;
|
|
4
|
-
|
|
4
|
+
let screenshot;
|
|
5
|
+
if ("highlight" in target) {
|
|
6
|
+
// Target is a locator - highlight it first, then get its page
|
|
7
|
+
await target.highlight();
|
|
8
|
+
const page = target.page();
|
|
9
|
+
screenshot = await page.screenshot(options);
|
|
10
|
+
// Remove highlighting after taking the screenshot
|
|
11
|
+
const glassElements = page.locator("X-PW-GLASS");
|
|
12
|
+
await glassElements.evaluateAll((elements) => {
|
|
13
|
+
elements.forEach((el) => el.remove());
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
else {
|
|
17
|
+
// Target is already a page
|
|
18
|
+
screenshot = await target.screenshot(options);
|
|
19
|
+
}
|
|
5
20
|
await testInfo.attach(filename, {
|
|
6
|
-
body:
|
|
21
|
+
body: screenshot,
|
|
7
22
|
contentType: "image/png",
|
|
8
23
|
});
|
|
9
24
|
};
|
package/dist/screenshots.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"screenshots.js","sourceRoot":"","sources":["../src/screenshots.ts"],"names":[],"mappings":"AAQA,IAAI,iBAAiB,GAAG,CAAC,CAAA;AAEzB,MAAM,CAAC,MAAM,UAAU,GAAG,KAAK,EAC7B,QAAkB,EAClB,MAAsB,EACtB,OAAuE,EACvE,EAAE;IACF,MAAM,QAAQ,GAAG,YAAY,IAAI,CAAC,GAAG,EAAE,IAAI,EAAE,iBAAiB,MAAM,CAAA;
|
|
1
|
+
{"version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