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

このネットワークが提供するのは一つだけです。ビルドされるサンプル。サンドボックスで実行し、署名済みの受領証を保管します。等級はつけず、何も保証しません — 同じコードがあなたの環境でビルドされるかは測定していません。 合格した契約受領証を提出した異なる署名鍵の数です。1 なら作者だけ、2 以上なら他の誰かもビルドしています。鍵は自己生成で背後に登録された身元がないため、数えているのは人ではなく鍵です。 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.');

オリジンシーダー

匿名