CodeSampleX

샘플

@vitest/pretty-format 4.1.10: DEFAULT_OPTIONS

검증된 샘플 — npm @vitest/pretty-format 4.1.10: DEFAULT_OPTIONS. node 22 · linux debian/x64 · docker에서 contract를 실행해 통과했습니다: DEFAULT_OPTIONS exports default…

sha256:dcd6f8cabd51e63c69f97a2a256603d5c274da8dfb9b8fcd66e0f5523e6a396f

이 네트워크가 제공하는 것은 하나입니다. 빌드되는 샘플. 샌드박스에서 돌리고 서명된 영수증을 보관합니다. 등급을 매기지 않고 무엇도 보증하지 않습니다 — 같은 코드가 당신 환경에서 빌드되는지는 측정한 적이 없습니다. 통과한 계약 영수증을 낸 서로 다른 서명 키의 수입니다. 하나면 작성자 혼자이고, 둘 이상이면 다른 사람도 빌드했다는 뜻입니다. 키는 스스로 만드는 것이고 뒤에 등록된 신원이 없으므로, 세는 것은 사람이 아니라 키입니다. 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-05

케이스

HOW
목표
verify @vitest/pretty-format.DEFAULT_OPTIONS in pkg:npm/%40vitest/pretty-format@4.1.10
패키지
심벌
  • @vitest/pretty-format.DEFAULT_OPTIONS
생성일
2026-09-05T21:50:22Z

컨트랙트

  1. DEFAULT_OPTIONS exports default configuration object with expected formatting flags and numeric limits
  2. DEFAULT_OPTIONS defines default syntax theme colors for comment, content, prop, tag, and value
  3. format applies DEFAULT_OPTIONS callToJSON to invoke toJSON method by default and preserves raw object when false
  4. format applies DEFAULT_OPTIONS printBasicPrototype to prefix Object and Array headers by default and omits them when false
  5. format applies DEFAULT_OPTIONS escapeString and escapeRegex behavior for strings and regular expressions
  6. 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

소스 아티팩트 내려받기 (tar.gz)

소스

PROMPT.md
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.10
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:npm/%40vitest/pretty-format@4.1.10
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.
csx.json
{"case":{"caseId":"case:sha256:d66645a0c539988c0c4c337cf8a42dd76295c3112f690343b6ec60ad67217ca8","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.10","kind":"HOW","packages":["pkg:npm/%40vitest/pretty-format@4.1.10"],"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.10"],"schemaVersion":1,"subject":"pkg:npm/%40vitest/pretty-format@4.1.10","symbols":["@vitest/pretty-format.DEFAULT_OPTIONS"],"verifierAdapter":"node-typescript@1"}
index.mjs
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 };
}
package-lock.json
{
  "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.10"
      }
    },
    "node_modules/@vitest/pretty-format": {
      "version": "4.1.10",
      "resolved": "https://registry.npmjs.org/@vitest/pretty-format/-/pretty-format-4.1.10.tgz",
      "integrity": "sha512-W1HsjSH4MXQ9YfmmhLAoIYf1HRfekQCGngeIgcei6MP5QQGWUe0gkopdZQaVCFO+JDJMrAJGwa5pRpNpvy4P8Q==",
      "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"
      }
    }
  }
}
package.json
{
  "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.10"
  }
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify @vitest/pretty-format.DEFAULT_OPTIONS in pkg:npm/%40vitest/pretty-format@4.1.10",
  "kind": "HOW",
  "packages": [
    "pkg:npm/%40vitest/pretty-format@4.1.10"
  ],
  "symbols": [
    "@vitest/pretty-format.DEFAULT_OPTIONS"
  ]
}
test/contract.mjs
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.');

오리진 시더

익명