# @visual-regression-tracker/sdk-js

> JavaScript SDK for Visual Regression Tracker

Latest version **5.7.1** (published 2024-07-26) · Apache-2.0 license · 0 weekly downloads

## Install

```sh
npm install @visual-regression-tracker/sdk-js
pnpm add @visual-regression-tracker/sdk-js
yarn add @visual-regression-tracker/sdk-js
bun add @visual-regression-tracker/sdk-js
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 5.7.1 |
| Published | 2024-07-26 |
| First published | 2020-05-09 |
| Weekly downloads | 0 |
| License | Apache-2.0 |
| TypeScript types | bundled |
| Module format | CommonJS |
| Node | >=18 |
| Dependencies | 2 |
| Unpacked size | 41.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 4 |
| Maintainers | pashidlos |

## Links

- npm: https://www.npmjs.com/package/@visual-regression-tracker/sdk-js
- Repository: https://github.com/Visual-Regression-Tracker/sdk-js
- Homepage: https://github.com/Visual-Regression-Tracker/Visual-Regression-Tracker
- Issues: https://github.com/Visual-Regression-Tracker/sdk-js/issues
- npm.io page: https://npm.io/package/@visual-regression-tracker/sdk-js

## Dependencies (2)

- [axios](https://npm.io/package/axios.md) ^1.6.2
- [form-data](https://npm.io/package/form-data.md) ^4.0.0

## Recent versions

- 5.7.1 (latest) — 2024-07-26
- 5.7.0 — 2023-07-12
- 5.6.0 — 2023-01-23
- 5.5.0 — 2022-06-24
- 5.4.0 — 2022-05-09
- 5.3.0 — 2022-03-25
- 5.2.0 — 2021-09-03
- 5.1.1 — 2021-08-27
- 5.1.0 — 2021-08-27
- 5.0.0 — 2021-05-22
- 4.8.1 — 2021-05-22
- 4.8.0 — 2021-05-20
- 4.7.0 — 2021-04-26
- 0.2.0 — 2021-04-26
- 0.1.0 — 2021-04-26
- … 27 more at https://npm.io/package/@visual-regression-tracker/sdk-js/versions

## README

# JS SDK for [Visual Regression Tracker](https://github.com/Visual-Regression-Tracker/Visual-Regression-Tracker)

[![Coverage](https://sonarcloud.io/api/project_badges/measure?project=Visual-Regression-Tracker_sdk-js&metric=coverage)](https://sonarcloud.io/summary/new_code?id=Visual-Regression-Tracker_sdk-js)
[![Code Smells](https://sonarcloud.io/api/project_badges/measure?project=Visual-Regression-Tracker_sdk-js&metric=code_smells)](https://sonarcloud.io/summary/new_code?id=Visual-Regression-Tracker_sdk-js)

## Npm

https://www.npmjs.com/package/@visual-regression-tracker/sdk-js

## Install

`npm install @visual-regression-tracker/sdk-js`

## Usage

### Import

```js
import {
  VisualRegressionTracker,
  Config,
} from "@visual-regression-tracker/sdk-js";
```

### Configure

#### Explicit config from code

```js
const config: Config = {
  // URL where backend is running
  // Required
  apiUrl: "http://localhost:4200",

  // Project name or ID
  // Required
  project: "Default project",

  // User apiKey
  // Required
  apiKey: "tXZVHX0EA4YQM1MGDD",

  // Current git branch
  // Required
  branchName: "develop",

  // Log errors instead of throwing exceptions
  // Optional - default false
  enableSoftAssert: true,

  // Unique ID related to one CI build
  // Optional - default null
  ciBuildId: "SOME_UNIQUE_ID",
};
```

#### Or, as JSON config file `vrt.json`

_Used only if not explicit config provided_
_Is overriden if ENV variables are present_

```json
{
  "apiUrl": "http://localhost:4200",
  "project": "Default project",
  "apiKey": "tXZVHX0EA4YQM1MGDD",
  "ciBuildId": "commit_sha",
  "branchName": "develop",
  "enableSoftAssert": false
}
```

#### Or, as environment variables

_Used only if not explicit config provided_

```
VRT_APIURL="http://localhost:4200"
VRT_PROJECT="Default project"
VRT_APIKEY="tXZVHX0EA4YQM1MGDD"
VRT_CIBUILDID="commit_sha"
VRT_BRANCHNAME="develop"
VRT_ENABLESOFTASSERT=true
```

### Setup

```js
vrt.start();
```

### Teardown

```js
vrt.stop();
```

### Assert

```js
await vrt.track({
  // Name to be displayed
  // Required
  name: "Image name",

  // Base64 encoded string
  // Required or use imagePath
  imageBase64: image,

  // Path to image (service version api:4.14.0 or higher is required)
  // Required or use imageBase64
  imagePath: image,

  // Allowed mismatch % (mismatched pixels to overal pixels count)
  // Optional
  diffTollerancePercent: 0,

  // Optional
  os: "Mac",

  // Optional
  browser: "Chrome",

  // Optional
  viewport: "800x600",

  // Optional
  device: "PC",

  // Optional
  customTags: "Cloud, DarkTheme, Auth",

  // Array of areas to be ignored
  // Optional
  ignoreAreas: [
    {
      // X-coordinate relative of left upper corner
      // Required
      x: 10;

      // Y-coordinate relative of left upper corner
      // Required
      y: 20;

      // Area width in px
      // Required
      width: 300;

      // Height width in px
      // Required
      height: 400;
    }
  ]

  // Allow additional details
  // Optional
  comment: 'Ignoring region because of animation'
});
```

---
_Source: https://npm.io/package/@visual-regression-tracker/sdk-js · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
