Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

happo-cypress

Package Overview
Dependencies
Maintainers
1
Versions
73
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

happo-cypress - npm Package Compare versions

Comparing version 1.2.0 to 1.3.0

.next/cache/next-babel-loader/0b8bd0c1994ab1e91ee58c2029c963fe.json

2

.next/static/runtime/webpack.js

@@ -116,3 +116,3 @@ /******/ (function(modules) { // webpackBootstrap

/******/ // eslint-disable-next-line no-unused-vars
/******/ var hotCurrentHash = "fffc3a5f630a31e3e4cc";
/******/ var hotCurrentHash = "037806a7ee2d6669476a";
/******/ var hotRequestTimeout = 10000;

@@ -119,0 +119,0 @@ /******/ var hotCurrentModuleData = {};

@@ -49,4 +49,4 @@ const crypto = require('crypto');

const allUrls = [];
const allElements = [subject[0]].concat(
Array.from(subject[0].querySelectorAll('*')),
const allElements = [subject].concat(
Array.from(subject.querySelectorAll('*')),
);

@@ -71,10 +71,52 @@ allElements.forEach(element => {

function inlineCanvases(doc, subject) {
const canvases = [];
if (subject.tagName === 'CANVAS') {
canvases.push(subject);
}
canvases.push(...Array.from(subject.querySelectorAll('canvas')));
let newSubject = subject;
const replacements = [];
for (const canvas of canvases) {
const image = doc.createElement('img');
try {
const canvasImageBase64 = canvas.toDataURL('image/png');
image.src = canvasImageBase64;
const style = window.getComputedStyle(canvas, '');
image.style.cssText = style.cssText;
canvas.replaceWith(image);
if (canvas === subject) {
// We're inlining the subject (the `cy.get('canvas')` element). Make sure
// we return the modified subject.
newSubject = image;
}
replacements.push({ from: canvas, to: image });
} catch (e) {
if (e.name === 'SecurityError') {
console.warn('[HAPPO] Failed to convert tainted canvas to PNG image');
console.warn(e);
} else {
throw e;
}
}
}
function cleanup() {
for (const { from, to } of replacements) {
to.replaceWith(from);
}
}
return { subject: newSubject, cleanup };
}
Cypress.Commands.add(
'happoScreenshot',
{ prevSubject: true },
(subject, options = {}) => {
(originalSubject, options = {}) => {
const component = options.component || cy.state('runnable').fullTitle();
const variant = options.variant || 'default';
cy.document().then(doc => {
const html = subject.prop('outerHTML');
const { subject, cleanup } = inlineCanvases(doc, originalSubject[0]);
const html = subject.outerHTML;
const assetUrls = getSubjectAssetUrls(subject, doc);

@@ -90,4 +132,5 @@ const cssBlocks = extractCSSBlocks({ doc });

});
cleanup();
});
},
);
{
"name": "happo-cypress",
"version": "1.2.0",
"version": "1.3.0",
"description": "A Happo integration with Cypress.io",

@@ -5,0 +5,0 @@ "main": "index.js",

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc