示例
@vitest/pretty-format 4.1.11: DEFAULT_OPTIONS
已验证示例 — npm @vitest/pretty-format 4.1.11: DEFAULT_OPTIONS. contract 在 node 22 · linux debian/x64 · docker 上运行并通过: DEFAULT_OPTIONS exports default…
sha256:6b72707f0a85661378346a79c62aa0cb91634170c87f55c80fe1a4941c82a630
本网络只提供一件事:能构建的样本。它在沙箱中运行并保留签名回执。它不评级、不担保——同样的代码能否在你的环境构建,它没有测量过。
提交了通过的契约回执的不同签名密钥数量。为 1 表示只有作者;大于 1 表示还有其他人构建过。密钥是自行生成的,背后没有注册身份,因此计的是密钥而非人。
MIT-0
执行证据
声明的环境与签名的运行分开呈现,你可以看到这个样本究竟运行了什么、在哪里运行。
- 证据依据
- 签名契约通过
- 验证回执
- 1
- 构建过它的签名密钥
- 1
声明的环境
linux 24 · ubuntu · glibc 2.39 x64 npm
验证运行环境
| 环境 | 契约 | 阶段 | 运行日期 |
|---|---|---|---|
| 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-06 |
案例
HOW- 目标
- verify @vitest/pretty-format.DEFAULT_OPTIONS in pkg:npm/%40vitest/pretty-format@4.1.11
- 符号
-
- @vitest/pretty-format.DEFAULT_OPTIONS
- 创建时间
- 2026-09-06T10:13:58Z
契约
- DEFAULT_OPTIONS exports default configuration object with expected formatting flags and numeric limits
- DEFAULT_OPTIONS defines default syntax theme colors for comment, content, prop, tag, and value
- format applies DEFAULT_OPTIONS callToJSON to invoke toJSON method by default and preserves raw object when false
- format applies DEFAULT_OPTIONS printBasicPrototype to prefix Object and Array headers by default and omits them when false
- format applies DEFAULT_OPTIONS escapeString and escapeRegex behavior for strings and regular expressions
- format applies DEFAULT_OPTIONS indent and min options to govern whitespace and single-line compact serialization
文件
- 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 @vitest/pretty-format.DEFAULT_OPTIONS in pkg:npm/%40vitest/pretty-format@4.1.11
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:npm/%40vitest/pretty-format@4.1.11
Demonstrate these symbols/APIs:
- @vitest/pretty-format.DEFAULT_OPTIONS
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:d4f4394e71f9894bc36cf62cc3cef90b50ee7089c96a23f8b4dd57682c7eab6a","contract":["DEFAULT_OPTIONS exports default configuration object with expected formatting flags and numeric limits","DEFAULT_OPTIONS defines default syntax theme colors for comment, content, prop, tag, and value","format applies DEFAULT_OPTIONS callToJSON to invoke toJSON method by default and preserves raw object when false","format applies DEFAULT_OPTIONS printBasicPrototype to prefix Object and Array headers by default and omits them when false","format applies DEFAULT_OPTIONS escapeString and escapeRegex behavior for strings and regular expressions","format applies DEFAULT_OPTIONS indent and min options to govern whitespace and single-line compact serialization"],"goal":"verify @vitest/pretty-format.DEFAULT_OPTIONS in pkg:npm/%40vitest/pretty-format@4.1.11","kind":"HOW","packages":["pkg:npm/%40vitest/pretty-format@4.1.11"],"schemaVersion":1,"symbols":["@vitest/pretty-format.DEFAULT_OPTIONS"]},"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/%40vitest/pretty-format@4.1.11"],"schemaVersion":1,"subject":"pkg:npm/%40vitest/pretty-format@4.1.11","symbols":["@vitest/pretty-format.DEFAULT_OPTIONS"],"verifierAdapter":"node-typescript@1"}
import { DEFAULT_OPTIONS, format, plugins } from '@vitest/pretty-format';
export { DEFAULT_OPTIONS, format, plugins };
export function formatWithDefaultOptions(value, overrides = {}) {
return format(value, { ...DEFAULT_OPTIONS, ...overrides });
}
export function getDefaultOptions() {
return { ...DEFAULT_OPTIONS };
}
{
"name": "sample-vitest-pretty-format-default-options",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "sample-vitest-pretty-format-default-options",
"version": "1.0.0",
"license": "MIT-0",
"dependencies": {
"@vitest/pretty-format": "4.1.11"
}
},
"node_modules/@vitest/pretty-format": {
"version": "4.1.11",
"resolved": "https://registry.npmjs.org/@vitest/pretty-format/-/pretty-format-4.1.11.tgz",
"integrity": "sha512-yiZzPbGTS9Sr/JpFl8zHrcIkAofNbFV6k21vIgQN/cY/oxZeXhJv5sc/MBJ5jFKWmWs+oJHw0UXLZjmf931+Vw==",
"license": "MIT",
"dependencies": {
"tinyrainbow": "^3.1.0"
},
"funding": {
"url": "https://opencollective.com/vitest"
}
},
"node_modules/tinyrainbow": {
"version": "3.1.1",
"resolved": "https://registry.npmjs.org/tinyrainbow/-/tinyrainbow-3.1.1.tgz",
"integrity": "sha512-yau8yJdTt989Mm0Bd/236QnzEiPf2xLLTqUZRUJOo/3CB078LSwzei343DgtJVmfJKJE3TMINY1u42SQsP6mXw==",
"license": "MIT",
"engines": {
"node": ">=14.0.0"
}
}
}
}
{
"name": "sample-vitest-pretty-format-default-options",
"version": "1.0.0",
"description": "Clean-room verification sample for @vitest/pretty-format DEFAULT_OPTIONS",
"type": "module",
"main": "index.mjs",
"scripts": {
"test": "node test/contract.mjs"
},
"dependencies": {
"@vitest/pretty-format": "4.1.11"
}
}
{
"schemaVersion": 1,
"goal": "verify @vitest/pretty-format.DEFAULT_OPTIONS in pkg:npm/%40vitest/pretty-format@4.1.11",
"kind": "HOW",
"packages": [
"pkg:npm/%40vitest/pretty-format@4.1.11"
],
"symbols": [
"@vitest/pretty-format.DEFAULT_OPTIONS"
]
}
import assert from 'node:assert/strict';
import { DEFAULT_OPTIONS, format } from '@vitest/pretty-format';
import { formatWithDefaultOptions, getDefaultOptions } from '../index.mjs';
// 1. DEFAULT_OPTIONS exports default configuration object with expected formatting flags and numeric limits
{
assert.equal(typeof DEFAULT_OPTIONS, 'object');
assert.notEqual(DEFAULT_OPTIONS, null);
assert.equal(DEFAULT_OPTIONS.callToJSON, true);
assert.equal(DEFAULT_OPTIONS.indent, 2);
assert.equal(DEFAULT_OPTIONS.maxDepth, Infinity);
assert.equal(DEFAULT_OPTIONS.maxWidth, Infinity);
assert.equal(DEFAULT_OPTIONS.maxOutputLength, 1000000);
assert.equal(DEFAULT_OPTIONS.min, false);
assert.equal(DEFAULT_OPTIONS.printFunctionName, true);
assert.equal(DEFAULT_OPTIONS.printBasicPrototype, true);
assert.equal(DEFAULT_OPTIONS.printShadowRoot, true);
assert.equal(DEFAULT_OPTIONS.highlight, false);
assert.equal(DEFAULT_OPTIONS.escapeRegex, false);
assert.equal(DEFAULT_OPTIONS.escapeString, true);
assert.equal(DEFAULT_OPTIONS.compareKeys, undefined);
assert.ok(Array.isArray(DEFAULT_OPTIONS.plugins));
assert.equal(DEFAULT_OPTIONS.plugins.length, 0);
const copied = getDefaultOptions();
assert.equal(copied.indent, 2);
assert.equal(copied.callToJSON, true);
}
// 2. DEFAULT_OPTIONS defines default syntax theme colors for comment, content, prop, tag, and value
{
assert.equal(typeof DEFAULT_OPTIONS.theme, 'object');
assert.notEqual(DEFAULT_OPTIONS.theme, null);
assert.equal(DEFAULT_OPTIONS.theme.comment, 'gray');
assert.equal(DEFAULT_OPTIONS.theme.content, 'reset');
assert.equal(DEFAULT_OPTIONS.theme.prop, 'yellow');
assert.equal(DEFAULT_OPTIONS.theme.tag, 'cyan');
assert.equal(DEFAULT_OPTIONS.theme.value, 'green');
}
// 3. format applies DEFAULT_OPTIONS callToJSON to invoke toJSON method by default and preserves raw object when false
{
const obj = {
raw: 'data',
toJSON() {
return { converted: true };
},
};
const defaultFormatted = format(obj);
assert.ok(defaultFormatted.includes('"converted": true'));
assert.ok(!defaultFormatted.includes('"raw": "data"'));
const rawFormatted = format(obj, { callToJSON: false });
assert.ok(rawFormatted.includes('"raw": "data"'));
const helperFormatted = formatWithDefaultOptions(obj);
assert.ok(helperFormatted.includes('"converted": true'));
}
// 4. format applies DEFAULT_OPTIONS printBasicPrototype to prefix Object and Array headers by default and omits them when false
{
const obj = { a: 1 };
assert.ok(format(obj).startsWith('Object {'));
assert.ok(format(obj, { printBasicPrototype: false }).startsWith('{'));
const arr = [1];
assert.ok(format(arr).startsWith('Array ['));
assert.ok(format(arr, { printBasicPrototype: false }).startsWith('['));
}
// 5. format applies DEFAULT_OPTIONS escapeString and escapeRegex behavior for strings and regular expressions
{
const str = 'quote " test';
assert.equal(format(str), '"quote \\" test"');
assert.equal(format(str, { escapeString: false }), '"quote " test"');
const regex = /a+b/;
assert.equal(format(regex), '/a+b/');
assert.equal(format(regex, { escapeRegex: true }), '/a\\+b/');
}
// 6. format applies DEFAULT_OPTIONS indent and min options to govern whitespace and single-line compact serialization
{
const data = { key: 1 };
assert.equal(format(data), 'Object {\n "key": 1,\n}');
assert.equal(format(data, { indent: 4 }), 'Object {\n "key": 1,\n}');
assert.equal(format(data, { min: true }), '{"key": 1}');
}
console.log('All @vitest/pretty-format.DEFAULT_OPTIONS contract assertions passed.');
原始种子者
匿名