# @applitools/core

Latest version **4.77.1** (published 2026-11-18) · SEE LICENSE IN LICENSE license · 0 weekly downloads

## Install

```sh
npm install @applitools/core
pnpm add @applitools/core
yarn add @applitools/core
bun add @applitools/core
```

Provides the command `eyes-check-network`.

## Health

**Score 70/100 (B)** — status: active.

Positive: has types; esm support; no vulnerabilities; recently updated; high maintenance score; high quality score.

Warnings: low downloads.

## Facts

| | |
|---|---|
| Version | 4.77.1 |
| Published | 2026-11-18 |
| First published | 2022-09-21 |
| Weekly downloads | 0 |
| License | SEE LICENSE IN LICENSE |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Node | >=12.13.0 |
| Dependencies | 22 |
| Unpacked size | 1.1 MB |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| Author | Applitools Team |
| Maintainers | danielputerman, gearm, amit.rokach, roy.sela, applitools-admin, applitools-readonly, iasisapp, noam.mendel, arik-applitools, yotammadem, denis.styrt, kyrylo.onufriiev, ormeda, clementbarry, idosapplitools, gofilord, alex.burdeynyy, ronikar_applitools, benny.halberstadt, grayscale64, fatihsolhan-applitools, itaiz134, dockermaster, anandbagmar, itaytamir-at, sergovapplitools, fluxomni.io, mmilapp, noam.gaash, roeefr, anastasia.koifman, aretm_borodavka, yonittzairilevy, asundaram-applitools, amir.groisman, emasuary, naama.shoham, adamcarmi, mulygottlieb, yoavnaveh-applitools, chaimaharonson, movsho, netta.bondy, shirbin, ranhadar, dmytro-h, rostyslav.pidburachynskyi.applitools, taltool |

## Links

- npm: https://www.npmjs.com/package/@applitools/core
- Homepage: https://applitools.com
- npm.io page: https://npm.io/package/@applitools/core

## Dependencies (22)

- [chalk](https://npm.io/package/chalk.md) 4.1.2
- [semver](https://npm.io/package/semver.md) 7.6.2
- [throat](https://npm.io/package/throat.md) 6.0.2
- [node-fetch](https://npm.io/package/node-fetch.md) 2.6.7
- [shell-quote](https://npm.io/package/shell-quote.md) ^1.8.4
- [@applitools/req](https://npm.io/package/@applitools/req.md) 1.11.9
- [fast-xml-parser](https://npm.io/package/fast-xml-parser.md) 5.11.1
- [abort-controller](https://npm.io/package/abort-controller.md) 3.0.0
- [@applitools/image](https://npm.io/package/@applitools/image.md) 1.3.6
- [@applitools/utils](https://npm.io/package/@applitools/utils.md) 1.15.4
- [@applitools/driver](https://npm.io/package/@applitools/driver.md) 1.26.17
- [@applitools/logger](https://npm.io/package/@applitools/logger.md) 2.3.4
- [@applitools/socket](https://npm.io/package/@applitools/socket.md) 1.3.20
- [@applitools/snippets](https://npm.io/package/@applitools/snippets.md) 2.9.12
- [@applitools/core-base](https://npm.io/package/@applitools/core-base.md) 1.44.1
- [@applitools/ec-client](https://npm.io/package/@applitools/ec-client.md) 1.12.60
- [@applitools/nml-client](https://npm.io/package/@applitools/nml-client.md) 1.12.16
- [@applitools/ufg-client](https://npm.io/package/@applitools/ufg-client.md) 1.27.1
- [@applitools/dom-capture](https://npm.io/package/@applitools/dom-capture.md) 11.8.13
- [@applitools/dom-snapshot](https://npm.io/package/@applitools/dom-snapshot.md) 4.18.11
- [@applitools/screenshoter](https://npm.io/package/@applitools/screenshoter.md) 3.12.39
- [@applitools/task-manager](https://npm.io/package/@applitools/task-manager.md) 1.1.0

## Recent versions

- 4.77.1 (latest) — 2026-11-18
- 4.61.1-debug.0 (debug) — 2026-05-12
- 2.5.3-legacy.1 (legacy-integration) — 2024-12-22
- 4.77.0 — 2026-11-16
- 4.76.0 — 2026-11-12
- 4.75.0 — 2026-11-05
- 4.74.2 — 2026-11-05
- 4.74.1 — 2026-11-02
- 4.74.0 — 2026-11-01
- 4.73.3 — 2026-10-29
- 4.73.2 — 2026-10-26
- 4.73.1 — 2026-10-25
- 4.73.0 — 2026-10-18
- 4.72.2 — 2026-10-18
- 4.72.1 — 2026-10-14
- … 314 more at https://npm.io/package/@applitools/core/versions

## README

# @applitools/core

The core SDK package that orchestrates visual testing via two distinct check strategies: **Classic** and **UFG** (Ultrafast Grid).

---

## Check Strategies Overview

Both strategies share the same entry point (`src/check.ts`) which normalizes settings and then delegates to the appropriate typed implementation based on the `type` parameter (`'classic'` or `'ufg'`).

```
eyes.check()
    └── src/check.ts           ← normalizes settings, resolves type
         ├── classic/check.ts  ← screenshot-based flow
         └── ufg/check.ts      ← DOM snapshot + cloud rendering flow
```

---

## Classic Check

**Concept**: Capture a screenshot locally (in the test runner's browser/device) and send it to Applitools for comparison against the baseline.

### Flow

```
check()
  │
  ├── [driver target?]
  │     │
  │     ├── beforeScreenshot()
  │     │     ├── setScrollingElement
  │     │     └── waitForLazyLoad (if enabled)
  │     │
  │     ├── [web or native?]
  │     │     ├── takeWebScreenshot()
  │     │     │     ├── takeScreenshot()   ← scrolls, stitches, captures PNG
  │     │     │     └── takeDomCapture()   ← captures DOM (if sendDom=true)
  │     │     │
  │     │     └── takeNMLScreenshot()
  │     │           └── nmlClient.takeScreenshots()  ← native mobile (NML)
  │     │
  │     └── [matchTimeout set?]
  │           ├── YES → checkEnvironment() synchronously, retry until passes
  │           └── NO  → checkInTheBackground() ← fire-and-forget, non-blocking
  │
  └── [image target?]
        └── checkInTheBackground() ← directly queue pre-captured image
```

### Key files

| File | Purpose |
|------|---------|
| `src/classic/check.ts` | Orchestrates the classic check flow |
| `src/classic/utils/take-screenshots.ts` | Takes the screenshot and optional DOM capture |
| `src/classic/utils/take-dom-capture.ts` | Captures the page DOM for RCA |
| `src/automation/utils/take-screenshot.ts` | Low-level screenshot + stitching logic |

### What happens on each check

1. **Settings normalization** — applied in `src/check.ts` (defaults for `fully`, `matchLevel`, `sendDom`, etc.)
2. **Scroll root / lazy load** — the driver scrolls and waits for deferred content
3. **Screenshot** — a full-page or viewport PNG is captured locally
4. **DOM capture** (optional) — if `sendDom=true`, the serialized DOM is captured for Root Cause Analysis (RCA)
5. **Session open** (lazy) — the environment's `open` task runs once a check needs it
6. **Upload + compare** — the `upload` task uploads the image+DOM (`baseEyes.uploadTarget()`), then the `match` task triggers comparison (`baseEyes.match()`)

### matchTimeout behavior

When `matchTimeout > 0`, the SDK retries the entire screenshot→compare cycle until the result matches expectations or the timeout expires. This blocks the test execution thread and is designed to tolerate transient UI states (e.g., loading spinners).

### Background queuing

When `matchTimeout = 0` (default), checks are queued as background promises. The test thread is not blocked. `eyes.close()` awaits all queued jobs before resolving results.

---

## UFG Check (Ultrafast Grid)

**Concept**: Capture a DOM snapshot locally, upload it to the Applitools rendering farm (UFG - Ultrafast Grid), which renders it in multiple browsers and devices in the cloud and then compares each rendered image against the baseline.

### Flow

```
check()
  │
  ├── getUFGClient()  ← initialize methods for UFG purposes
  │
  ├── [driver target?]
  │     └── takeSnapshots()
  │           ├── setScrollingElement
  │           ├── takeDomSnapshots()    ← serialized DOM + resources
  │           │     └── (per environment: browser widths, layout breakpoints)
  │           └── driver.getUrl() / getTitle() / getUserAgent()
  │
  ├── [for each snapshot × environment]
  │     ├── createRenderTargetFromSnapshot()
  │     │     └── ufgClient.uploadResources()  ← CSS, fonts, images → UFG CDN
  │     │
  │     ├── open task   ← open test session (lazy, per environment)
  │     │
  │     ├── ufgClient.render()
  │     │     └── UFG renders DOM in target browser/device → returns rendered image
  │     │
  │     └── baseEyes.match()  ← compare rendered image against baseline
  │
  └── each environment's tasks run on core's task graph (src/tasks/)
```

### Key files

| File | Purpose |
|------|---------|
| `src/ufg/check.ts` | Orchestrates the UFG check flow |
| `src/ufg/take-snapshots.ts` | Takes DOM snapshots per environment |
| `src/ufg/create-render-target-from-snapshot.ts` | Uploads resources to UFG CDN, builds render target |
| `src/ufg/utils/take-dom-snapshots.ts` | Serializes DOM including cross-frame content |

### What happens on each check

1. **Settings normalization** — same as Classic (`src/check.ts`)
2. **DOM snapshot** — the page's full DOM (HTML, CSS, iframes) is serialized and resources are collected
3. **Resource upload** — CSS, fonts, images are uploaded to the UFG CDN (cached by URL to avoid re-uploads)
4. **Render request** — sent to the UFG rendering farm per target environment (browser + viewport or device)
5. **Session open** (lazy, per environment) — each environment's `open` task opens its Applitools session
6. **Compare** — the `match` task sends the rendered image reference (`renderId`) to `baseEyes.match()`, which triggers comparison

### Environment targeting

UFG supports rendering in multiple environments per check:

```ts
settings.environments = [
  { name: 'chrome', width: 1280, height: 800 },
  { name: 'firefox', width: 1280, height: 800 },
  { chromeEmulationInfo: { deviceName: 'Pixel 4 XL' } },
  { iosDeviceInfo: { deviceName: 'iPhone 12', version: 'latest' } },
]
```

Each environment produces one independent test session, one render, and one comparison result.

### Layout breakpoints

UFG supports `layoutBreakpoints` — the DOM is snapshotted at each specified viewport width to capture responsive layout differences, and UFG renders each environment at the closest matching breakpoint.

---

## Classic vs UFG: Key Differences

| Aspect | Classic | UFG |
|--------|---------|-----|
| **What's captured locally** | Screenshot (PNG) | DOM snapshot (HTML/CSS/resources) |
| **Where rendering happens** | Local driver (real browser) | Applitools cloud (UFG rendering farm) |
| **Multi-environment** | Takes one screenshot, reuses for all envs | Renders separately per environment |
| **Native mobile** | Supported via NML (real devices) | Supported via cloud device emulation |
| **DOM capture** | Optional (for RCA) | Always — it's the input |
| **Concurrency usage** | One slot per environment | One slot per environment |
| **matchTimeout** | Supported (retry loop) | Not supported |
| **Scroll/stitch** | Done locally by the SDK | Done by UFG renderer |

---

## Environment Terminology

Two distinct environment shapes flow through classic check. Confusing them is the source of a known bug.

| Name | TypeScript type | Shape | Where it comes from |
|------|----------------|-------|---------------------|
| **Requested environment** (also called *unique environment*) | `RenderEnvironment` | `{iosDeviceInfo: {deviceName: 'iPhone 12'}}` or `{name: 'chrome', width: 1280, height: 800}` | Comes from `settings.environments` (user input). After `uniquifyEnvironments()`, duplicates get a synthetic `environmentId` to map to separate sessions. |
| **Actual / exact environment** | `ExactEnvironment` | `{environmentId, deviceName, os, viewportSize, requested: <RenderEnvironment>}` | Returned by `takeWebScreenshot` / `takeNMLScreenshot` after the device is resolved. The flat shape that `core-base` and the Applitools server understand. Always has `requested` pointing back to the original `RenderEnvironment`. |

**Key invariant:** `toEnvironmentKey(exactEnvironment)` === `toEnvironmentKey(requestedEnvironment)` because `toEnvironmentKey` uses `env.requested ?? env`. This is how a check keyed on the exact environment finds the open declared for the requested one.

**Known bug:** In the `matchTimeout` path, `base.openEyes` is called with the *requested* environment (`{iosDeviceInfo: ...}`) instead of the *exact* environment (`{deviceName, os, viewportSize, ...}`). `core-base/server/requests.ts` reads the flat fields (`os`, `deviceName`, `viewportSize`) which are `undefined` on the requested form, so the session opens on the server with empty environment info. This only affects NML (iOS/Android native) environments since web environments are not transformed and `exactEnvironment === requestedEnvironment`.

---

## Session Lifecycle (Both Strategies)

Sessions are opened **lazily** — `openEyes()` declares a lazy `open` task per environment (`src/tasks/`); the first check's steps activate it, and a close or abort dismisses one nothing needed. This avoids charging concurrency for tests that open but never check.

```
openEyes()         → declares lazy opens, no server call
check()            → activates the env's open → POST /api/sessions (first time only)
close()            → one close task per environment, after its last step
abort()            → one abort task per environment, as soon as it is open (doesn't wait for steps)
```

---

## Task Graph

Both strategies add their steps to core's task graph (`src/tasks/`), each task labeled `{session, env}`; close, abort and getResults query it for each environment's tasks.

---
_Source: https://npm.io/package/@applitools/core · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
