📅 You're Invited: Meet the Socket team at RSAC (April 28 – May 1).RSVP
Socket
Sign inDemoInstall
Socket

@web/test-runner-visual-regression

Package Overview
Dependencies
Maintainers
0
Versions
42
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@web/test-runner-visual-regression - npm Package Compare versions

Comparing version

to
0.10.0

12

dist/config.js

@@ -9,7 +9,7 @@ "use strict";

const mkdirp_1 = __importDefault(require("mkdirp"));
const fs_1 = require("./fs");
const pixelMatchDiff_1 = require("./pixelMatchDiff");
const fs_js_1 = require("./fs.js");
const pixelMatchDiff_js_1 = require("./pixelMatchDiff.js");
async function getImage({ filePath }) {
if (await (0, fs_1.fileExists)(filePath)) {
return (0, fs_1.readFile)(filePath);
if (await (0, fs_js_1.fileExists)(filePath)) {
return (0, fs_js_1.readFile)(filePath);
}

@@ -19,3 +19,3 @@ }

await (0, mkdirp_1.default)(path_1.default.dirname(filePath));
await (0, fs_1.writeFile)(filePath, content);
await (0, fs_js_1.writeFile)(filePath, content);
}

@@ -36,4 +36,4 @@ exports.defaultOptions = {

saveFailed: saveImage,
getImageDiff: pixelMatchDiff_1.pixelMatchDiff,
getImageDiff: pixelMatchDiff_js_1.pixelMatchDiff,
};
//# sourceMappingURL=config.js.map

@@ -1,2 +0,2 @@

export { visualRegressionPlugin } from './visualRegressionPlugin';
export { visualRegressionPlugin } from './visualRegressionPlugin.js';
//# sourceMappingURL=index.d.ts.map
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.visualRegressionPlugin = void 0;
var visualRegressionPlugin_1 = require("./visualRegressionPlugin");
Object.defineProperty(exports, "visualRegressionPlugin", { enumerable: true, get: function () { return visualRegressionPlugin_1.visualRegressionPlugin; } });
var visualRegressionPlugin_js_1 = require("./visualRegressionPlugin.js");
Object.defineProperty(exports, "visualRegressionPlugin", { enumerable: true, get: function () { return visualRegressionPlugin_js_1.visualRegressionPlugin; } });
//# sourceMappingURL=index.js.map

@@ -1,3 +0,3 @@

import { DiffArgs, DiffResult } from './config';
import { DiffArgs, DiffResult } from './config.js';
export declare function pixelMatchDiff({ baselineImage, image, options }: DiffArgs): DiffResult;
//# sourceMappingURL=pixelMatchDiff.d.ts.map
/// <reference types="node" />
import { VisualRegressionPluginOptions } from './config';
import { VisualRegressionPluginOptions } from './config.js';
export interface VisualDiffCommandResult {

@@ -4,0 +4,0 @@ errorMessage?: string;

@@ -8,3 +8,3 @@ "use strict";

const path_1 = __importDefault(require("path"));
const VisualRegressionError_1 = require("./VisualRegressionError");
const VisualRegressionError_js_1 = require("./VisualRegressionError.js");
function resolveImagePath(baseDir, name) {

@@ -33,3 +33,3 @@ const finalName = path_1.default.extname(name) ? name : `${name}.png`;

}
throw new VisualRegressionError_1.VisualRegressionError(`Unrecognized failureThresholdType: ${failureThresholdType}`);
throw new VisualRegressionError_js_1.VisualRegressionError(`Unrecognized failureThresholdType: ${failureThresholdType}`);
}

@@ -36,0 +36,0 @@ async function visualDiffCommand(options, image, name, { browser, testFile }) {

import { TestRunnerPlugin } from '@web/test-runner-core';
import { VisualRegressionPluginOptions } from './config';
import { VisualRegressionPluginOptions } from './config.js';
export declare function visualRegressionPlugin(options?: Partial<VisualRegressionPluginOptions>): TestRunnerPlugin;
//# sourceMappingURL=visualRegressionPlugin.d.ts.map
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.visualRegressionPlugin = void 0;
const config_1 = require("./config");
const visualDiffCommand_1 = require("./visualDiffCommand");
const VisualRegressionError_1 = require("./VisualRegressionError");
const config_js_1 = require("./config.js");
const visualDiffCommand_js_1 = require("./visualDiffCommand.js");
const VisualRegressionError_js_1 = require("./VisualRegressionError.js");
function validatePayload(payload) {

@@ -20,3 +20,3 @@ if (payload == null || typeof payload !== 'object') {

function visualRegressionPlugin(options = {}) {
const mergedOptions = Object.assign(Object.assign(Object.assign({}, config_1.defaultOptions), options), { diffOptions: Object.assign(Object.assign({}, config_1.defaultOptions.diffOptions), options.diffOptions) });
const mergedOptions = Object.assign(Object.assign(Object.assign({}, config_js_1.defaultOptions), options), { diffOptions: Object.assign(Object.assign({}, config_js_1.defaultOptions.diffOptions), options.diffOptions) });
return {

@@ -44,6 +44,6 @@ name: 'visual-regression',

if (!element) {
throw new VisualRegressionError_1.VisualRegressionError('Something went wrong diffing element, the browser could not find it.');
throw new VisualRegressionError_js_1.VisualRegressionError('Something went wrong diffing element, the browser could not find it.');
}
const screenshot = (await element.screenshot({ encoding: 'binary' }));
return (0, visualDiffCommand_1.visualDiffCommand)(mergedOptions, screenshot, payload.name, context);
const screenshot = await element.screenshot({ encoding: 'binary' });
return (0, visualDiffCommand_js_1.visualDiffCommand)(mergedOptions, Buffer.from(screenshot), payload.name, context);
}

@@ -59,6 +59,6 @@ if (session.browser.type === 'playwright') {

if (!element) {
throw new VisualRegressionError_1.VisualRegressionError('Something went wrong diffing element, the browser could not find it.');
throw new VisualRegressionError_js_1.VisualRegressionError('Something went wrong diffing element, the browser could not find it.');
}
const screenshot = await element.screenshot();
return (0, visualDiffCommand_1.visualDiffCommand)(mergedOptions, screenshot, payload.name, context);
return (0, visualDiffCommand_js_1.visualDiffCommand)(mergedOptions, screenshot, payload.name, context);
}

@@ -78,3 +78,3 @@ if (session.browser.type === 'webdriver') {

const screenshot = await browser.takeScreenshot(session.id, locator);
return (0, visualDiffCommand_1.visualDiffCommand)(mergedOptions, screenshot, payload.name, context);
return (0, visualDiffCommand_js_1.visualDiffCommand)(mergedOptions, screenshot, payload.name, context);
}

@@ -84,3 +84,3 @@ throw new Error(`Browser type ${session.browser.type} is not supported for visual diffing.`);

catch (error) {
if (error instanceof VisualRegressionError_1.VisualRegressionError) {
if (error instanceof VisualRegressionError_js_1.VisualRegressionError) {
return {

@@ -87,0 +87,0 @@ errorMessage: `Something went wrong while executing creating visual diff: ${error.message}`,

// this file is autogenerated with the generate-mjs-dts-entrypoints script
export * from './browser/commands';
export * from './browser/commands.mjs';
{
"name": "@web/test-runner-visual-regression",
"version": "0.9.0",
"version": "0.10.0",
"publishConfig": {

@@ -33,3 +33,3 @@ "access": "public"

"build": "tsc",
"test": "mocha test/**/*.test.ts --require ts-node/register",
"test:node": "mocha test/**/*.test.ts --require ts-node/register --reporter dot",
"test:watch": "mocha test/**/*.test.ts --require ts-node/register --watch --watch-files src,test"

@@ -63,3 +63,3 @@ },

"devDependencies": {
"@web/test-runner-chrome": "^0.15.0",
"@web/test-runner-chrome": "^0.17.0",
"@web/test-runner-playwright": "^0.11.0",

@@ -66,0 +66,0 @@ "@web/test-runner-webdriver": "^0.8.0",

// this file is autogenerated with the generate-mjs-dts-entrypoints script
export * from './dist/index';
export * from './dist/index.js';

@@ -5,4 +5,4 @@ import path from 'path';

import { readFile, writeFile, fileExists } from './fs';
import { pixelMatchDiff } from './pixelMatchDiff';
import { readFile, writeFile, fileExists } from './fs.js';
import { pixelMatchDiff } from './pixelMatchDiff.js';

@@ -9,0 +9,0 @@ type PixelMatchParams = Parameters<typeof pixelmatch>;

@@ -1,1 +0,1 @@

export { visualRegressionPlugin } from './visualRegressionPlugin';
export { visualRegressionPlugin } from './visualRegressionPlugin.js';
import pixelmatch from 'pixelmatch';
import { PNG, PNGWithMetadata } from 'pngjs';
import { DiffArgs, DiffResult } from './config';
import { DiffArgs, DiffResult } from './config.js';

@@ -6,0 +6,0 @@ export function pixelMatchDiff({ baselineImage, image, options }: DiffArgs): DiffResult {

import path from 'path';
import { VisualRegressionPluginOptions, DiffResult } from './config';
import { VisualRegressionError } from './VisualRegressionError';
import { VisualRegressionPluginOptions, DiffResult } from './config.js';
import { VisualRegressionError } from './VisualRegressionError.js';

@@ -6,0 +6,0 @@ function resolveImagePath(baseDir: string, name: string) {

@@ -6,3 +6,3 @@ import { TestRunnerPlugin } from '@web/test-runner-core';

import { defaultOptions, VisualRegressionPluginOptions } from './config';
import { defaultOptions, VisualRegressionPluginOptions } from './config.js';
import {

@@ -12,4 +12,4 @@ visualDiffCommand,

VisualDiffCommandResult,
} from './visualDiffCommand';
import { VisualRegressionError } from './VisualRegressionError';
} from './visualDiffCommand.js';
import { VisualRegressionError } from './VisualRegressionError.js';

@@ -81,4 +81,4 @@ interface Payload {

const screenshot = (await element.screenshot({ encoding: 'binary' })) as Buffer;
return visualDiffCommand(mergedOptions, screenshot, payload.name, context);
const screenshot = await element.screenshot({ encoding: 'binary' });
return visualDiffCommand(mergedOptions, Buffer.from(screenshot), payload.name, context);
}

@@ -85,0 +85,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet