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';
// provide a read or write token, defaults to PERCY_TOKEN environment variable
const client = new PercyClient({ token: 'abcdef123456' })
await client.createBuild()
await client.sendSnapshot({
name,
widths,
minimumHeight,
enableJavaScript,
clientInfo,
environmentInfo,
// `sha` falls back to `content` sha
resources: [{ url, sha, content, mimetype, root }]
})
await client.finalizeBuild()
// finalize all parallel build shards
await client.finalizeBuild({ all: true })
Requires a read access token
await client.getBuild(buildId)
Requires a read access token
await client.getBuilds(projectSlug/*, filters*/)
Requires a read access token
await client.waitForBuild({ build: 'build-id' })
await client.waitForBuild({ project: 'project-slug', commit: '40-char-sha' })