Пример
jest-util 29.7.0
Проверенный пример — npm jest-util 29.7.0. Контракт выполнен на node 22 · linux alpine/x64 · docker и пройден: pluralize formats singular and plural counts…
sha256:491dc51907d29eb7eca1853d64791d280a6cdfb87a9342f12dfe2d19179f8574
Эта сеть предлагает одно: образец, который собирается. Она запустила его в песочнице и сохранила подписанную квитанцию. Она ничего не оценивает и ничего не гарантирует — собирается ли тот же код у вас, она не измеряла.
Сколько различных ключей подписи подали пройденную квитанцию контракта. Один — только автор; больше одного — значит, кто-то ещё тоже собрал. Ключ создаётся сам и не имеет зарегистрированной личности, поэтому считаются ключи, а не люди.
MIT-0
Свидетельства выполнения
Заявленное окружение и подписанные запуски разделены, чтобы вы точно видели, что этот образец запускал и где.
- Основа свидетельства
- Подписанный контракт пройден
- Квитанции проверки
- 1
- Ключи подписи, собравшие его
- 1
Заявленная среда
node 22.23 linux 24 · ubuntu · glibc 2.39 x64 node 22.23 javascript npm 10
Среды запусков проверки
| Окружение | Контракт | Этапы | Запуск |
|---|---|---|---|
| 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 pkg:npm/jest-util@29.7.0
- Пакеты
- Окружение
- node 22.23.2
- Создан
- 2026-08-27T15:27:38Z
Контракт
- pluralize formats singular and plural counts with given words
- formatTime formats millisecond and microsecond durations with metric prefix units and padding
- replacePathSepForGlob normalizes Windows backslash path separators to POSIX forward slashes
- globsToMatcher converts an array of glob strings into a matching function
- isPromise distinguishes Promises and thenables from non-promise values
- isNonNullable identifies non-null and non-undefined values
- deepCyclicCopy creates a deep copy of complex objects preserving circular and nested references
- ErrorWithStack constructs an Error instance capturing stack trace at the specified callsite
- convertDescriptorToString stringifies named functions, classes, and primitives while rejecting unsupported objects
- interopRequireDefault normalizes CommonJS and ES module default exports
- invariant asserts truthy conditions and throws Error with given message on falsy conditions
- specialChars provides terminal formatting escape sequences and status icons
- testPathPatternToRegExp converts string pattern into case-insensitive regular expression
- tryRealpath resolves existing filesystem path or falls back to original path
Файлы
- PROMPT.md
- csx.json
- index.mjs
- package-lock.json
- package.json
- spec.json
- 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 pkg:npm/jest-util@29.7.0
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:npm/jest-util@29.7.0
Constraints:
- executionContext: node
Required runtime conditions:
- ecosystem: npm
- language: javascript
- moduleSystem: cjs
- packageManager: npm@10.9.8
- runtime: node@22.23.2
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:1693978ab74ec9bcc7381db959decb3d33a0f22ee83ccb049547ae5abcb88e14","constraints":{"executionContext":"node"},"contract":["pluralize formats singular and plural counts with given words","formatTime formats millisecond and microsecond durations with metric prefix units and padding","replacePathSepForGlob normalizes Windows backslash path separators to POSIX forward slashes","globsToMatcher converts an array of glob strings into a matching function","isPromise distinguishes Promises and thenables from non-promise values","isNonNullable identifies non-null and non-undefined values","deepCyclicCopy creates a deep copy of complex objects preserving circular and nested references","ErrorWithStack constructs an Error instance capturing stack trace at the specified callsite","convertDescriptorToString stringifies named functions, classes, and primitives while rejecting unsupported objects","interopRequireDefault normalizes CommonJS and ES module default exports","invariant asserts truthy conditions and throws Error with given message on falsy conditions","specialChars provides terminal formatting escape sequences and status icons","testPathPatternToRegExp converts string pattern into case-insensitive regular expression","tryRealpath resolves existing filesystem path or falls back to original path"],"goal":"verify pkg:npm/jest-util@29.7.0","kind":"HOW","packages":["pkg:npm/jest-util@29.7.0"],"schemaVersion":1},"contractCommand":["node","test/contract.mjs"],"environment":{"arch":"x64","distro":"ubuntu","ecosystem":"npm","executionContext":"node","language":"javascript","libc":"glibc","libcVersion":"2.39","moduleSystem":"cjs","os":"linux","osVersionBucket":"24","packageManager":"npm","packageManagerVersion":"10.9.8","runtime":"node","runtimeVersion":"22.23.2","schemaVersion":1},"license":"MIT-0","packages":["pkg:npm/jest-util@29.7.0"],"schemaVersion":1,"subject":"pkg:npm/jest-util@29.7.0","verifierAdapter":"node-typescript@1"}
import {
pluralize,
formatTime,
replacePathSepForGlob,
globsToMatcher,
isPromise,
isNonNullable,
deepCyclicCopy,
ErrorWithStack,
convertDescriptorToString,
interopRequireDefault,
invariant,
specialChars,
testPathPatternToRegExp,
tryRealpath
} from 'jest-util';
export {
pluralize,
formatTime,
replacePathSepForGlob,
globsToMatcher,
isPromise,
isNonNullable,
deepCyclicCopy,
ErrorWithStack,
convertDescriptorToString,
interopRequireDefault,
invariant,
specialChars,
testPathPatternToRegExp,
tryRealpath
};
export function formatDurationSummary(count, durationMs) {
const countStr = pluralize('test', count);
const timeStr = formatTime(durationMs);
return `${countStr} completed in ${timeStr}`;
}
{
"name": "sample-jest-util",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "sample-jest-util",
"version": "1.0.0",
"dependencies": {
"jest-util": "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/@jest/types": {
"version": "29.6.3",
"resolved": "https://registry.npmjs.org/@jest/types/-/types-29.6.3.tgz",
"integrity": "sha512-u3UPsIilWKOM3F9CXtrG8LEJmNxwoCQC/XVj4IKYXvvpx7QIi/Kg1LI5uDmDpKlac62NUtX7eLjRh+jVZcLOzw==",
"license": "MIT",
"dependencies": {
"@jest/schemas": "^29.6.3",
"@types/istanbul-lib-coverage": "^2.0.0",
"@types/istanbul-reports": "^3.0.0",
"@types/node": "*",
"@types/yargs": "^17.0.8",
"chalk": "^4.0.0"
},
"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/@types/istanbul-lib-coverage": {
"version": "2.0.6",
"resolved": "https://registry.npmjs.org/@types/istanbul-lib-coverage/-/istanbul-lib-coverage-2.0.6.tgz",
"integrity": "sha512-2QF/t/auWm0lsy8XtKVPG19v3sSOQlJe/YHZgfjb/KBBHOGSV+J2q/S671rcq9uTBrLAXmZpqJiaQbMT+zNU1w==",
"license": "MIT"
},
"node_modules/@types/istanbul-lib-report": {
"version": "3.0.3",
"resolved": "https://registry.npmjs.org/@types/istanbul-lib-report/-/istanbul-lib-report-3.0.3.tgz",
"integrity": "sha512-NQn7AHQnk/RSLOxrBbGyJM/aVQ+pjj5HCgasFxc0K/KhoATfQ/47AyUl15I2yBUpihjmas+a+VJBOqecrFH+uA==",
"license": "MIT",
"dependencies": {
"@types/istanbul-lib-coverage": "*"
}
},
"node_modules/@types/istanbul-reports": {
"version": "3.0.4",
"resolved": "https://registry.npmjs.org/@types/istanbul-reports/-/istanbul-reports-3.0.4.tgz",
"integrity": "sha512-pk2B1NWalF9toCRu6gjBzR69syFjP4Od8WRAX+0mmf9lAjCRicLOWc+ZrxZHx/0XRjotgkF9t6iaMJ+aXcOdZQ==",
"license": "MIT",
"dependencies": {
"@types/istanbul-lib-report": "*"
}
},
"node_modules/@types/node": {
"version": "26.4.0",
"resolved": "https://registry.npmjs.org/@types/node/-/node-26.4.0.tgz",
"integrity": "sha512-faiGnoIrLH/V8cibOMEAZ8pMw6oXqSukl29ra4mN8GdaB2ZewzeaLj+INpV5N+Z1eKWzY+IzaIZH2EIR6YZRNQ==",
"license": "MIT",
"dependencies": {
"undici-types": "~8.3.0"
}
},
"node_modules/@types/yargs": {
"version": "17.0.35",
"resolved": "https://registry.npmjs.org/@types/yargs/-/yargs-17.0.35.tgz",
"integrity": "sha512-qUHkeCyQFxMXg79wQfTtfndEC+N9ZZg76HJftDJp+qH2tV7Gj4OJi7l+PiWwJ+pWtW8GwSmqsDj/oymhrTWXjg==",
"license": "MIT",
"dependencies": {
"@types/yargs-parser": "*"
}
},
"node_modules/@types/yargs-parser": {
"version": "21.0.3",
"resolved": "https://registry.npmjs.org/@types/yargs-parser/-/yargs-parser-21.0.3.tgz",
"integrity": "sha512-I4q9QU9MQv4oEOz4tAHJtNz1cwuLxn2F3xcc2iV5WdqLPpUnj30aUuxt1mAxYTG+oe8CZMV/+6rU4S4gRDzqtQ==",
"license": "MIT"
},
"node_modules/ansi-styles": {
"version": "4.3.0",
"resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz",
"integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==",
"license": "MIT",
"dependencies": {
"color-convert": "^2.0.1"
},
"engines": {
"node": ">=8"
},
"funding": {
"url": "https://github.com/chalk/ansi-styles?sponsor=1"
}
},
"node_modules/chalk": {
"version": "4.1.2",
"resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz",
"integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==",
"license": "MIT",
"dependencies": {
"ansi-styles": "^4.1.0",
"supports-color": "^7.1.0"
},
"engines": {
"node": ">=10"
},
"funding": {
"url": "https://github.com/chalk/chalk?sponsor=1"
}
},
"node_modules/ci-info": {
"version": "3.9.0",
"resolved": "https://registry.npmjs.org/ci-info/-/ci-info-3.9.0.tgz",
"integrity": "sha512-NIxF55hv4nSqQswkAeiOi1r83xy8JldOFDTWiug55KBu9Jnblncd2U6ViHmYgHf01TPZS77NJBhBMKdWj9HQMQ==",
"funding": [
{
"type": "github",
"url": "https://github.com/sponsors/sibiraj-s"
}
],
"license": "MIT",
"engines": {
"node": ">=8"
}
},
"node_modules/color-convert": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz",
"integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==",
"license": "MIT",
"dependencies": {
"color-name": "~1.1.4"
},
"engines": {
"node": ">=7.0.0"
}
},
"node_modules/color-name": {
"version": "1.1.4",
"resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz",
"integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==",
"license": "MIT"
},
"node_modules/graceful-fs": {
"version": "4.2.11",
"resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.11.tgz",
"integrity": "sha512-RbJ5/jmFcNNCcDV5o9eTnBLJ/HszWV0P73bc+Ff4nS/rJj+YaS6IGyiOL0VoBYX+l1Wrl3k63h/KrH+nhJ0XvQ==",
"license": "ISC"
},
"node_modules/has-flag": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz",
"integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==",
"license": "MIT",
"engines": {
"node": ">=8"
}
},
"node_modules/jest-util": {
"version": "29.7.0",
"resolved": "https://registry.npmjs.org/jest-util/-/jest-util-29.7.0.tgz",
"integrity": "sha512-z6EbKajIpqGKU56y5KBUgy1dt1ihhQJgWzUlZHArA/+X2ad7Cb5iF+AK1EWVL/Bo7Rz9uurpqw6SiBCefUbCGA==",
"license": "MIT",
"dependencies": {
"@jest/types": "^29.6.3",
"@types/node": "*",
"chalk": "^4.0.0",
"ci-info": "^3.2.0",
"graceful-fs": "^4.2.9",
"picomatch": "^2.2.3"
},
"engines": {
"node": "^14.15.0 || ^16.10.0 || >=18.0.0"
}
},
"node_modules/picomatch": {
"version": "2.3.2",
"resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.2.tgz",
"integrity": "sha512-V7+vQEJ06Z+c5tSye8S+nHUfI51xoXIXjHQ99cQtKUkQqqO1kO/KCJUfZXuB47h/YBlDhah2H3hdUGXn8ie0oA==",
"license": "MIT",
"engines": {
"node": ">=8.6"
},
"funding": {
"url": "https://github.com/sponsors/jonschlinkert"
}
},
"node_modules/supports-color": {
"version": "7.2.0",
"resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz",
"integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==",
"license": "MIT",
"dependencies": {
"has-flag": "^4.0.0"
},
"engines": {
"node": ">=8"
}
},
"node_modules/undici-types": {
"version": "8.3.0",
"resolved": "https://registry.npmjs.org/undici-types/-/undici-types-8.3.0.tgz",
"integrity": "sha512-j375ScV60dom+YkPFIfTLcOiPxkN/buHz5GobjLhixFuANaNs3C9l4GmrWqejgXWJ7BbJcFYpTEUkS1Ge8bpZQ==",
"license": "MIT"
}
}
}
{
"name": "sample-jest-util",
"version": "1.0.0",
"description": "Clean-room verification sample for jest-util",
"type": "module",
"main": "index.mjs",
"scripts": {
"test": "node test/contract.mjs"
},
"dependencies": {
"jest-util": "29.7.0"
}
}
{
"schemaVersion": 1,
"goal": "verify pkg:npm/jest-util@29.7.0",
"kind": "HOW",
"packages": [
"pkg:npm/jest-util@29.7.0"
],
"constraints": {
"executionContext": "node"
},
"runtimeConditions": {
"ecosystem": "npm",
"language": "javascript",
"moduleSystem": "cjs",
"packageManager": "npm@10.9.8",
"runtime": "node@22.23.2"
}
}
import assert from 'node:assert/strict';
import {
pluralize,
formatTime,
replacePathSepForGlob,
globsToMatcher,
isPromise,
isNonNullable,
deepCyclicCopy,
ErrorWithStack,
convertDescriptorToString,
interopRequireDefault,
invariant,
specialChars,
testPathPatternToRegExp,
tryRealpath
} from 'jest-util';
import { formatDurationSummary } from '../index.mjs';
// 1. pluralize formats singular and plural counts with given words
{
assert.equal(pluralize('item', 1), '1 item');
assert.equal(pluralize('item', 0), '0 items');
assert.equal(pluralize('item', 2), '2 items');
}
// 2. formatTime formats millisecond and microsecond durations with metric prefix units and padding
{
assert.equal(formatTime(250), '250 ms');
assert.equal(formatTime(5, 0), '5 s');
assert.equal(formatTime(10, -6), '10 μs');
assert.equal(formatTime(100, -9), '100 ns');
assert.equal(formatTime(42, -3, 6), ' 42 ms');
}
// 3. replacePathSepForGlob normalizes Windows backslash path separators to POSIX forward slashes
{
assert.equal(replacePathSepForGlob('foo\\bar\\baz'), 'foo/bar/baz');
assert.equal(replacePathSepForGlob('nested\\dir\\file.js'), 'nested/dir/file.js');
assert.equal(replacePathSepForGlob('already/forward/slash'), 'already/forward/slash');
}
// 4. globsToMatcher converts an array of glob strings into a matching function
{
const matcher = globsToMatcher(['**/*.spec.ts', 'src/**/*.js']);
assert.equal(matcher('test/unit/app.spec.ts'), true);
assert.equal(matcher('src/utils/math.js'), true);
assert.equal(matcher('docs/readme.md'), false);
}
// 5. isPromise distinguishes Promises and thenables from non-promise values
{
assert.equal(isPromise(Promise.resolve(1)), true);
assert.equal(isPromise({ then: () => {} }), true);
assert.equal(isPromise({}), false);
assert.equal(isPromise(null), false);
assert.equal(isPromise(123), false);
assert.equal(isPromise('promise'), false);
}
// 6. isNonNullable identifies non-null and non-undefined values
{
assert.equal(isNonNullable(0), true);
assert.equal(isNonNullable(''), true);
assert.equal(isNonNullable(false), true);
assert.equal(isNonNullable(null), false);
assert.equal(isNonNullable(undefined), false);
}
// 7. deepCyclicCopy creates a deep copy of complex objects preserving circular and nested references
{
const original = { a: 1, nested: { b: 2 } };
original.self = original;
original.nested.parent = original;
const copy = deepCyclicCopy(original);
assert.equal(copy.a, 1);
assert.equal(copy.nested.b, 2);
assert.equal(copy.self, copy);
assert.equal(copy.nested.parent, copy);
assert.notEqual(copy, original);
assert.notEqual(copy.nested, original.nested);
}
// 8. ErrorWithStack constructs an Error instance capturing stack trace at the specified callsite
{
function createCustomError() {
return new ErrorWithStack('sample error message', createCustomError);
}
const err = createCustomError();
assert.ok(err instanceof Error);
assert.equal(err.message, 'sample error message');
assert.ok(typeof err.stack === 'string');
}
// 9. convertDescriptorToString stringifies named functions, classes, and primitives while rejecting unsupported objects
{
function namedFunc() {}
class SampleClass {}
assert.equal(convertDescriptorToString(namedFunc), 'namedFunc');
assert.equal(convertDescriptorToString(SampleClass), 'SampleClass');
assert.equal(convertDescriptorToString('customString'), 'customString');
assert.equal(convertDescriptorToString(42), '42');
assert.equal(convertDescriptorToString(undefined), 'undefined');
assert.throws(() => convertDescriptorToString({}), /Invalid first argument/);
}
// 10. interopRequireDefault normalizes CommonJS and ES module default exports
{
const esmModule = { __esModule: true, default: { key: 'value' } };
const cjsModule = { key: 'value' };
assert.deepEqual(interopRequireDefault(esmModule), esmModule);
assert.deepEqual(interopRequireDefault(cjsModule), { default: cjsModule });
}
// 11. invariant asserts truthy conditions and throws Error with given message on falsy conditions
{
assert.doesNotThrow(() => invariant(true, 'should not throw'));
assert.throws(() => invariant(false, 'invariant check failed'), /invariant check failed/);
}
// 12. specialChars provides terminal formatting escape sequences and status icons
{
assert.equal(specialChars.ARROW, ' \u203A ');
assert.equal(specialChars.ICONS.success, '✓');
assert.equal(specialChars.ICONS.failed, '✕');
assert.equal(specialChars.ICONS.pending, '○');
assert.equal(specialChars.ICONS.todo, '✎');
assert.ok(typeof specialChars.CLEAR === 'string');
}
// 13. testPathPatternToRegExp converts string pattern into case-insensitive regular expression
{
const regex = testPathPatternToRegExp('src/components/.*\\.test\\.js');
assert.ok(regex instanceof RegExp);
assert.equal(regex.ignoreCase, true);
assert.ok(regex.test('src/components/Button.test.js'));
assert.ok(regex.test('SRC/COMPONENTS/BUTTON.TEST.JS'));
assert.equal(regex.test('docs/Button.test.js'), false);
}
// 14. tryRealpath resolves existing filesystem path or falls back to original path
{
const resolved = tryRealpath('.');
assert.ok(typeof resolved === 'string');
assert.ok(resolved.length > 0);
const nonExistent = '/non/existent/path/for/realpath/test';
assert.equal(tryRealpath(nonExistent), nonExistent);
}
// Helper test
{
const summary = formatDurationSummary(3, 1500);
assert.equal(summary, '3 tests completed in 1500 ms');
}
console.log('All jest-util contract assertions passed.');
Исходный сидер
аноним