Security News
Supply Chain Attack Detected in Solana's web3.js Library
A supply chain attack has been detected in versions 1.95.6 and 1.95.7 of the popular @solana/web3.js library.
@applitools/visual-grid-client
Advanced tools
A library that drives the visual grid with dom snapshot rendering.
A library that drives the visual grid with dom snapshot rendering.
npm install @applitools/visual-grid-client
const {makeVisualGridClient} = require('@applitools/visual-grid-client')
See below for the full API.
makeVisualGridClient
:const {makeVisualGridClient} = require('@applitools/visual-grid-client')
const visualGridClient = makeVisualGridClient()
The visualGridClient, returned by makeVisualGridClient
, is an object with the following functions:
openEyes(configOverride)
: to start a set of tests, where each step is a set of renderings according to the browser
stuff in the configuration.
This function will return an object with functions (see below) allowing you to create renderings (or "steps" in
Applitools parlance) for the test.
testWindow({openParams, checkParams, throwEx})
closeBatch()
Async function openEyes
will create a test. Actually, it will create a series of tests, one for each browser configuration
defined in the browser
property of the configuration.
openEyes
accepts a configuration object that will override the default configuration found by
makeVisualGridClient
, per this test.
Accepts:
proxy - string or object, examples:
https://username:password@myproxy
{url: 'https://myproxy', username: 'my_user', password: 'my_password', isHttpOnly: false
more params TBD..
Returns a promise to an object with the following functions:
checkWindow(...)
: creates a "step" that checks the window according to the baseline. Note that this
function will not fail, and you need to await
the promises returned from close()
to wait for the failure or success
of a batch of steps in the test.close()
: async closes the test (or series of tests) created by openEyes
.abort()
: if you want to abort this test (or series of tests). Async.checkWindow(...)
checkWindow
receives an object with the following parameters:
tag
: the name of the step, as seen in Applitools Eyes.url
: the URL appearing in the address bar of the browser. All relative URLs in the CDT will be relative to it.snapshots
: either single dom snapshot or an array corresponding to the browser
array sent in openEyes
. The DOM snapshot can have these properties:
cdt
: the HTML and set and resources, in the x-applitools-html/cdt
format (see below). you can use domNodesToCdt
to create a CDT from a document
.resourceUrls
: By default, an empty array. Additional resource URLs not found in the CDT.resourceContents
: a map of all resource values (buffers). The keys are URLs (relative to the url
property).frames
: same structure of snapshot
, recursively.target
: the target of the rendering. Can be one of window
, region
fully
: set when target
is window
, if fully
is true
then snapshot is full page, if fully
is false
then snapshot is viewport.selector
: if the target
is region
, this is the selector we are targeting.region
: if the target
is region
, this is the region we are targeting.
This is an object with x
, y
, width
, height
properties.ignore
: TBDfloating
: TBDaccessibility
: TBDstrict
: TBDlayout
: TBDcontent
: TBDsendDom
: TBDscriptHooks
: a set of scripts to be run by the browser during the rendering.
An object with the following properties:
beforeCaptureScreenshot
: a script that runs after the page is loaded but before taking the screenshot.
The value is an object with the following properties:url
: yes, again.type
: the content type of the resource.value
: a Buffer
of the resource content.matchLevel
: The method to use when comparing two screenshots, which expresses the extent to which the two images are expected to match.accessibilitySettings
: The accessibility to use for the screenshots. Possible values are 'AA' and 'AAA'. // TODObatchNotify
.close
receives throwEx
parameters, and returns a promise.
openEyes
pass then the promise is resolved with Array<TestResults>.openEyes
then the promise is rejected with Array<TestResults>.{
domNodes: [
{
nodeType: number, // like in the DOM Standard
nodeName: ‘...’ , // for elements and DocumentType
nodeValue: ‘...’, // for text nodes
attributes: [{name, value}, ...],
childNodeIndexes: [index, index, ...]
},
//...
],
resources: [
{
hashFormat: 'sha256', // currently the only hash format allowed
hash: '....', // the hash of the resource.
contentType: '...', // the mime type of the resource.
},
//...
]
}
Accepts a document object conforming to the DOM specification (browser document is fine, as is the JSDOM document).
Returns a cdt, ready to be passed to checkWindow
???
Example Mocha test that uses the visual grid client:
const path = require('path')
const fs = require('fs')
const {makeVisualGridClient} = require('@applitools/visual-grid-client')
const {getProcessPageAndSerialize} = require('@applitools/dom-snapshot')
const puppeteer = require('puppeteer')
describe('visual-grid-client test', function() {
let visualGridClient
let closePromises = []
let processPageAndSerialize
let browser
let page
before(async () => {
browser = await puppeteer.launch()
page = await browser.newPage()
visualGridClient = makeVisualGridClient({
showLogs: true,
})
processPageAndSerialize = `(${await getProcessPageAndSerializeScript()})()`
})
after(async () => {
await browser.close()
const results = await Promise.all(closePromises)
await visualGridClient.closeBatch() // after all sessions ended (session = open checkWindow close)
return results;
})
let checkWindow, close
beforeEach(async () => {
;({checkWindow, close} = await visualGridClient.openEyes({
appName: 'visual grid client with a cat',
testName: 'visual-grid-client test',
}))
})
afterEach(() => closePromises.push(close()))
it('should work', async () => {
await page.goto('index.html')
const {cdt, url, resourceUrls, blobs, frames} = await page.evaluate(processPageAndSerialize)
const resourceContents = blobs.map(({url, type, value}) => ({
url,
type,
value: Buffer.from(value, 'base64'),
}));
checkWindow({
tag: 'first test',
target: 'region',
fully: false,
url,
snapshots: {
cdt,
resourceUrls,
resourceContents,
frames,
}
})
})
})
const {makeVisualGridClient} = require('@applitools/visual-grid-client')
const {getProcessPageAndSerialize} = require('@applitools/dom-snapshot')
const puppeteer = require('puppeteer')
describe('visual-grid-client test', function() {
let visualGridClient
let closePromises = []
let processPageAndSerialize
let browser
let page
before(async () => {
browser = await puppeteer.launch()
page = await browser.newPage()
visualGridClient = makeVisualGridClient({
showLogs: true,
})
processPageAndSerialize = `(${await getProcessPageAndSerializeScript()})()`
})
after(async () => {
await browser.close()
const results = await Promise.all(closePromises)
})
it('should work', async () => {
await page.goto('index.html')
const {cdt, url, resourceUrls, blobs, frames} = await page.evaluate(processPageAndSerialize)
const resourceContents = blobs.map(({url, type, value}) => ({
url,
type,
value: Buffer.from(value, 'base64'),
}));
const checkParams = {
tag: 'first test',
target: 'region',
fully: false,
url,
snapshots: {
cdt,
resourceUrls,
resourceContents,
frames,
}
};
const openParams = {
appName: 'visual grid client with a cat',
testName: 'visual-grid-client test',
}
const results = await testWindow({checkParams, openParams, throwEx: false})
})
})
The best way is to run npm run changelog
. The prerequisite for that is to have jq installed, and also define the following in git configuration:
git config changelog.format "* %s - %an [[%h](https://github.com/applitools/visual-grid-client/commit/%H)]"
FAQs
A library that drives the visual grid with dom snapshot rendering.
The npm package @applitools/visual-grid-client receives a total of 8,205 weekly downloads. As such, @applitools/visual-grid-client popularity was classified as popular.
We found that @applitools/visual-grid-client demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 33 open source maintainers collaborating on the project.
Did you know?
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.
Security News
A supply chain attack has been detected in versions 1.95.6 and 1.95.7 of the popular @solana/web3.js library.
Research
Security News
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.