New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@bitovi/snapshot-test

Package Overview
Dependencies
Maintainers
3
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@bitovi/snapshot-test

Visual snapshot testing for everyone

  • 0.0.3
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
decreased by-100%
Maintainers
3
Weekly downloads
 
Created
Source

@bitovi/snapshot-test

Take an image of an iframe and compare it to a saved image.

import {compareToSnapshot} from "@bitovi/snapshot-test";

compareToSnapshot({
	// A URL you want to test against.
	// Must be same domain.
	url: "./style-guide.html",

	// The width and height of an iframe used
	// to load the URL. The <body> will be rendered.
	// So if your <body> is greater than `height`
	// an image of that size will be created.
	width: 1000, // defaults to 1000
	height: 400, // defaults to 400

	// The path to where to keep your saved images.
	snapshotDir: "./",

	// An identifier used to figure out the saved
	// image's path.
	//
	// For example, if the tests were running in google `chrome`
	// on a `high definition` display, an image would be looked
	// in the following places:
	//
	// 1. style-guide-1000-hd-chrome.png
	// 2. style-guide-1000-hd.png
	// 3. style-guide.png
	snapshotPrefix: "style-guide",

	// This function is called after the iframe has loaded.
	// You can make adjustments to the document before the snapshot
	// is taken. This function should return a promise when
	// the snapshot is ready to be taken.
	prepareDocument(iframe) { return Promise },

	// Options passed to pixelmatch that does the diff.
	pixelMatchOptions: { ... }

})
// `compareToSnapshot` returns a promise.
.then(function(){
	// If the promise resolves, the images are equal.
	// You should pass your test!
}, function(err) {
	// If the promise rejects, the images are not equal!
	// You should fail your test.

	// An err object is returned with useful information.

	// A DOM element you can insert
	// to see the difference and save a new snapshot.
	err.html
});

Keywords

FAQs

Package last updated on 03 Apr 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

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