screenright-client 0.9.6 → 0.9.7

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/dist/index.d.ts CHANGED
@@ -1,4 +1,11 @@
1
1
  import { Page } from '@playwright/test';
2
2
  export declare const initializeScreenwright: () => Promise<void>;
3
3
  export declare const finalize: () => Promise<void>;
4
+ /**
5
+ * Get screen capture.
6
+ * @param {Page} page - Playwright's page object.
7
+ * @param {string} key - Unique key. cannot contain slashes.
8
+ * @param {string} title - Page title.
9
+ * @param {string|null} [parentKey] - Parent page key. Creates a hierarchical structure.
10
+ */
4
11
  export declare const capture: (page: Page, key: string, title: string, parentKey?: string) => Promise<void>;
package/dist/index.js CHANGED
@@ -55,10 +55,21 @@ export const finalize = () => __awaiter(void 0, void 0, void 0, function* () {
55
55
  });
56
56
  deploymentId = null;
57
57
  });
58
+ /**
59
+ * Get screen capture.
60
+ * @param {Page} page - Playwright's page object.
61
+ * @param {string} key - Unique key. cannot contain slashes.
62
+ * @param {string} title - Page title.
63
+ * @param {string|null} [parentKey] - Parent page key. Creates a hierarchical structure.
64
+ */
58
65
  export const capture = (page, key, title, parentKey) => __awaiter(void 0, void 0, void 0, function* () {
59
66
  if (deploymentId === null) {
60
67
  return;
61
68
  }
69
+ if (0 <= key.indexOf('/')) {
70
+ errorOccurred('Capture argument[key] cannot contain slashes.');
71
+ return;
72
+ }
62
73
  const fileName = `${key}.jpg`;
63
74
  try {
64
75
  const buffer = yield page.screenshot({ fullPage: true, type: 'jpeg' });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "screenright-client",
3
- "version": "0.9.6",
3
+ "version": "0.9.7",
4
4
  "description": "screenright's nodejs client library",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
package/src/index.ts CHANGED
@@ -71,6 +71,13 @@ export const finalize = async () => {
71
71
  deploymentId = null
72
72
  }
73
73
 
74
+ /**
75
+ * Get screen capture.
76
+ * @param {Page} page - Playwright's page object.
77
+ * @param {string} key - Unique key. cannot contain slashes.
78
+ * @param {string} title - Page title.
79
+ * @param {string|null} [parentKey] - Parent page key. Creates a hierarchical structure.
80
+ */
74
81
  export const capture = async (
75
82
  page: Page,
76
83
  key: string,
@@ -81,6 +88,11 @@ export const capture = async (
81
88
  return
82
89
  }
83
90
 
91
+ if (0 <= key.indexOf('/')) {
92
+ errorOccurred('Capture argument[key] cannot contain slashes.')
93
+ return
94
+ }
95
+
84
96
  const fileName = `${key}.jpg`
85
97
  try {
86
98
  const buffer = await page.screenshot({ fullPage: true, type: 'jpeg' })