Exemplo
pretty-format 29.7.0: plugins
Amostra verificada para npm pretty-format 29.7.0: plugins. O contrato rodou em node 22 · linux debian/x64 · docker e passou: plugins exports built-in…
sha256:39df2d710ef44bac52ceb4a4e332f4eb2e86ab27b4f185d400d167213c23a886
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-02 |
Caso
HOW- Objetivo
- verify plugins in pkg:npm/pretty-format@29.7.0
- Pacotes
- Símbolos
-
- plugins
- Criado
- 2026-09-02T00:51:14Z
Contrato
- plugins exports built-in serializer plugins including ReactElement, ReactTestComponent, and AsymmetricMatcher
- format with plugins.ReactElement formats React element structures into JSX-like strings
- format with plugins.ReactTestComponent formats React test renderer JSON structures
- format with plugins.AsymmetricMatcher formats Jest asymmetric matchers
- format supports custom plugins implementing test and serialize hooks
- format supports recursive nested serialization with printer in custom plugins
- format applies plugins in array order where earlier matching plugins take precedence
- format ignores plugins when test returns false and falls back to default formatting
Arquivos
- PROMPT.md
- csx.json
- index.mjs
- 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 plugins in pkg:npm/pretty-format@29.7.0
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:npm/pretty-format@29.7.0
Demonstrate these symbols/APIs:
- plugins
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:16e7c8d985b2c94cc4e1d300cb4be56fb96479cabd90f0c8a04073ed4f0a28bb","contract":["plugins exports built-in serializer plugins including ReactElement, ReactTestComponent, and AsymmetricMatcher","format with plugins.ReactElement formats React element structures into JSX-like strings","format with plugins.ReactTestComponent formats React test renderer JSON structures","format with plugins.AsymmetricMatcher formats Jest asymmetric matchers","format supports custom plugins implementing test and serialize hooks","format supports recursive nested serialization with printer in custom plugins","format applies plugins in array order where earlier matching plugins take precedence","format ignores plugins when test returns false and falls back to default formatting"],"goal":"verify plugins in pkg:npm/pretty-format@29.7.0","kind":"HOW","packages":["pkg:npm/pretty-format@29.7.0"],"schemaVersion":1,"symbols":["plugins"]},"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/pretty-format@29.7.0"],"schemaVersion":1,"subject":"pkg:npm/pretty-format@29.7.0","symbols":["plugins"],"verifierAdapter":"node-typescript@1"}
import prettyFormat, { format, plugins, DEFAULT_OPTIONS } from 'pretty-format';
export { prettyFormat, format, plugins, DEFAULT_OPTIONS };
/**
* Format a value using provided plugins array.
*/
export function formatWithPlugins(value, pluginList, options = {}) {
return format(value, { ...options, plugins: pluginList });
}
/**
* Format a value using a custom test/serialize plugin.
*/
export function formatWithCustomSerializer(value, testFn, serializeFn, options = {}) {
const plugin = {
test: testFn,
serialize: serializeFn,
};
return format(value, { ...options, plugins: [plugin] });
}
/**
* Create a simple custom serializer plugin.
*/
export function createCustomPlugin(testFn, serializeFn) {
return {
test: testFn,
serialize: serializeFn,
};
}
{
"name": "sample-pretty-format-plugins",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "sample-pretty-format-plugins",
"version": "1.0.0",
"license": "MIT-0",
"dependencies": {
"pretty-format": "29.7.0"
}
},
"node_modules/@jest/schemas": {
"version": "29.6.3",
"resolved": "https://registry.npmjs.org/@jest/schemas/-/schemas-29.6.3.tgz",
"integrity": "sha512-mo5j5X+jIZmJQveBKeS/clAueipV7KgiX1vMgCxam1RNYiqE1w62n0/tJJnHtjW8ZHcQco5gY85jA3mi0L+nSA==",
"license": "MIT",
"dependencies": {
"@sinclair/typebox": "^0.27.8"
},
"engines": {
"node": "^14.15.0 || ^16.10.0 || >=18.0.0"
}
},
"node_modules/@sinclair/typebox": {
"version": "0.27.12",
"resolved": "https://registry.npmjs.org/@sinclair/typebox/-/typebox-0.27.12.tgz",
"integrity": "sha512-hhyNJ+nbR6ZR7pToHvllEFun9TL0sbL+tk/ON75lo+Xas054uez98qRbsuNt7MBCyZKK4+8Yli/OAGZhmfBZ/g==",
"license": "MIT"
},
"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",
"engines": {
"node": ">=10"
},
"funding": {
"url": "https://github.com/chalk/ansi-styles?sponsor=1"
}
},
"node_modules/pretty-format": {
"version": "29.7.0",
"resolved": "https://registry.npmjs.org/pretty-format/-/pretty-format-29.7.0.tgz",
"integrity": "sha512-Pdlw/oPxN+aXdmM9R00JVC9WVFoCLTKJvDVLgmJ+qAffBMxsV85l/Lu7sNx4zSzPyoL2euImuEwHhOXdEgNFZQ==",
"license": "MIT",
"dependencies": {
"@jest/schemas": "^29.6.3",
"ansi-styles": "^5.0.0",
"react-is": "^18.0.0"
},
"engines": {
"node": "^14.15.0 || ^16.10.0 || >=18.0.0"
}
},
"node_modules/react-is": {
"version": "18.3.1",
"resolved": "https://registry.npmjs.org/react-is/-/react-is-18.3.1.tgz",
"integrity": "sha512-/LLMVyas0ljjAtoYiPqYiL8VWXzUUdThrmU5+n20DZv+a+ClRoevUzw5JxU+Ieh5/c87ytoTBV9G1FiKfNJdmg==",
"license": "MIT"
}
}
}
{
"name": "sample-pretty-format-plugins",
"version": "1.0.0",
"description": "Clean-room verification sample for pretty-format plugins",
"type": "module",
"main": "index.mjs",
"scripts": {
"test": "node test/contract.mjs"
},
"dependencies": {
"pretty-format": "29.7.0"
},
"license": "MIT-0"
}
{
"schemaVersion": 1,
"goal": "verify plugins in pkg:npm/pretty-format@29.7.0",
"kind": "HOW",
"packages": [
"pkg:npm/pretty-format@29.7.0"
],
"symbols": [
"plugins"
]
}
import assert from 'node:assert/strict';
import prettyFormat, { format, plugins, DEFAULT_OPTIONS } from 'pretty-format';
import {
formatWithPlugins,
formatWithCustomSerializer,
createCustomPlugin,
} from '../index.mjs';
// 1. plugins exports built-in serializer plugins including ReactElement, ReactTestComponent, and AsymmetricMatcher
{
assert.equal(typeof plugins, 'object');
assert.equal(typeof plugins.ReactElement.test, 'function');
assert.equal(typeof plugins.ReactElement.serialize, 'function');
assert.equal(typeof plugins.ReactTestComponent.test, 'function');
assert.equal(typeof plugins.ReactTestComponent.serialize, 'function');
assert.equal(typeof plugins.AsymmetricMatcher.test, 'function');
assert.equal(typeof plugins.AsymmetricMatcher.serialize, 'function');
assert.equal(typeof plugins.DOMElement.test, 'function');
assert.equal(typeof plugins.DOMCollection.test, 'function');
assert.equal(typeof plugins.Immutable.test, 'function');
}
// 2. format with plugins.ReactElement formats React element structures into JSX-like strings
{
const reactEl = {
$$typeof: Symbol.for('react.element'),
type: 'div',
props: { className: 'card' },
key: null,
ref: null,
};
const result = format(reactEl, { plugins: [plugins.ReactElement] });
assert.equal(result, '<div\n className="card"\n/>');
assert.equal(formatWithPlugins(reactEl, [plugins.ReactElement]), '<div\n className="card"\n/>');
}
// 3. format with plugins.ReactTestComponent formats React test renderer JSON structures
{
const testComp = {
$$typeof: Symbol.for('react.test.json'),
type: 'button',
props: { disabled: true },
children: ['Click'],
};
const result = format(testComp, { plugins: [plugins.ReactTestComponent] });
assert.equal(result, '<button\n disabled={true}\n>\n Click\n</button>');
}
// 4. format with plugins.AsymmetricMatcher formats Jest asymmetric matchers
{
const matcher = {
$$typeof: Symbol.for('jest.asymmetricMatcher'),
asymmetricMatch: () => true,
toAsymmetricMatcher: () => 'StringMatching(/xyz/)',
};
const result = format(matcher, { plugins: [plugins.AsymmetricMatcher] });
assert.equal(result, 'StringMatching(/xyz/)');
}
// 5. format supports custom plugins implementing test and serialize hooks
{
const personPlugin = createCustomPlugin(
(val) => val && val.__type === 'Person',
(val) => `Person(${val.name}, ${val.age})`
);
const data = { user: { __type: 'Person', name: 'Bob', age: 25 } };
const result = format(data, { plugins: [personPlugin] });
assert.equal(result, 'Object {\n "user": Person(Bob, 25),\n}');
const helperResult = formatWithCustomSerializer(
data,
(val) => val && val.__type === 'Person',
(val) => `Person(${val.name}, ${val.age})`
);
assert.equal(helperResult, 'Object {\n "user": Person(Bob, 25),\n}');
}
// 6. format supports recursive nested serialization with printer in custom plugins
{
const wrapperPlugin = {
test: (val) => val && val.__type === 'Wrapper',
serialize: (val, config, indentation, depth, refs, printer) => {
return `Wrapper<${printer(val.inner, config, indentation, depth, refs)}>`;
},
};
const wrapped = { __type: 'Wrapper', inner: 42 };
assert.equal(format(wrapped, { plugins: [wrapperPlugin] }), 'Wrapper<42>');
}
// 7. format applies plugins in array order where earlier matching plugins take precedence
{
const pluginA = {
test: (val) => val && val.tag === 'special',
serialize: () => 'PluginA',
};
const pluginB = {
test: (val) => val && val.tag === 'special',
serialize: () => 'PluginB',
};
assert.equal(format({ tag: 'special' }, { plugins: [pluginA, pluginB] }), 'PluginA');
assert.equal(format({ tag: 'special' }, { plugins: [pluginB, pluginA] }), 'PluginB');
}
// 8. format ignores plugins when test returns false and falls back to default formatting
{
const noopPlugin = {
test: () => false,
serialize: () => 'Never',
};
assert.equal(format({ a: 1 }, { plugins: [noopPlugin] }), 'Object {\n "a": 1,\n}');
}
console.log('All pretty-format plugins contract assertions passed.');
Seeder de origem
anônimo