Skip to main content
Hugs
cliq hug new scaffolds a test and a test script (vitest run --environment happy-dom). The blocks below are abridged from the examples’ tests (examples/hugs); each example has a hug.test.ts and a page.test.ts.

The definition

hug.test.ts (abridged)
The agent checks answers with this same definition, so these tests are the rules that count.

The page — mock_host

mock_host stands in for the Hub page: it answers the page’s messages, records what it sends, and plays the person’s part.
mock_host(options): The host it returns:

Testing the real page

mock_host can drive your actual src/main.ts: point mount_hug at it with vi.mock, then import the page.
page.test.ts (abridged)
For a page on the runtime API, mock connect the same way; for React, wrap HugRoot to pass connect. Every example has a page.test.ts. Test view mode by starting there: mock_host({ definition, params, mode: 'view', viewing: { values } }).

In the browser — cliq hug dev

--attachments gives the folder’s files the ids dev-file-0, dev-file-1, … in name order — use them in the sample params. The hug on cliqd’s local Hug page — no run, no Hug — rebuilt and reloaded as you edit, with a panel showing what it sends: values, valid, problems, the Submit label, the summary, uploads, reads and links. Try every state: an empty answer, an invalid one, the view. The panel also has an accessibility check: axe runs inside the hug’s frame after it draws and after each change, against WCAG 2.2 A and AA and axe’s best practices, in the theme your browser prefers. Each problem shows how serious it is, the rule, where it is (inside a kit element: cliq-field » input) and a link explaining the fix. Rules about the whole page — landmarks, the page’s heading, skip links — are left out: those are the host’s. Errors in the hug lists what your own code threw, promises it left rejected, files that didn’t load, and what the frame’s sandbox blocked (a fetch, an outside image or font — see Security for what to do instead), with the file and line and the first lines of the stack. Both run only in cliq hug dev, from a script cliqd adds to the frame; a real Hug’s frame never loads it.

The whole Hug

Run the team with a local cliqd: cliq run opens the Hug’s page. To answer from a test or script — including answers the page wouldn’t allow, to check that the agent refuses them:
The run’s log says the answer couldn’t be used, and the Hug stays open. The hug_id is in the run’s hug.opened event.