
Security News
Vite+ Joins the Push to Consolidate JavaScript Tooling
Evan You announces Vite+, a commercial, Rust-powered toolchain built on the Vite ecosystem to unify JavaScript development and fund open source.
@percy/client
Advanced tools
Communicate with Percy's API to create builds and snapshots, upload resources, and finalize builds and snapshots. Uses [`@percy/env`](.packages/env) to send environment information with new builds. Can also be used to query for a project's builds using a
Communicate with Percy's API to create builds and snapshots, upload resources, and finalize builds
and snapshots. Uses @percy/env
to send environment information with new
builds. Can also be used to query for a project's builds using a read access token.
import PercyClient from '@percy/client'
const client = new PercyClient(options)
token
— Your project's PERCY_TOKEN
(default process.env.PERCY_TOKEN
)clientInfo
— Client info sent to Percy via a user-agent stringenvironmentInfo
— Environment info also sent with the user-agent stringCreates a percy build. Only one build can be created at a time per instance. During this step,
various environment information is collected via @percy/env
and
associated with the new build. If PERCY_PARALLEL_TOTAL
and PERCY_PARALLEL_NONCE
are present, a
build shard is created as part of a parallelized Percy build.
await client.createBuild()
This method combines the work of creating a snapshot, uploading any missing resources, and finally finalizng the snapshot.
await client.sendSnapshot(buildId, snapshotOptions)
name
— Snapshot namewidths
— Widths to take screenshots atminHeight
— Minimum screenshot heightenableJavaScript
— Enable JavaScript for screenshotsclientInfo
— Additional client infoenvironmentInfo
— Additional environment inforesources
— Array of snapshot resources
url
— Resource URL (required)mimetype
— Resource mimetype (required)content
— Resource content (required)sha
— Resource content sharoot
— Boolean indicating a root resource## Create, upload, and finalize snapshotsThis method combines the work of creating a snapshot, creating an associated comparison, uploading associated comparison tiles, and finally finalizing the comparison.
await client.sendComparison(buildId, comparisonOptions)
name
— Snapshot name (required)clientInfo
— Additional client infoenvironmentInfo
— Additional environment infoexternalDebugUrl
— External debug URLtag
— Tagged information about this comparison
name
— The tag name for this comparison, e.g. "iPhone 14 Pro" (required)osName
- OS name for the comparison tag; e.g. "iOS"osVersion
- OS version for the comparison tag; e.g. "16"width
- The width for this type of comparisonheight
- The height for this type of comparisonorientation
- Either "portrait" or "landscape"tiles
— Array of comparison tiles
sha
— Tile file contents SHA-256 hashfilepath
— Tile filepath in the filesystem (required when missing content
)content
— Tile contents as a string or buffer (required when missing filepath
)statusBarHeight
— Height of any status bar in this tilenavBarHeight
— Height of any nav bar in this tileheaderHeight
— Height of any header area in this tilefooterHeight
— Height of any footer area in this tilefullscreen
— Boolean indicating this is a fullscreen tileFinalizes a build. When all
is true, all-shards=true
is added as a query param so the
API finalizes all other parallel build shards associated with the build.
// finalize a build
await client.finalizeBuild(buildId)
// finalize all parallel build shards
await client.finalizeBuild(buildId, { all: true })
Retrieves build data by id.
Requires a read access token
await client.getBuild(buildId)
Retrieves project builds, optionally filtered. The project slug can be found as part of the
project's URL. For example, the project slug for https://percy.io/percy/example
is
"percy/example"
.
Requires a read access token
// get all builds for a project
await client.getBuilds(projectSlug)
// get all builds for a project's "master" branch
await client.getBuilds(projectSlug, { branch: 'master' })
sha
— A single commit shashas
— An array of commit shasbranch
— The name of a branchstate
— The build state ("pending"
, "finished"
, etc.)This method resolves when the build has finished and is no longer pending or processing. By default, it will time out if there is no update after 10 minutes.
Requires a read access token
// wait for a specific project build by commit sha
await client.waitForBuild({
project: 'percy/example',
commit: '40-char-sha'
}, data => {
// called whenever data changes
console.log(JSON.stringify(data));
})
build
— Build ID (required when missing commit
)commit
— Commit SHA (required when missing build
)project
— Project slug (required when using commit
)timeout
— Timeout in milliseconds to wait with no updates (default 10 * 60 * 1000
)interval
— Interval in milliseconds to check for updates (default 10000
)BackstopJS is a visual regression testing tool that uses headless browsers to capture screenshots of web pages and compare them against baseline images. Unlike @percy/client, BackstopJS is a standalone tool that does not require a separate service for storing and comparing images.
Cypress is an end-to-end testing framework that includes built-in support for visual testing through plugins like cypress-image-snapshot. While Cypress is primarily focused on functional testing, it can be extended to perform visual regression testing similar to @percy/client.
WebdriverIO is a testing framework for Node.js that supports visual regression testing through plugins like wdio-visual-regression-service. It allows you to capture and compare screenshots during your end-to-end tests, similar to @percy/client.
FAQs
Communicate with Percy's API to create builds and snapshots, upload resources, and finalize builds and snapshots. Uses [`@percy/env`](.packages/env) to send environment information with new builds. Can also be used to query for a project's builds using a
The npm package @percy/client receives a total of 342,868 weekly downloads. As such, @percy/client popularity was classified as popular.
We found that @percy/client demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer 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
Evan You announces Vite+, a commercial, Rust-powered toolchain built on the Vite ecosystem to unify JavaScript development and fund open source.
Security News
Ruby Central’s incident report on the RubyGems.org access dispute sparks backlash from former maintainers and renewed debate over project governance.
Research
/Security News
Socket researchers uncover how threat actors weaponize Discord across the npm, PyPI, and RubyGems ecosystems to exfiltrate sensitive data.