Exemplo
@testing-library/user-event 14.6.1: userEvent.setup
Amostra verificada para npm @testing-library/user-event 14.6.1: userEvent.setup. O contrato rodou em node 22 · linux debian/x64 · docker e passou.
sha256:bc46b9b3d206ca6f6c97e53ed3db40b7039ecfef8b2433a161ccbb1ce302fa20
Esta rede oferece uma coisa: uma amostra que compila. Ela a executou em um sandbox e guardou o recibo assinado. Não classifica nem garante nada — se o mesmo código compila onde você está, ela não mediu.
Quantas chaves de assinatura distintas enviaram um recibo de contrato aprovado. Uma é só o autor; mais de uma significa que outra pessoa também o compilou. Uma chave é gerada por conta própria e não tem identidade registrada por trás, então conta chaves, não pessoas.
MIT-0
Evidência de execução
O ambiente declarado e as execuções assinadas ficam separados, para você ver exatamente o que esta amostra executou e onde.
- Base da evidência
- Contrato assinado aprovado
- Recibos de verificação
- 1
- Chaves de assinatura que o compilaram
- 1
Ambiente declarado
linux 24 · ubuntu · glibc 2.39 x64 npm
Ambientes das execuções de verificação
| Ambiente | Contrato | Etapas | Execução |
|---|---|---|---|
| node 22 · linux debian/x64 · docker ed25519:c1973797be207ac4 | PASS | compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS CONTAINER_RUN · node-typescript@1node:22@sha256:8a34c4ab3ea2… |
2026-09-12 |
Caso
HOW- Objetivo
- verify userEvent.setup in pkg:npm/%40testing-library/user-event@14.6.1
- Símbolos
-
- userEvent.setup
- Criado
- 2026-09-12T02:37:58Z
Contrato
- userEvent.setup initializes an instance exposing user interaction methods and setup method
- userEvent.setup attaches clipboard stub implementation to window navigator
- userEvent.setup instance dispatches sequential pointer, mouse, and click events upon click
- userEvent.setup instance setup method creates sub-session with overridden options and shared state
Arquivos
- PROMPT.md
- csx.json
- package-lock.json
- package.json
- spec.json
- test/contract.mjs
Código-fonte
Clean-room public code sample — generation instructions
Write a brand-new, minimal, self-contained code sample in this clean-room directory.
Do not copy, paraphrase, or reference any existing project source. Work only from this spec.
A csx.json manifest scaffold already exists. Do not recreate it from memory. Preserve its case.goal, packages and symbols; fill its empty case.contract with exact assertions and correct its environment, commands and verifierAdapter for the files you generate.
Goal: verify userEvent.setup in pkg:npm/%40testing-library/user-event@14.6.1
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:npm/%40testing-library/user-event@14.6.1
Demonstrate these symbols/APIs:
- userEvent.setup
Rules:
- One focused purpose; the smallest project that proves the goal.
- Include a contract test (test/contract.*) that runs OFFLINE and exits 0 exactly when the goal behavior works.
- Pin every dependency with a lockfile so resolution is reproducible.
- No secrets, credentials, or tokens. No real URLs (only example.com or localhost). No absolute paths.
- No personal names, emails, company names, or project identifiers of any kind.
- No binaries and no generated output (node_modules, dist, target, venv, .git, .env).
- Keep it under 200 files and 256KB packed.
{"case":{"caseId":"case:sha256:c81ddd96a3ed7c7a715bc7695983db4677a06cb224bab8e8fbf838901c0fdc44","contract":["userEvent.setup initializes an instance exposing user interaction methods and setup method","userEvent.setup attaches clipboard stub implementation to window navigator","userEvent.setup instance dispatches sequential pointer, mouse, and click events upon click","userEvent.setup instance setup method creates sub-session with overridden options and shared state"],"goal":"verify userEvent.setup in pkg:npm/%40testing-library/user-event@14.6.1","kind":"HOW","packages":["pkg:npm/%40testing-library/user-event@14.6.1"],"schemaVersion":1,"symbols":["userEvent.setup"]},"contractCommand":["node","test/contract.mjs"],"environment":{"arch":"x64","distro":"ubuntu","ecosystem":"npm","libc":"glibc","libcVersion":"2.39","os":"linux","osVersionBucket":"24","packageManager":"npm","schemaVersion":1},"license":"MIT-0","packages":["pkg:npm/%40testing-library/user-event@14.6.1"],"schemaVersion":1,"subject":"pkg:npm/%40testing-library/user-event@14.6.1","symbols":["userEvent.setup"],"verifierAdapter":"node-typescript@1"}
{
"name": "sample-user-event-setup",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "sample-user-event-setup",
"version": "1.0.0",
"dependencies": {
"@testing-library/user-event": "14.6.1"
}
},
"node_modules/@babel/code-frame": {
"version": "7.29.7",
"resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.29.7.tgz",
"integrity": "sha512-Aup7aUOfpbAUg2ROOJN6Iw5f9DMBlzu0mIkm/malLQFN/YQgO48wCj0Kxa3sEHJvPVFg7siR+qRInwXd2qhQKw==",
"license": "MIT",
"peer": true,
"dependencies": {
"@babel/helper-validator-identifier": "^7.29.7",
"js-tokens": "^4.0.0",
"picocolors": "^1.1.1"
},
"engines": {
"node": ">=6.9.0"
}
},
"node_modules/@babel/helper-validator-identifier": {
"version": "7.29.7",
"resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.29.7.tgz",
"integrity": "sha512-qehxGkRj55h/ff8EMaJ+cYhyaKlHIxqYDn682wQD7RNp9UujOQsHog2uS0r2vzr4pW+sXf90NeeayjcNaX3fFg==",
"license": "MIT",
"peer": true,
"engines": {
"node": ">=6.9.0"
}
},
"node_modules/@babel/runtime": {
"version": "7.29.7",
"resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.29.7.tgz",
"integrity": "sha512-Nq8OhGWiZIZGV6hLHoyAKLLcJihP/xFeBMGJoUrxTX2psI8dCifzLhZISFb+VWS3wFMRDmCGw5R+dOySCqPLhw==",
"license": "MIT",
"peer": true,
"engines": {
"node": ">=6.9.0"
}
},
"node_modules/@testing-library/dom": {
"version": "10.4.1",
"resolved": "https://registry.npmjs.org/@testing-library/dom/-/dom-10.4.1.tgz",
"integrity": "sha512-o4PXJQidqJl82ckFaXUeoAW+XysPLauYI43Abki5hABd853iMhitooc6znOnczgbTYmEP6U6/y1ZyKAIsvMKGg==",
"license": "MIT",
"peer": true,
"dependencies": {
"@babel/code-frame": "^7.10.4",
"@babel/runtime": "^7.12.5",
"@types/aria-query": "^5.0.1",
"aria-query": "5.3.0",
"dom-accessibility-api": "^0.5.9",
"lz-string": "^1.5.0",
"picocolors": "1.1.1",
"pretty-format": "^27.0.2"
},
"engines": {
"node": ">=18"
}
},
"node_modules/@testing-library/user-event": {
"version": "14.6.1",
"resolved": "https://registry.npmjs.org/@testing-library/user-event/-/user-event-14.6.1.tgz",
"integrity": "sha512-vq7fv0rnt+QTXgPxr5Hjc210p6YKq2kmdziLgnsZGgLJ9e6VAShx1pACLuRjd/AS/sr7phAR58OIIpf0LlmQNw==",
"license": "MIT",
"engines": {
"node": ">=12",
"npm": ">=6"
},
"peerDependencies": {
"@testing-library/dom": ">=7.21.4"
}
},
"node_modules/@types/aria-query": {
"version": "5.0.4",
"resolved": "https://registry.npmjs.org/@types/aria-query/-/aria-query-5.0.4.tgz",
"integrity": "sha512-rfT93uj5s0PRL7EzccGMs3brplhcrghnDoV26NqKhCAS1hVo+WdNsPvE/yb6ilfr5hi2MEk6d5EWJTKdxg8jVw==",
"license": "MIT",
"peer": true
},
"node_modules/ansi-regex": {
"version": "5.0.1",
"resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz",
"integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==",
"license": "MIT",
"peer": true,
"engines": {
"node": ">=8"
}
},
"node_modules/ansi-styles": {
"version": "5.2.0",
"resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-5.2.0.tgz",
"integrity": "sha512-Cxwpt2SfTzTtXcfOlzGEee8O+c+MmUgGrNiBcXnuWxuFJHe6a5Hz7qwhwe5OgaSYI0IJvkLqWX1ASG+cJOkEiA==",
"license": "MIT",
"peer": true,
"engines": {
"node": ">=10"
},
"funding": {
"url": "https://github.com/chalk/ansi-styles?sponsor=1"
}
},
"node_modules/aria-query": {
"version": "5.3.0",
"resolved": "https://registry.npmjs.org/aria-query/-/aria-query-5.3.0.tgz",
"integrity": "sha512-b0P0sZPKtyu8HkeRAfCq0IfURZK+SuwMjY1UXGBU27wpAiTwQAIlq56IbIO+ytk/JjS1fMR14ee5WBBfKi5J6A==",
"license": "Apache-2.0",
"peer": true,
"dependencies": {
"dequal": "^2.0.3"
}
},
"node_modules/dequal": {
"version": "2.0.3",
"resolved": "https://registry.npmjs.org/dequal/-/dequal-2.0.3.tgz",
"integrity": "sha512-0je+qPKHEMohvfRTCEo3CrPG6cAzAYgmzKyxRiYSSDkS6eGJdyVJm7WaYA5ECaAD9wLB2T4EEeymA5aFVcYXCA==",
"license": "MIT",
"peer": true,
"engines": {
"node": ">=6"
}
},
"node_modules/dom-accessibility-api": {
"version": "0.5.16",
"resolved": "https://registry.npmjs.org/dom-accessibility-api/-/dom-accessibility-api-0.5.16.tgz",
"integrity": "sha512-X7BJ2yElsnOJ30pZF4uIIDfBEVgF4XEBxL9Bxhy6dnrm5hkzqmsWHGTiHqRiITNhMyFLyAiWndIJP7Z1NTteDg==",
"license": "MIT",
"peer": true
},
"node_modules/js-tokens": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz",
"integrity": "sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==",
"license": "MIT",
"peer": true
},
"node_modules/lz-string": {
"version": "1.5.0",
"resolved": "https://registry.npmjs.org/lz-string/-/lz-string-1.5.0.tgz",
"integrity": "sha512-h5bgJWpxJNswbU7qCrV0tIKQCaS3blPDrqKWx+QxzuzL1zGUzij9XCWLrSLsJPu5t+eWA/ycetzYAO5IOMcWAQ==",
"license": "MIT",
"peer": true,
"bin": {
"lz-string": "bin/bin.js"
}
},
"node_modules/picocolors": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.1.1.tgz",
"integrity": "sha512-xceH2snhtb5M9liqDsmEw56le376mTZkEX/jEb/RxNFyegNul7eNslCXP9FDj/Lcu0X8KEyMceP2ntpaHrDEVA==",
"license": "ISC",
"peer": true
},
"node_modules/pretty-format": {
"version": "27.5.1",
"resolved": "https://registry.npmjs.org/pretty-format/-/pretty-format-27.5.1.tgz",
"integrity": "sha512-Qb1gy5OrP5+zDf2Bvnzdl3jsTf1qXVMazbvCoKhtKqVs4/YK4ozX4gKQJJVyNe+cajNPn0KoC0MC3FUmaHWEmQ==",
"license": "MIT",
"peer": true,
"dependencies": {
"ansi-regex": "^5.0.1",
"ansi-styles": "^5.0.0",
"react-is": "^17.0.1"
},
"engines": {
"node": "^10.13.0 || ^12.13.0 || ^14.15.0 || >=15.0.0"
}
},
"node_modules/react-is": {
"version": "17.0.2",
"resolved": "https://registry.npmjs.org/react-is/-/react-is-17.0.2.tgz",
"integrity": "sha512-w2GsyukL62IJnlaff/nRegPQR94C/XXamvMWmSHRJ4y7Ts/4ocGRmTHvOs8PSE6pB3dWOrD/nueuU5sduBsQ4w==",
"license": "MIT",
"peer": true
}
}
}
{
"name": "sample-user-event-setup",
"version": "1.0.0",
"private": true,
"description": "Clean-room verification for userEvent.setup in @testing-library/user-event",
"dependencies": {
"@testing-library/user-event": "14.6.1"
}
}
{
"schemaVersion": 1,
"goal": "verify userEvent.setup in pkg:npm/%40testing-library/user-event@14.6.1",
"kind": "HOW",
"packages": [
"pkg:npm/%40testing-library/user-event@14.6.1"
],
"symbols": [
"userEvent.setup"
]
}
import assert from 'node:assert';
import { userEvent } from '@testing-library/user-event';
// Minimal self-contained DOM environment for Node.js clean-room execution
class MockEventTarget {
constructor() {
this._listeners = {};
}
addEventListener(type, listener, options) {
if (!this._listeners[type]) this._listeners[type] = [];
this._listeners[type].push(listener);
}
removeEventListener(type, listener, options) {
if (!this._listeners[type]) return;
this._listeners[type] = this._listeners[type].filter(l => l !== listener);
}
dispatchEvent(event) {
Object.defineProperty(event, 'target', { value: this, configurable: true, writable: true });
Object.defineProperty(event, 'currentTarget', { value: this, configurable: true, writable: true });
const list = this._listeners[event.type] || [];
for (const l of list) {
if (typeof l === 'function') l(event);
else if (l && typeof l.handleEvent === 'function') l.handleEvent(event);
}
return !event.defaultPrevented;
}
}
class MockElement extends MockEventTarget {
constructor(tagName, ownerDocument) {
super();
this.tagName = tagName.toUpperCase();
this.nodeType = 1;
this.ownerDocument = ownerDocument;
this.disabled = false;
this.children = [];
this.parentElement = null;
this.style = {};
}
focus() {}
blur() {}
hasAttribute(name) { return name === 'disabled' ? Boolean(this.disabled) : false; }
getAttribute(name) { return this.hasAttribute(name) ? '' : null; }
setAttribute(name, val) { if (name === 'disabled') this.disabled = true; }
removeAttribute(name) { if (name === 'disabled') this.disabled = false; }
matches(selector) { return false; }
closest(selector) { return null; }
querySelector(selector) { return null; }
querySelectorAll(selector) { return []; }
getBoundingClientRect() {
return { top: 0, left: 0, right: 100, bottom: 30, width: 100, height: 30, x: 0, y: 0 };
}
contains(node) {
return node === this;
}
}
class MockDocument extends MockEventTarget {
constructor() {
super();
this.nodeType = 9;
this.visibilityState = 'visible';
this.documentElement = new MockElement('HTML', this);
this.body = new MockElement('BODY', this);
this.documentElement.parentElement = null;
this.body.parentElement = this.documentElement;
this.activeElement = this.body;
this.defaultView = null;
}
createElement(tag) {
return new MockElement(tag, this);
}
createRange() {
return {
setStart: () => {},
setEnd: () => {},
commonAncestorContainer: this.body
};
}
elementFromPoint(x, y) {
return this.body;
}
hasAttribute() { return false; }
}
const mockDoc = new MockDocument();
class CustomEventClass extends globalThis.Event {
constructor(type, init = {}) {
super(type, init);
}
}
class MockMouseEvent extends CustomEventClass {}
class MockPointerEvent extends CustomEventClass {}
class MockUIEvent extends CustomEventClass {}
const mockWindow = {
document: mockDoc,
Event: CustomEventClass,
UIEvent: MockUIEvent,
MouseEvent: MockMouseEvent,
PointerEvent: MockPointerEvent,
EventTarget: globalThis.EventTarget,
navigator: { clipboard: {} },
HTMLElement: MockElement,
Element: MockElement,
Node: { ELEMENT_NODE: 1, DOCUMENT_NODE: 9 },
getComputedStyle: () => ({
visibility: 'visible',
display: 'block',
pointerEvents: 'auto'
})
};
mockDoc.defaultView = mockWindow;
globalThis.window = mockWindow;
globalThis.document = mockDoc;
globalThis.HTMLElement = MockElement;
globalThis.Element = MockElement;
globalThis.getComputedStyle = mockWindow.getComputedStyle;
// 1. userEvent.setup initializes an instance exposing user interaction methods and setup method
{
const user = userEvent.setup({ document: mockDoc });
assert.strictEqual(typeof user.setup, 'function');
assert.strictEqual(typeof user.click, 'function');
assert.strictEqual(typeof user.type, 'function');
assert.strictEqual(typeof user.keyboard, 'function');
assert.strictEqual(typeof user.pointer, 'function');
assert.strictEqual(typeof user.clear, 'function');
assert.strictEqual(typeof user.tab, 'function');
}
// 2. userEvent.setup attaches clipboard stub implementation to window navigator
{
assert.strictEqual(typeof mockWindow.navigator.clipboard.read, 'function');
assert.strictEqual(typeof mockWindow.navigator.clipboard.writeText, 'function');
}
// 3. userEvent.setup instance dispatches sequential pointer, mouse, and click events upon click
{
const user = userEvent.setup({ document: mockDoc });
const button = mockDoc.createElement('button');
mockDoc.body.children.push(button);
button.parentElement = mockDoc.body;
const events = [];
button.addEventListener('pointerdown', e => events.push(e.type));
button.addEventListener('mousedown', e => events.push(e.type));
button.addEventListener('pointerup', e => events.push(e.type));
button.addEventListener('mouseup', e => events.push(e.type));
button.addEventListener('click', e => events.push(e.type));
await user.click(button);
assert.deepStrictEqual(events, ['pointerdown', 'mousedown', 'pointerup', 'mouseup', 'click']);
}
// 4. userEvent.setup instance setup method creates sub-session with overridden options and shared state
{
const user = userEvent.setup({ document: mockDoc });
const subUser = user.setup({ delay: 10 });
assert.strictEqual(typeof subUser.setup, 'function');
assert.strictEqual(typeof subUser.click, 'function');
assert.strictEqual(typeof subUser.type, 'function');
}
console.log('Contract passed');
Seeder de origem
anônimo