Пример
@jest/schemas 29.6.3: SnapshotFormat
Проверенный пример — npm @jest/schemas 29.6.3: SnapshotFormat. Контракт выполнен на node 22 · linux alpine/x64 · docker и пройден.
sha256:8c0d2b0603882831e77b9e349b0c5f08712a4ac4bea6ea66a159836051d931cc
Эта сеть предлагает одно: образец, который собирается. Она запустила его в песочнице и сохранила подписанную квитанцию. Она ничего не оценивает и ничего не гарантирует — собирается ли тот же код у вас, она не измеряла.
Сколько различных ключей подписи подали пройденную квитанцию контракта. Один — только автор; больше одного — значит, кто-то ещё тоже собрал. Ключ создаётся сам и не имеет зарегистрированной личности, поэтому считаются ключи, а не люди.
MIT-0
Свидетельства выполнения
Заявленное окружение и подписанные запуски разделены, чтобы вы точно видели, что этот образец запускал и где.
- Основа свидетельства
- Подписанный контракт пройден
- Квитанции проверки
- 1
- Ключи подписи, собравшие его
- 1
Заявленная среда
linux 24 · ubuntu · glibc 2.39 x64 npm
Среды запусков проверки
| Окружение | Контракт | Этапы | Запуск |
|---|---|---|---|
| node 22 · linux alpine/x64 · docker ed25519:c1973797be207ac4 | PASS | compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS CONTAINER_RUN · node-typescript@1node:22-alpine@sha256:c610fcdfb1d5… |
2026-08-27 |
Кейс
HOW- Цель
- verify @jest/schemas.SnapshotFormat in pkg:npm/%40jest/schemas@29.6.3
- Пакеты
- Символы
-
- @jest/schemas.SnapshotFormat
- Создан
- 2026-08-27T15:25:02Z
Контракт
- SnapshotFormat provides a Strict TypeBox JSON schema for Jest snapshot formatting options
- validateSnapshotFormat validates full and partial snapshot format configuration objects
- validateSnapshotFormat accepts an empty configuration object with all default/optional settings
- validateSnapshotFormat rejects negative numbers for indent, maxDepth, and maxWidth
- validateSnapshotFormat rejects invalid types and unrecognized properties not defined in SnapshotFormat
Файлы
- PROMPT.md
- csx.json
- package-lock.json
- package.json
- spec.json
- src/index.js
- test/contract.mjs
Исходный код
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 @jest/schemas.SnapshotFormat in pkg:npm/%40jest/schemas@29.6.3
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:npm/%40jest/schemas@29.6.3
Demonstrate these symbols/APIs:
- @jest/schemas.SnapshotFormat
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:d9e8174a3867d576bb7676a8870d0e827b0c30e2e98777856c01d817115877e4","contract":["SnapshotFormat provides a Strict TypeBox JSON schema for Jest snapshot formatting options","validateSnapshotFormat validates full and partial snapshot format configuration objects","validateSnapshotFormat accepts an empty configuration object with all default/optional settings","validateSnapshotFormat rejects negative numbers for indent, maxDepth, and maxWidth","validateSnapshotFormat rejects invalid types and unrecognized properties not defined in SnapshotFormat"],"goal":"verify @jest/schemas.SnapshotFormat in pkg:npm/%40jest/schemas@29.6.3","kind":"HOW","packages":["pkg:npm/%40jest/schemas@29.6.3"],"schemaVersion":1,"symbols":["@jest/schemas.SnapshotFormat"]},"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/%40jest/schemas@29.6.3"],"schemaVersion":1,"subject":"pkg:npm/%40jest/schemas@29.6.3","symbols":["@jest/schemas.SnapshotFormat"],"verifierAdapter":"node-typescript@1"}
{
"name": "verify-jest-schemas",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "verify-jest-schemas",
"version": "1.0.0",
"dependencies": {
"@jest/schemas": "29.6.3"
}
},
"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"
}
}
}
{
"name": "verify-jest-schemas",
"version": "1.0.0",
"private": true,
"description": "Verification sample for @jest/schemas SnapshotFormat",
"main": "src/index.js",
"dependencies": {
"@jest/schemas": "29.6.3"
}
}
{
"schemaVersion": 1,
"goal": "verify @jest/schemas.SnapshotFormat in pkg:npm/%40jest/schemas@29.6.3",
"kind": "HOW",
"packages": [
"pkg:npm/%40jest/schemas@29.6.3"
],
"symbols": [
"@jest/schemas.SnapshotFormat"
]
}
const { SnapshotFormat } = require('@jest/schemas');
/**
* Validates a given options object against the SnapshotFormat schema specifications.
*
* @param {Record<string, unknown>} options
* @returns {{ valid: boolean, errors: string[] }}
*/
function validateSnapshotFormat(options) {
if (typeof options !== 'object' || options === null || Array.isArray(options)) {
return {
valid: false,
errors: ['Options must be a non-null plain object']
};
}
const errors = [];
const schemaProps = SnapshotFormat.properties;
for (const key of Object.keys(options)) {
if (!Object.prototype.hasOwnProperty.call(schemaProps, key)) {
errors.push(`Unrecognized option: "${key}"`);
continue;
}
const val = options[key];
if (val === undefined) {
continue;
}
const propSchema = schemaProps[key];
if (key === 'theme') {
if (typeof val !== 'object' || val === null || Array.isArray(val)) {
errors.push('Option "theme" must be an object');
} else {
const themeProps = propSchema.properties;
for (const themeKey of Object.keys(val)) {
if (!Object.prototype.hasOwnProperty.call(themeProps, themeKey)) {
errors.push(`Unrecognized theme property: "${themeKey}"`);
} else if (val[themeKey] !== undefined && typeof val[themeKey] !== 'string') {
errors.push(`Property "theme.${themeKey}" must be a string`);
}
}
}
} else if (propSchema.type === 'boolean') {
if (typeof val !== 'boolean') {
errors.push(`Option "${key}" must be a boolean`);
}
} else if (propSchema.type === 'number') {
if (typeof val !== 'number' || Number.isNaN(val)) {
errors.push(`Option "${key}" must be a number`);
} else if (propSchema.minimum !== undefined && val < propSchema.minimum) {
errors.push(`Option "${key}" must be >= ${propSchema.minimum}`);
}
} else if (propSchema.type === 'null') {
if (val !== null) {
errors.push(`Option "${key}" must be null`);
}
}
}
return {
valid: errors.length === 0,
errors
};
}
module.exports = {
SnapshotFormat,
validateSnapshotFormat
};
import assert from 'node:assert';
import { createRequire } from 'node:module';
const require = createRequire(import.meta.url);
const { SnapshotFormat, validateSnapshotFormat } = require('../src/index.js');
// 1. SnapshotFormat provides a Strict TypeBox JSON schema for Jest snapshot formatting options
assert.strictEqual(typeof SnapshotFormat, 'object', 'SnapshotFormat schema should be an object');
assert.strictEqual(SnapshotFormat.type, 'object', 'SnapshotFormat schema type should be object');
assert.ok(SnapshotFormat.properties, 'SnapshotFormat schema should expose properties');
assert.strictEqual(typeof SnapshotFormat.properties.indent, 'object', 'SnapshotFormat indent property should be defined');
assert.strictEqual(SnapshotFormat.properties.indent.minimum, 0, 'SnapshotFormat indent minimum should be 0');
assert.strictEqual(SnapshotFormat.properties.maxDepth.minimum, 0, 'SnapshotFormat maxDepth minimum should be 0');
assert.strictEqual(SnapshotFormat.properties.maxWidth.minimum, 0, 'SnapshotFormat maxWidth minimum should be 0');
assert.strictEqual(SnapshotFormat.properties.theme.type, 'object', 'SnapshotFormat theme property should be an object');
// 2. validateSnapshotFormat validates full and partial snapshot format configuration objects
const fullValidConfig = {
callToJSON: true,
compareKeys: null,
escapeRegex: false,
escapeString: true,
highlight: true,
indent: 4,
maxDepth: 5,
maxWidth: 120,
min: false,
printBasicPrototype: false,
printFunctionName: true,
theme: {
comment: 'gray',
content: 'reset',
prop: 'yellow',
tag: 'cyan',
value: 'green'
}
};
const fullResult = validateSnapshotFormat(fullValidConfig);
assert.strictEqual(fullResult.valid, true, 'Full valid configuration should pass validation');
assert.strictEqual(fullResult.errors.length, 0, 'No errors for valid configuration');
const partialValidConfig = {
indent: 2,
printFunctionName: false
};
const partialResult = validateSnapshotFormat(partialValidConfig);
assert.strictEqual(partialResult.valid, true, 'Partial valid configuration should pass validation');
// 3. validateSnapshotFormat accepts an empty configuration object with all default/optional settings
const emptyResult = validateSnapshotFormat({});
assert.strictEqual(emptyResult.valid, true, 'Empty configuration should be valid as all fields are optional');
// 4. validateSnapshotFormat rejects negative numbers for indent, maxDepth, and maxWidth
const negativeNumbersConfig = {
indent: -1,
maxDepth: -5,
maxWidth: -10
};
const negativeResult = validateSnapshotFormat(negativeNumbersConfig);
assert.strictEqual(negativeResult.valid, false, 'Negative numeric values should fail validation');
assert.ok(negativeResult.errors.some(err => err.includes('indent')), 'Error message must mention indent');
assert.ok(negativeResult.errors.some(err => err.includes('maxDepth')), 'Error message must mention maxDepth');
assert.ok(negativeResult.errors.some(err => err.includes('maxWidth')), 'Error message must mention maxWidth');
// 5. validateSnapshotFormat rejects invalid types and unrecognized properties not defined in SnapshotFormat
const invalidTypesAndUnknownProps = {
callToJSON: 'yes',
unknownOption: 123,
theme: {
unknownThemeKey: 'red',
comment: 100
}
};
const invalidResult = validateSnapshotFormat(invalidTypesAndUnknownProps);
assert.strictEqual(invalidResult.valid, false, 'Invalid types and unknown properties should fail validation');
assert.ok(invalidResult.errors.some(err => err.includes('callToJSON')), 'Error message must mention callToJSON');
assert.ok(invalidResult.errors.some(err => err.includes('unknownOption')), 'Error message must mention unknownOption');
assert.ok(invalidResult.errors.some(err => err.includes('unknownThemeKey')), 'Error message must mention unknownThemeKey');
assert.ok(invalidResult.errors.some(err => err.includes('theme.comment')), 'Error message must mention theme.comment');
const nonObjectResult = validateSnapshotFormat(null);
assert.strictEqual(nonObjectResult.valid, false, 'Non-object input should fail validation');
console.log('All contract tests passed successfully.');
Исходный сидер
аноним