Get started
From your app to a first result in six steps. Each command copies as it is; the last one runs the whole study on you, recruits nobody and costs nothing.
Install
Adds the package.
npm install -D ui-testsWrite the config and a study
Writes a study file and a config, and prints the script tag for your app.
npx ui-tests initAdd the tag and start the server
Put this tag in the
<head>of your app's HTML layout, whatever the app is built with. It does nothing until a person is in an attempt: no request, no change to the page. The people taking part reach a ui-tests server you run while the study is open, and rehearsal starts one on this machine for you. The tag's address differs between rehearsal, previews and production, so read it from your setup's environment:<script data-ui-tests="http://localhost:4300">(function(){try{var d=document,u=d.currentScript&&d.currentScript.getAttribute('data-ui-tests')||'';if(!/^https?:\/\/[^/?#\s]+\/?$/i.test(u))return;u=new URL(u).origin;var l=location,m=/(^#|&)ui-tests=([^&]*)/.exec(l.hash);if(m){var h=l.hash.replace(m[0],m[1]=='#'?'#':'').replace('#&','#');history.replaceState(history.state,'',l.href.split('#')[0]+(h=='#'?'':h))}else{var j=JSON.parse(localStorage.getItem('ui-tests-attempt'));if(!j||j.server!==u||!(j.expiresAt>Date.now()))return}var s=d.createElement('script');s.type='module';s.src=u+'/ui-tests.js'+(m?'#'+m[2]:'');d.head.appendChild(s)}catch(e){}})()</script>- Vite:
index.html: <script data-ui-tests="%VITE_UI_TESTS_URL%">…</script>, with VITE_UI_TESTS_URL in .env - Astro:
<script is:inline data-ui-tests={import.meta.env.PUBLIC_UI_TESTS_URL}>…</script> in your layout - Next.js:
<script data-ui-tests={process.env.NEXT_PUBLIC_UI_TESTS_URL} dangerouslySetInnerHTML={{ __html: TAG_SCRIPT }} /> in app/layout.tsx, with TAG_SCRIPT from 'ui-tests/tag' - Rails:
<script data-ui-tests="<%= ENV["UI_TESTS_URL"] %>">…</script> in app/views/layouts/application.html.erb - Plain HTML:
the tag as printed, with the address of your ui-tests server
To run the server yourself, on any machine with Node 24 or later, or as a Docker image with its store on a volume. The image is not on a registry yet, so build it from a clone of the repository; it is to be published as ghcr.io/miguel-perez/ui-tests.
npx ui-tests servedocker build -t ui-tests . docker run -p 4300:4300 -v ui-tests:/data ui-tests- Vite:
Write the study
Say who your users are, what they are trying to do, and how you would know they did it, in one small file next to your code. This is the study this site runs on itself, in
ui-tests/landing.ui.test.ts:import { study, task, outcome, expect } from 'ui-tests' study('getting started', { users: { did: 'shipped a user interface you built yourself', role: ['Developer', 'Designer', 'Founder'], }, purpose: 'find out whether people can use what I built, without a researcher', }, () => { task('start trying ui-tests', { path: ['/', '/docs/getting-started'] }, () => { outcome(async ({ page }) => { expect(page.url()).toContain('/docs/getting-started') }) }) })Run it on yourself
Runs the whole study on you, in your browser: the consent, the scenario card, your page with the bar, and your own trace. Recruits nobody, costs nothing.
npx ui-testsRead the result
When you press Done and answer the questions, the terminal says whether your check passed, lists the moments that got in the way, and opens your trace on this machine. A run on yourself is a rehearsal: it never counts toward the five people a study plans for, so the sentence reads
Rehearsal: 0 of 5 planned attempts recorded.
Running from CI
Runs and results live in a database, so a record outlives any one preview. Locally that is a file; for CI and previews use Postgres on Neon. These steps need your own accounts, so nothing here is done for you.
- Create a Neon project and a database, and copy its pooled connection string.
- Run a ui-tests server that people can reach for the length of the study, with
UI_TESTS_DATABASE_URLset to that string andUI_TESTS_PUBLIC_URLset to the address they reach it at:npx ui-tests serveon a machine you run, or, from a clone of the repository,docker build -t ui-tests .thendocker run -p 4300:4300 -v ui-tests:/data -e UI_TESTS_DATABASE_URL=… -e UI_TESTS_PUBLIC_URL=… ui-tests. - In Vercel, set
NEXT_PUBLIC_UI_TESTS_URL(or your framework's variable for the tag's address) in the Preview environment to that address, so the preview's tag points at the server. - In GitHub, add the same string as the repository secret
UI_TESTS_DATABASE_URL, and setUI_TESTS_PUBLIC_URLto the server's address in the workflow that runs your studies: the configinitwrites readsserver.urlfrom it, sonpx ui-tests checkfinds the server and puts the invite links on it.
To prove a preview without people, start npx ui-tests serve inside the job instead, before npx ui-tests check, and leave UI_TESTS_PUBLIC_URL unset: the check finds the server on this machine, as this repository's .github/workflows/ui-tests-check.yml does. That server ends with the job, so it is not one to invite people to. For a local try-out without Neon, UI_TESTS_DATABASE_URL=pglite:memory runs the same store in memory. The tables are created on first use.
Accessibility
Everything a participant meets works with the keyboard alone: Tab and Shift+Tab to move between questions and buttons, the arrow keys to choose within a set of choices, Space to tick a box, Enter to press a button. Every screen has one heading, one question and labelled controls; the bar announces the question it asks and any offer of more time. The checks run in a real browser with axe on every screen. What they cannot do is listen, so before you publish a study, check it by ear.
- On a Mac, open Safari and turn VoiceOver on with Command+F5.
- Open a participant link and go from the first screen to the thanks with the keyboard only.
- On each screen, listen for the heading, then the question, then each choice with its place in the group (for example "3 of 5").
- On the task page, press Tab until the bar is read: the task, Done, and I couldn't do this. Press Done and listen for "Finished this task?".
- When the bar offers more time, listen for the offer, then press the button once with the keyboard.
Do this by hand. It is not part of the automated checks. Each person's browser and device are read from their browser, and after the consent they may say which assistive technology they use; both are kept with their attempt. Spoken answers are kept as audio; set UI_TESTS_TRANSCRIBER to a module whose default export turns audio into text to keep the words too.