brokit: from scattered test scripts to one tool

How the browser-testing scripts I kept building, project after project, turned into an open-source tool for developers and AI agents.
I never sat down to build a testing tool. I was working on several different projects, and each one needed some way to check it in the browser. So each one got its own little tools and scripts.
They had two jobs: help me test the thing in a real browser, and make it easy to run locally, whether the one running it was me or an AI.
After a while I had a pile of them, all solving the same problem. So I thought: why not make one proper tool out of it, one that might be helpful to others too? That's brokit, short for browser kit.
What it does
brokit opens your pages in a headless Chrome, uses them the way a person would, checks what they show, and compares their screenshots with the ones you approved. It's a command-line tool and a Node.js library.
You describe what to do as a list of steps:
[
{ "click": { "selector": "#email" } },
{ "type": "ana@example.com" },
{ "key": "Enter" },
{ "expect": "document.querySelector('#greeting').textContent", "equals": "Welcome, ana" },
{ "screenshot": "signed-in" }
]And brokit tells you how it went:
$ 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
It works with plain HTML or any framework, DOM or canvas, on a desktop screen or an emulated phone, in light or dark mode.
Catching what changed
Save those steps in a *.check.json file, add "baseline": true to a screenshot, and
brokit check runs every check in your project. When a screen no longer matches the one you
approved, you get the new screenshot and an image with the changed pixels in red. If the
change is what you wanted, brokit check --update makes it the new baseline.
Screenshot tests are only useful if they don't fail at random, so brokit waits for fonts, transitions and scrolling to settle before it takes the picture. And a page with errors never becomes a baseline, so a server that wasn't running can't replace your approved screens with its error page.
Made for AI agents too
An AI agent can write a UI without ever seeing it. With brokit it can open the page, click
through it, read the console and look at the screenshot. Add --json and it gets every
result as data.
A prompt that works well:
After changing the UI, run
npx brokit run <page> --out shot.png --json, read the JSON for console errors, and look at shot.png before saying you're done.
Small and careful
- No npm dependencies. Installing brokit adds one package, about 160 kB on disk. It uses
the Chrome, Chromium or Edge you already have, or downloads Chrome with
brokit install-chrome. - Local by default. It only opens pages on your own computer, unless you allow a host.
- Nothing shared with your browser. Every run gets a throwaway Chrome profile, with Chrome's sandbox on.
I also benchmarked it next to Playwright and Puppeteer. Puppeteer is still the quickest. On a suite of 20 checks, brokit finished a little ahead of Playwright and used about a third of its CPU time.
Try it
brokit is early (0.1). It's tested on Linux; macOS and Windows aren't tested yet. It isn't on npm yet either, so for now it installs from GitHub. You need Node.js 22.4 or newer:
npm install --save-dev github:radufarcas10/brokit
npx brokit doctor
npx brokit run index.html --out shot.pngdoctor checks that everything brokit needs is there, and tells you what to fix if it isn't.
Reports, a GitHub Action and an MCP server for agents come next. The documentation has all the details, and the code is on GitHub. If you also have test scripts scattered across your projects, give it a go.
PS: this site was tested with brokit too. The projects carousel on the home page was scrolled, swiped, paused and looped in a real Chrome, on a desktop screen and an emulated phone, before it went live.