@cloudscape-design/browser-test-tools 3.0.0 → 3.0.3
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
|
@@ -18,4 +18,4 @@ The [contribution guidelines](https://github.com/cloudscape-design/browser-test-
|
|
|
18
18
|
|
|
19
19
|
## License
|
|
20
20
|
|
|
21
|
-
This project is licensed under the [Apache 2.0 License](/LICENSE).
|
|
21
|
+
This project is licensed under the [Apache 2.0 License](https://github.com/cloudscape-design/browser-test-tools/blob/main/LICENSE).
|
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
-
import {
|
|
2
|
+
import { PNG } from 'pngjs';
|
|
3
|
+
import { ElementSize, ScreenshotWithOffset } from '../page-objects/types';
|
|
4
|
+
export declare function compareImages(firstImage: PNG, secondImage: PNG, { width, height }: ElementSize): {
|
|
5
|
+
diffPixels: number;
|
|
6
|
+
diffImage: null;
|
|
7
|
+
} | {
|
|
8
|
+
diffPixels: number;
|
|
9
|
+
diffImage: PNG;
|
|
10
|
+
};
|
|
3
11
|
export interface CropAndCompareResult {
|
|
4
12
|
firstImage: Buffer;
|
|
5
13
|
secondImage: Buffer;
|
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.cropAndCompare = void 0;
|
|
6
|
+
exports.cropAndCompare = exports.compareImages = void 0;
|
|
7
7
|
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
8
8
|
// SPDX-License-Identifier: Apache-2.0
|
|
9
9
|
const pngjs_1 = require("pngjs");
|
|
@@ -18,6 +18,7 @@ function compareImages(firstImage, secondImage, { width, height }) {
|
|
|
18
18
|
const diffPixels = (0, pixelmatch_1.default)(firstImage.data, secondImage.data, diffImage.data, width, height, { threshold: 0.01 });
|
|
19
19
|
return { diffPixels, diffImage };
|
|
20
20
|
}
|
|
21
|
+
exports.compareImages = compareImages;
|
|
21
22
|
function normalizeSize(firstScreenshot, secondScreenshot) {
|
|
22
23
|
return {
|
|
23
24
|
height: Math.round(Math.max(firstScreenshot.height, secondScreenshot.height)),
|
|
@@ -1,2 +1,5 @@
|
|
|
1
1
|
/// <reference types="webdriverio/async" />
|
|
2
|
+
import type { Browser as PuppeteerBrowser } from 'puppeteer-core';
|
|
3
|
+
export declare function scrollAndMergeStrategy(browser: WebdriverIO.Browser): Promise<string>;
|
|
2
4
|
export default function fullPageScreenshot(browser: WebdriverIO.Browser): Promise<string>;
|
|
5
|
+
export declare function puppeteerStrategy(browser: WebdriverIO.Browser, puppeteer: PuppeteerBrowser): Promise<string>;
|
|
@@ -3,6 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.puppeteerStrategy = exports.scrollAndMergeStrategy = void 0;
|
|
6
7
|
const browser_scripts_1 = require("../browser-scripts");
|
|
7
8
|
const merge_1 = __importDefault(require("../image-utils/merge"));
|
|
8
9
|
const browser_scripts_2 = require("./browser-scripts");
|
|
@@ -41,6 +42,7 @@ async function scrollAndMergeStrategy(browser) {
|
|
|
41
42
|
}
|
|
42
43
|
return (0, merge_1.default)(screenshots, width * pixelRatio, height * pixelRatio, lastImageOffset * pixelRatio, offsetTop);
|
|
43
44
|
}
|
|
45
|
+
exports.scrollAndMergeStrategy = scrollAndMergeStrategy;
|
|
44
46
|
async function fullPageScreenshot(browser) {
|
|
45
47
|
const puppeteer = await (0, utils_1.getPuppeteer)(browser);
|
|
46
48
|
if (puppeteer) {
|
|
@@ -64,3 +66,4 @@ async function puppeteerStrategy(browser, puppeteer) {
|
|
|
64
66
|
// See: https://pptr.dev/#?product=Puppeteer&version=v13.2.0&show=api-pagescreenshotoptions
|
|
65
67
|
return image;
|
|
66
68
|
}
|
|
69
|
+
exports.puppeteerStrategy = puppeteerStrategy;
|
package/package.json
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
"url": "https://github.com/cloudscape-design/browser-test-tools/issues"
|
|
4
4
|
},
|
|
5
5
|
"bundleDependencies": false,
|
|
6
|
+
"commit": "5e3c4fb",
|
|
6
7
|
"dependencies": {
|
|
7
8
|
"@types/pngjs": "^6.0.1",
|
|
8
9
|
"aws-sdk": "^2.1140.0",
|
|
@@ -58,6 +59,6 @@
|
|
|
58
59
|
"type": "git",
|
|
59
60
|
"url": "git+https://github.com/cloudscape-design/browser-test-tools.git"
|
|
60
61
|
},
|
|
61
|
-
"version": "3.0.
|
|
62
|
+
"version": "3.0.3",
|
|
62
63
|
"license": "Apache-2.0"
|
|
63
|
-
}
|
|
64
|
+
}
|