vita-playwright 1.2.4 → 1.2.6
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 +26 -1
- package/package.json +1 -1
- package/src/utils/pdf_utility.ts +0 -14
package/README.md
CHANGED
|
@@ -79,7 +79,7 @@ const postResponse = await ApiHelper.post(url, header, payload);
|
|
|
79
79
|
* @description: Post call with endpoint, headers and data.
|
|
80
80
|
* @param {string} apiEndPoint - API end point.
|
|
81
81
|
* @param {string} headers - headers contains authentication keys, application type etc..
|
|
82
|
-
* @param {string} payload - payload data
|
|
82
|
+
* @param {json/string} payload - payload data
|
|
83
83
|
* @returns {Promise<reponse>} - returns Promise of reponse
|
|
84
84
|
*/
|
|
85
85
|
import { ApiHelper } from "vita-playwright";
|
|
@@ -480,6 +480,28 @@ static async auditLightHouse(pageurl: string, deviceType, filename, customThresh
|
|
|
480
480
|
seo: 70,
|
|
481
481
|
pwa: 70,
|
|
482
482
|
}, format = { html: true })
|
|
483
|
+
|
|
484
|
+
//"Usage with new browser context:"
|
|
485
|
+
test("light house testing "+vurl, async ({ page }) => {
|
|
486
|
+
const browser = await playwright['chromium'].launch({
|
|
487
|
+
args: ['--start-maximized', '--remote-debugging-port=9222'],
|
|
488
|
+
channel:'chrome'
|
|
489
|
+
});
|
|
490
|
+
const context = await browser.newContext();
|
|
491
|
+
const page = await context.newPage();
|
|
492
|
+
page.goto(url);
|
|
493
|
+
await LightHouseUtility.auditLightHouse(url, "desktop", url.split('/').join('_')+'.html');
|
|
494
|
+
});
|
|
495
|
+
|
|
496
|
+
//"Usage with default playwright page:"
|
|
497
|
+
//Please set port in playwright.config.ts
|
|
498
|
+
args: ['--start-maximized','--remote-debugging-port=9222']
|
|
499
|
+
|
|
500
|
+
//calling auditLightHouse from test
|
|
501
|
+
test("light house testing " + url, async ({ page }) => {
|
|
502
|
+
page.goto(url);
|
|
503
|
+
await LightHouseUtility.auditLightHouse(url, "desktop", url.split('/').join('_')+'.html');
|
|
504
|
+
});
|
|
483
505
|
```
|
|
484
506
|
#### createLightHouseReport
|
|
485
507
|
```ts
|
|
@@ -491,6 +513,9 @@ static async auditLightHouse(pageurl: string, deviceType, filename, customThresh
|
|
|
491
513
|
* @returns {Promise<void>} - returns void promise.
|
|
492
514
|
*/
|
|
493
515
|
static async createLightHouseReport(filePath: string, sheetname: string)
|
|
516
|
+
|
|
517
|
+
//Usage:
|
|
518
|
+
await LightHouseUtility.createLightHouseReport(process.cwd() + '/lighthouse/pages', process.cwd() + '/lighthouse/index.html', applicationName);
|
|
494
519
|
```
|
|
495
520
|
|
|
496
521
|
### Date Utilities
|
package/package.json
CHANGED
package/src/utils/pdf_utility.ts
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { PdfReader } from "pdfreader";
|
|
2
|
-
export class PDFUtility {
|
|
3
|
-
|
|
4
|
-
static async readPdfFile(filePath: string) {
|
|
5
|
-
const items = [];
|
|
6
|
-
return new Promise((resolve, reject) => {
|
|
7
|
-
new PdfReader().parseFileItems(filePath, (err, item) => {
|
|
8
|
-
if (err) reject(err);
|
|
9
|
-
else if (!item) resolve(items);
|
|
10
|
-
else if (item.text) items.push(item.text);
|
|
11
|
-
});
|
|
12
|
-
});
|
|
13
|
-
}
|
|
14
|
-
}
|