brokit

brokit checks web pages in a real Chrome. It's a free, open-source command-line tool and Node.js library: it opens your pages in a headless Chrome, uses them as a person would (clicks, typing, touch, input methods), checks what they show, and compares their screenshots with the ones you approved. Its name is short for browser kit.

Status: early (0.1). run, check with expectations and baseline screenshots, diff, serve, doctor, install-chrome and the library work, and are tested on Linux. Reports, a GitHub Action and an MCP server for agents come next.

Install#

From npm, into your project:

shell
npm install --save-dev brokit
npx brokit doctor          # checks that everything brokit needs is here, says what to fix

brokit isn't on npm yet. Until it is, install it from GitHub or from a clone instead; everything after that (npx brokit ..., import ... from 'brokit') works the same.

shell
# From GitHub, into your project (no clone needed). Run it again to update.
npm install --save-dev github:radufarcas10/brokit

# From a clone, into your project: npm links the folder, so `git pull` there updates it.
git clone https://github.com/radufarcas10/brokit.git
cd my-project
npm install --save-dev ../brokit       # the path to your clone

# From a clone, as a `brokit` command anywhere (no npx needed).
cd brokit
npm link
brokit doctor

Or try it without installing: npx github:radufarcas10/brokit run index.html.

Quick start#

shell
brokit run index.html                       # a page from disk (brokit serves the folder)
brokit run http://localhost:3000/           # a page from your dev server
brokit run index.html --out shot.png        # ...and a screenshot
brokit run index.html --size 393x852 --dpr 3 --mobile   # as a phone
brokit check                                # every *.check.json / *.check.mjs here

It prints what happened: when the page was ready, each step, the console, any errors. It exits 0 when everything went fine, 1 when something failed, 2 for a mistake in how it was run. Add --json for the result as JSON (for scripts and agents).

Documentation: radufarcas10.github.io/brokit has all of it, with examples. The same pages are in this repository: see Documentation below.

A taste#

Steps say what to do on a page, as a person would:

JSON
[
  { "click": { "selector": "#email" } },
  { "type": "ana@example.com" },
  { "key": "Enter" },
  { "expect": "document.querySelector('#greeting').textContent", "equals": "Welcome, ana" },
  { "screenshot": "signed-in" }
]
terminal
$ brokit run signup.html --steps steps.json
brokit run http://127.0.0.1:45541/signup.html
  ready (load + network idle) in 609 ms
  ✓ click #email
  ✓ type "ana@example.com"
  ✓ key Enter
  ✓ expect greeting.textContent equals "Welcome, ana"
  ✓ screenshot signed-in → brokit-out/signed-in.png (1280×800)
ok in 0.8 s

Put them in a *.check.json file with their page and screen, add "baseline": true to a screenshot, and brokit check runs every check in your project, comparing each screenshot with the one you approved.

Documentation#

Getting startedfrom installing to a first check with a baseline screenshot
Steps and expectationsevery step: clicks, typing, touch, input methods, screens, waits; checking values
Scenariosscenario files, when a page is ready, JS scenarios
Checks and baselinesbrokit check, baselines, motion, tolerances, brokit diff
Chrome and safetywhich Chrome, brokit doctor, installing and pinning Chrome, serving, what brokit allows
CI and containersGitHub Actions, GitLab CI, Docker, AI agents
Command lineevery command, option, exit code and environment variable
Node.js librarylaunch, Browser, Page, scenarios, images, serving, Chrome
Examplessmall apps with their checks: a form, a phone in dark mode, a canvas, keyboard and input methods, a JS scenario, the library

Also: SECURITY.md (what brokit promises, and reporting a vulnerability), CHANGELOG.md, and the benchmark next to Playwright and Puppeteer.

License#

brokit is licensed under either of

at your option.

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

Edit this page on GitHub