샘플
@vitest/expect 2.1.9
검증된 샘플 — npm @vitest/expect 2.1.9. node 22 · linux alpine/x64 · docker에서 contract를 실행해 통과했습니다: createExpect configures Chai with JestChaiExpect…
sha256:ea3e58697c025ec150af6fb42101442beac0e1d8063debe03252b73ed394311f
이 네트워크가 제공하는 것은 하나입니다. 빌드되는 샘플. 샌드박스에서 돌리고 서명된 영수증을 보관합니다. 등급을 매기지 않고 무엇도 보증하지 않습니다 — 같은 코드가 당신 환경에서 빌드되는지는 측정한 적이 없습니다.
통과한 계약 영수증을 낸 서로 다른 서명 키의 수입니다. 하나면 작성자 혼자이고, 둘 이상이면 다른 사람도 빌드했다는 뜻입니다. 키는 스스로 만드는 것이고 뒤에 등록된 신원이 없으므로, 세는 것은 사람이 아니라 키입니다.
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-26 |
케이스
HOW- 목표
- verify pkg:npm/%40vitest/expect@2.1.9
- 환경
- node 22.23.2
- 생성일
- 2026-08-26T14:41:21Z
컨트랙트
- createExpect configures Chai with JestChaiExpect, JestAsymmetricMatchers, and JestExtend
- toBe and toEqual perform primitive value and deep equality assertions
- toMatchObject and toHaveProperty verify subset structures and nested object properties
- toContain and toContainEqual assert element presence in arrays and strings
- toBeGreaterThan, toBeLessThan, and toBeCloseTo validate numeric relationships and floating point values
- toBeTypeOf and toSatisfy evaluate type classifications and custom predicate functions
- toThrow verifies exception throwing and error type matching
- Asymmetric matchers StringContaining, StringMatching, ObjectContaining, and ArrayContaining match partial values
- expect.extend registers custom matchers with custom pass and failure message logic
- getState and setState inspect and update matcher execution context
파일
- 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/%40vitest/expect@2.1.9
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:npm/%40vitest/expect@2.1.9
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:08b007b06b5c54ddf5c834e4b5ea36f69c53f0cd36830c5464621d1787642874","constraints":{"executionContext":"node"},"contract":["createExpect configures Chai with JestChaiExpect, JestAsymmetricMatchers, and JestExtend","toBe and toEqual perform primitive value and deep equality assertions","toMatchObject and toHaveProperty verify subset structures and nested object properties","toContain and toContainEqual assert element presence in arrays and strings","toBeGreaterThan, toBeLessThan, and toBeCloseTo validate numeric relationships and floating point values","toBeTypeOf and toSatisfy evaluate type classifications and custom predicate functions","toThrow verifies exception throwing and error type matching","Asymmetric matchers StringContaining, StringMatching, ObjectContaining, and ArrayContaining match partial values","expect.extend registers custom matchers with custom pass and failure message logic","getState and setState inspect and update matcher execution context"],"goal":"verify pkg:npm/%40vitest/expect@2.1.9","kind":"HOW","packages":["pkg:npm/%40vitest/expect@2.1.9"],"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/%40vitest/expect@2.1.9"],"schemaVersion":1,"subject":"pkg:npm/%40vitest/expect@2.1.9","verifierAdapter":"node-typescript@1"}
import * as chai from 'chai';
import {
JestChaiExpect,
JestAsymmetricMatchers,
JestExtend,
getState,
setState,
equals,
isA,
isAsymmetric,
hasAsymmetric,
StringContaining,
StringMatching,
ObjectContaining,
ArrayContaining,
Any,
Anything,
addCustomEqualityTesters,
getObjectSubset
} from '@vitest/expect';
export function createExpect() {
chai.use(JestChaiExpect);
chai.use(JestAsymmetricMatchers);
chai.use(JestExtend);
return chai.expect;
}
export const expect = createExpect();
export function extendExpect(expectInstance, customMatchers) {
expectInstance.extend(expectInstance, customMatchers);
}
export {
JestChaiExpect,
JestAsymmetricMatchers,
JestExtend,
getState,
setState,
equals,
isA,
isAsymmetric,
hasAsymmetric,
StringContaining,
StringMatching,
ObjectContaining,
ArrayContaining,
Any,
Anything,
addCustomEqualityTesters,
getObjectSubset
};
{
"name": "sample-vitest-expect",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "sample-vitest-expect",
"version": "1.0.0",
"dependencies": {
"@vitest/expect": "2.1.9"
}
},
"node_modules/@vitest/expect": {
"version": "2.1.9",
"resolved": "https://registry.npmjs.org/@vitest/expect/-/expect-2.1.9.tgz",
"integrity": "sha512-UJCIkTBenHeKT1TTlKMJWy1laZewsRIzYighyYiJKZreqtdxSos/S1t+ktRMQWu2CKqaarrkeszJx1cgC5tGZw==",
"license": "MIT",
"dependencies": {
"@vitest/spy": "2.1.9",
"@vitest/utils": "2.1.9",
"chai": "^5.1.2",
"tinyrainbow": "^1.2.0"
},
"funding": {
"url": "https://opencollective.com/vitest"
}
},
"node_modules/@vitest/pretty-format": {
"version": "2.1.9",
"resolved": "https://registry.npmjs.org/@vitest/pretty-format/-/pretty-format-2.1.9.tgz",
"integrity": "sha512-KhRIdGV2U9HOUzxfiHmY8IFHTdqtOhIzCpd8WRdJiE7D/HUcZVD0EgQCVjm+Q9gkUXWgBvMmTtZgIG48wq7sOQ==",
"license": "MIT",
"dependencies": {
"tinyrainbow": "^1.2.0"
},
"funding": {
"url": "https://opencollective.com/vitest"
}
},
"node_modules/@vitest/spy": {
"version": "2.1.9",
"resolved": "https://registry.npmjs.org/@vitest/spy/-/spy-2.1.9.tgz",
"integrity": "sha512-E1B35FwzXXTs9FHNK6bDszs7mtydNi5MIfUWpceJ8Xbfb1gBMscAnwLbEu+B44ed6W3XjL9/ehLPHR1fkf1KLQ==",
"license": "MIT",
"dependencies": {
"tinyspy": "^3.0.2"
},
"funding": {
"url": "https://opencollective.com/vitest"
}
},
"node_modules/@vitest/utils": {
"version": "2.1.9",
"resolved": "https://registry.npmjs.org/@vitest/utils/-/utils-2.1.9.tgz",
"integrity": "sha512-v0psaMSkNJ3A2NMrUEHFRzJtDPFn+/VWZ5WxImB21T9fjucJRmS7xCS3ppEnARb9y11OAzaD+P2Ps+b+BGX5iQ==",
"license": "MIT",
"dependencies": {
"@vitest/pretty-format": "2.1.9",
"loupe": "^3.1.2",
"tinyrainbow": "^1.2.0"
},
"funding": {
"url": "https://opencollective.com/vitest"
}
},
"node_modules/assertion-error": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/assertion-error/-/assertion-error-2.0.1.tgz",
"integrity": "sha512-Izi8RQcffqCeNVgFigKli1ssklIbpHnCYc6AknXGYoB6grJqyeby7jv12JUQgmTAnIDnbck1uxksT4dzN3PWBA==",
"license": "MIT",
"engines": {
"node": ">=12"
}
},
"node_modules/chai": {
"version": "5.3.3",
"resolved": "https://registry.npmjs.org/chai/-/chai-5.3.3.tgz",
"integrity": "sha512-4zNhdJD/iOjSH0A05ea+Ke6MU5mmpQcbQsSOkgdaUMJ9zTlDTD/GYlwohmIE2u0gaxHYiVHEn1Fw9mZ/ktJWgw==",
"license": "MIT",
"dependencies": {
"assertion-error": "^2.0.1",
"check-error": "^2.1.1",
"deep-eql": "^5.0.1",
"loupe": "^3.1.0",
"pathval": "^2.0.0"
},
"engines": {
"node": ">=18"
}
},
"node_modules/check-error": {
"version": "2.1.3",
"resolved": "https://registry.npmjs.org/check-error/-/check-error-2.1.3.tgz",
"integrity": "sha512-PAJdDJusoxnwm1VwW07VWwUN1sl7smmC3OKggvndJFadxxDRyFJBX/ggnu/KE4kQAB7a3Dp8f/YXC1FlUprWmA==",
"license": "MIT",
"engines": {
"node": ">= 16"
}
},
"node_modules/deep-eql": {
"version": "5.0.2",
"resolved": "https://registry.npmjs.org/deep-eql/-/deep-eql-5.0.2.tgz",
"integrity": "sha512-h5k/5U50IJJFpzfL6nO9jaaumfjO/f2NjK/oYB2Djzm4p9L+3T9qWpZqZ2hAbLPuuYq9wrU08WQyBTL5GbPk5Q==",
"license": "MIT",
"engines": {
"node": ">=6"
}
},
"node_modules/loupe": {
"version": "3.2.1",
"resolved": "https://registry.npmjs.org/loupe/-/loupe-3.2.1.tgz",
"integrity": "sha512-CdzqowRJCeLU72bHvWqwRBBlLcMEtIvGrlvef74kMnV2AolS9Y8xUv1I0U/MNAWMhBlKIoyuEgoJ0t/bbwHbLQ==",
"license": "MIT"
},
"node_modules/pathval": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/pathval/-/pathval-2.0.1.tgz",
"integrity": "sha512-//nshmD55c46FuFw26xV/xFAaB5HF9Xdap7HJBBnrKdAd6/GxDBaNA1870O79+9ueg61cZLSVc+OaFlfmObYVQ==",
"license": "MIT",
"engines": {
"node": ">= 14.16"
}
},
"node_modules/tinyrainbow": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/tinyrainbow/-/tinyrainbow-1.2.0.tgz",
"integrity": "sha512-weEDEq7Z5eTHPDh4xjX789+fHfF+P8boiFB+0vbWzpbnbsEr/GRaohi/uMKxg8RZMXnl1ItAi/IUHWMsjDV7kQ==",
"license": "MIT",
"engines": {
"node": ">=14.0.0"
}
},
"node_modules/tinyspy": {
"version": "3.0.2",
"resolved": "https://registry.npmjs.org/tinyspy/-/tinyspy-3.0.2.tgz",
"integrity": "sha512-n1cw8k1k0x4pgA2+9XrOkFydTerNcJ1zWCO5Nn9scWHTD+5tp8dghT2x1uduQePZTZgd3Tupf+x9BxJjeJi77Q==",
"license": "MIT",
"engines": {
"node": ">=14.0.0"
}
}
}
}
{
"name": "sample-vitest-expect",
"version": "1.0.0",
"description": "Clean-room verification sample for @vitest/expect",
"type": "module",
"main": "index.mjs",
"scripts": {
"test": "node test/contract.mjs"
},
"dependencies": {
"@vitest/expect": "2.1.9"
}
}
{
"schemaVersion": 1,
"goal": "verify pkg:npm/%40vitest/expect@2.1.9",
"kind": "HOW",
"packages": [
"pkg:npm/%40vitest/expect@2.1.9"
],
"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 {
createExpect,
expect,
extendExpect,
getState,
setState,
equals,
isA,
isAsymmetric,
hasAsymmetric,
StringContaining,
StringMatching,
ObjectContaining,
ArrayContaining,
Any,
Anything
} from '../index.mjs';
// 1. createExpect configures Chai with JestChaiExpect, JestAsymmetricMatchers, and JestExtend
{
const customExp = createExpect();
assert.equal(typeof customExp, 'function');
assert.equal(typeof customExp.extend, 'function');
customExp(1 + 1).toBe(2);
}
// 2. toBe and toEqual perform primitive value and deep equality assertions
{
expect(42).toBe(42);
expect('hello world').toBe('hello world');
expect(null).toBeNull();
expect(undefined).toBeUndefined();
expect(true).toBeTruthy();
expect(false).toBeFalsy();
expect(NaN).toBeNaN();
const original = { a: 1, nested: { list: [10, 20] } };
const duplicate = { a: 1, nested: { list: [10, 20] } };
expect(original).toEqual(duplicate);
}
// 3. toMatchObject and toHaveProperty verify subset structures and nested object properties
{
const payload = { id: 101, title: 'Report', details: { pages: 5, author: 'tester' } };
expect(payload).toMatchObject({ id: 101, details: { pages: 5 } });
expect(payload).toHaveProperty('details.author', 'tester');
}
// 4. toContain and toContainEqual assert element presence in arrays and strings
{
expect([1, 2, 3]).toContain(2);
expect([{ id: 1 }, { id: 2 }]).toContainEqual({ id: 1 });
expect('vitest expect framework').toContain('expect');
expect([1, 2, 3]).toHaveLength(3);
}
// 5. toBeGreaterThan, toBeLessThan, and toBeCloseTo validate numeric relationships and floating point values
{
expect(10).toBeGreaterThan(5);
expect(10).toBeGreaterThanOrEqual(10);
expect(5).toBeLessThan(10);
expect(5).toBeLessThanOrEqual(5);
expect(0.1 + 0.2).toBeCloseTo(0.3, 5);
}
// 6. toBeTypeOf and toSatisfy evaluate type classifications and custom predicate functions
{
expect('text').toBeTypeOf('string');
expect(100).toBeTypeOf('number');
expect(true).toBeTypeOf('boolean');
expect(Symbol('sym')).toBeTypeOf('symbol');
expect(25).toSatisfy(val => val > 20 && val < 30);
}
// 7. toThrow verifies exception throwing and error type matching
{
expect(() => {
throw new Error('invalid operation');
}).toThrow('invalid operation');
expect(() => {
throw new TypeError('bad argument type');
}).toThrow(TypeError);
}
// 8. Asymmetric matchers StringContaining, StringMatching, ObjectContaining, and ArrayContaining match partial values
{
expect('prefix-order-123-suffix').toEqual(new StringContaining('order'));
expect('order-9988').toEqual(new StringMatching(/^order-\d+$/));
expect({ id: 1, role: 'admin', meta: { score: 95 } }).toEqual(
new ObjectContaining({ role: 'admin', meta: new ObjectContaining({ score: 95 }) })
);
expect([1, 2, 3, 4]).toEqual(new ArrayContaining([2, 4]));
expect('sample-text').toEqual(new Any(String));
expect(42).toEqual(new Any(Number));
expect({ custom: true }).toEqual(new Anything());
}
// 9. expect.extend registers custom matchers with custom pass and failure message logic
{
extendExpect(expect, {
toBeDivisibleBy(received, divisor) {
const pass = received % divisor === 0;
return {
pass,
message: () => `expected ${received} ${pass ? 'not ' : ''}to be divisible by ${divisor}`,
};
},
});
expect(15).toBeDivisibleBy(5);
expect(14).not.toBeDivisibleBy(5);
}
// 10. getState and setState inspect and update matcher execution context
{
setState({ testName: 'contract-suite', isRunning: true }, expect);
const state = getState(expect);
assert.equal(state.testName, 'contract-suite');
assert.equal(state.isRunning, true);
assert.equal(equals({ x: 1 }, { x: 1 }), true);
assert.equal(equals({ x: 1 }, { x: 2 }), false);
assert.equal(isA('String', 'abc'), true);
assert.equal(isA('Number', 123), true);
assert.equal(isAsymmetric(new Any(String)), true);
assert.equal(hasAsymmetric({ matcher: new Any(Number) }), true);
}
console.log('All @vitest/expect contract assertions passed.');
오리진 시더
익명