Exemple
@vitest/expect 4.1.11
Échantillon vérifié pour npm @vitest/expect 4.1.11. Le contrat s'est exécuté sur node 22 · linux alpine/x64 · docker et a réussi.
sha256:21e2f381fd2647c4f4db6be94fa0443a7081440ea6623f6946e31031d388aaf6
Ce réseau offre une seule chose : un échantillon qui compile. Il l'a exécuté dans un bac à sable et conservé le reçu signé. Il ne note rien et ne garantit rien : si le même code compile chez vous, il ne l'a pas mesuré.
Combien de clés de signature distinctes ont déposé un reçu de contrat réussi. Une seule, c'est l'auteur ; plus d'une signifie que quelqu'un d'autre l'a compilé aussi. Une clé est auto-générée sans identité enregistrée derrière, donc on compte des clés, pas des personnes.
MIT-0
Preuves d'exécution
L'environnement déclaré et les exécutions signées sont séparés, pour que vous voyiez exactement ce que cet échantillon a exécuté et où.
- Base de preuve
- Contrat signé réussi
- Reçus de vérification
- 1
- Clés de signature qui l’ont compilé
- 1
Environnement déclaré
node 22.23 linux 24 · ubuntu · glibc 2.39 x64 node 22.23 javascript npm 10
Environnements des exécutions de vérification
| Environnement | Contrat | Étapes | Exécution |
|---|---|---|---|
| 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-28 |
Cas
HOW- Objectif
- verify pkg:npm/%40vitest/expect@4.1.11
- Paquets
- Environnement
- node 22.23.2
- Créé
- 2026-08-28T06:20:52Z
Contrat
- expect performs strict primitive equality, boolean/nullish checks, and .not negation
- toEqual and toStrictEqual perform deep structural equality assertions on objects and arrays
- toMatchObject and toHaveProperty verify subset structures and nested object properties
- toContain and toContainEqual assert collection containment and element equality
- toBeGreaterThan, toBeLessThan, and toBeCloseTo validate numeric relationships and floating point values
- toBeTypeOf and toBeInstanceOf evaluate type classifications and instance constructors
- toSatisfy and toBeOneOf custom matchers evaluate predicate functions and element membership
- toThrow verifies exception throwing and error type matching
- Asymmetric matchers stringContaining, stringMatching, objectContaining, arrayContaining, any, anything, and closeTo match partial values
- SchemaMatching and expect.schemaMatching validate data against Standard Schema V1 definitions
- expect.extend registers custom matchers with custom pass and failure message logic
- getState and setState inspect and update matcher execution context
Fichiers
- PROMPT.md
- csx.json
- index.mjs
- package-lock.json
- package.json
- spec.json
- test/contract.mjs
Code source
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@4.1.11
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:npm/%40vitest/expect@4.1.11
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:398260778990bbae44d585704bee6b0697c5dbfee5b9c9d3ee245e5dc684b94a","contract":["expect performs strict primitive equality, boolean/nullish checks, and .not negation","toEqual and toStrictEqual perform deep structural equality assertions on objects and arrays","toMatchObject and toHaveProperty verify subset structures and nested object properties","toContain and toContainEqual assert collection containment and element equality","toBeGreaterThan, toBeLessThan, and toBeCloseTo validate numeric relationships and floating point values","toBeTypeOf and toBeInstanceOf evaluate type classifications and instance constructors","toSatisfy and toBeOneOf custom matchers evaluate predicate functions and element membership","toThrow verifies exception throwing and error type matching","Asymmetric matchers stringContaining, stringMatching, objectContaining, arrayContaining, any, anything, and closeTo match partial values","SchemaMatching and expect.schemaMatching validate data against Standard Schema V1 definitions","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@4.1.11","kind":"HOW","packages":["pkg:npm/%40vitest/expect@4.1.11"],"schemaVersion":1},"contractCommand":["node","test/contract.mjs"],"environment":{"arch":"x64","distro":"ubuntu","ecosystem":"npm","executionContext":"node","language":"javascript","libc":"glibc","libcVersion":"2.39","moduleSystem":"esm","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@4.1.11"],"schemaVersion":1,"subject":"pkg:npm/%40vitest/expect@4.1.11","verifierAdapter":"node-typescript@1"}
import * as chai from 'chai';
import {
JestChaiExpect,
JestAsymmetricMatchers,
JestExtend,
ChaiStyleAssertions,
customMatchers,
getState,
setState,
equals,
isA,
isAsymmetric,
hasAsymmetric,
isStandardSchema,
StringContaining,
StringMatching,
ObjectContaining,
ArrayContaining,
Any,
Anything,
SchemaMatching,
addCustomEqualityTesters
} from '@vitest/expect';
chai.use(JestChaiExpect);
chai.use(JestAsymmetricMatchers);
chai.use(JestExtend);
chai.use(ChaiStyleAssertions);
chai.expect.extend(chai.expect, customMatchers);
export const expect = chai.expect;
export {
chai,
JestChaiExpect,
JestAsymmetricMatchers,
JestExtend,
ChaiStyleAssertions,
customMatchers,
getState,
setState,
equals,
isA,
isAsymmetric,
hasAsymmetric,
isStandardSchema,
StringContaining,
StringMatching,
ObjectContaining,
ArrayContaining,
Any,
Anything,
SchemaMatching,
addCustomEqualityTesters
};
{
"name": "sample-vitest-expect",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "sample-vitest-expect",
"version": "1.0.0",
"dependencies": {
"@vitest/expect": "4.1.11"
}
},
"node_modules/@standard-schema/spec": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/@standard-schema/spec/-/spec-1.1.0.tgz",
"integrity": "sha512-l2aFy5jALhniG5HgqrD6jXLi/rUWrKvqN/qJx6yoJsgKhblVd+iqqU4RCXavm/jPityDo5TCvKMnpjKnOriy0w==",
"license": "MIT"
},
"node_modules/@types/chai": {
"version": "5.2.3",
"resolved": "https://registry.npmjs.org/@types/chai/-/chai-5.2.3.tgz",
"integrity": "sha512-Mw558oeA9fFbv65/y4mHtXDs9bPnFMZAL/jxdPFUpOHHIXX91mcgEHbS5Lahr+pwZFR8A7GQleRWeI6cGFC2UA==",
"license": "MIT",
"dependencies": {
"@types/deep-eql": "*",
"assertion-error": "^2.0.1"
}
},
"node_modules/@types/deep-eql": {
"version": "4.0.2",
"resolved": "https://registry.npmjs.org/@types/deep-eql/-/deep-eql-4.0.2.tgz",
"integrity": "sha512-c9h9dVVMigMPc4bwTvC5dxqtqJZwQPePsWjPlpSOnojbor6pGqdk541lfA7AqFQr5pB1BRdq0juY9db81BwyFw==",
"license": "MIT"
},
"node_modules/@vitest/expect": {
"version": "4.1.11",
"resolved": "https://registry.npmjs.org/@vitest/expect/-/expect-4.1.11.tgz",
"integrity": "sha512-VX2x5vNJXET47KAFzwERI+KRMtTTCSWTfSMKsW7JsUsXV4psq++e3DvZpuTDOpHcxytiDs6p2nhVb2tVDiiUYw==",
"license": "MIT",
"dependencies": {
"@standard-schema/spec": "^1.1.0",
"@types/chai": "^5.2.2",
"@vitest/spy": "4.1.11",
"@vitest/utils": "4.1.11",
"chai": "^6.2.2",
"tinyrainbow": "^3.1.0"
},
"funding": {
"url": "https://opencollective.com/vitest"
}
},
"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/@vitest/spy": {
"version": "4.1.11",
"resolved": "https://registry.npmjs.org/@vitest/spy/-/spy-4.1.11.tgz",
"integrity": "sha512-apNa/prQy2qCeywhnixOHPRCgGNhvg7T4Dapfl1GahLp/R+uhBm5cPyFoNVyqsNd2h1nJxL6BqqdIjiABL60YA==",
"license": "MIT",
"funding": {
"url": "https://opencollective.com/vitest"
}
},
"node_modules/@vitest/utils": {
"version": "4.1.11",
"resolved": "https://registry.npmjs.org/@vitest/utils/-/utils-4.1.11.tgz",
"integrity": "sha512-zTCVGpyFsGWBhllOyKlTw/vnr6D9qxsfSDyfbyZmTyjHw5N/VuvzHpHoQjm2ZJzn4RJgx5w4r7V0er69CmLgPQ==",
"license": "MIT",
"dependencies": {
"@vitest/pretty-format": "4.1.11",
"convert-source-map": "^2.0.0",
"tinyrainbow": "^3.1.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": "6.2.2",
"resolved": "https://registry.npmjs.org/chai/-/chai-6.2.2.tgz",
"integrity": "sha512-NUPRluOfOiTKBKvWPtSD4PhFvWCqOi0BGStNWs57X9js7XGTprSmFoz5F0tWhR4WPjNeR9jXqdC7/UpSJTnlRg==",
"license": "MIT",
"engines": {
"node": ">=18"
}
},
"node_modules/convert-source-map": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/convert-source-map/-/convert-source-map-2.0.0.tgz",
"integrity": "sha512-Kvp459HrV2FEJ1CAsi1Ku+MY3kasH19TFykTz2xWmMeq6bk2NU3XXvfJ+Q61m0xktWwt+1HSYf3JZsTms3aRJg==",
"license": "MIT"
},
"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-expect",
"version": "1.0.0",
"description": "Clean-room verification sample for @vitest/expect@4.1.11",
"type": "module",
"main": "index.mjs",
"scripts": {
"test": "node test/contract.mjs"
},
"dependencies": {
"@vitest/expect": "4.1.11"
}
}
{
"schemaVersion": 1,
"goal": "verify pkg:npm/%40vitest/expect@4.1.11",
"kind": "HOW",
"packages": [
"pkg:npm/%40vitest/expect@4.1.11"
]
}
import assert from 'node:assert/strict';
import {
expect,
customMatchers,
getState,
setState,
equals,
isA,
isAsymmetric,
hasAsymmetric,
isStandardSchema,
StringContaining,
StringMatching,
ObjectContaining,
ArrayContaining,
Any,
Anything,
SchemaMatching,
addCustomEqualityTesters
} from '../index.mjs';
// 1. Basic expect assertions and .not negation
{
assert.equal(typeof expect, 'function');
expect(42).toBe(42);
expect('vitest').toBe('vitest');
expect(true).toBe(true);
expect(false).toBe(false);
expect(null).toBeNull();
expect(undefined).toBeUndefined();
expect(NaN).toBeNaN();
expect('value').toBeDefined();
expect(true).toBeTruthy();
expect(false).toBeFalsy();
expect(10).not.toBe(20);
expect('hello').not.toBe('world');
}
// 2. Deep equality with toEqual and toStrictEqual
{
const obj1 = { id: 1, tags: ['a', 'b'], meta: { count: 3 } };
const obj2 = { id: 1, tags: ['a', 'b'], meta: { count: 3 } };
expect(obj1).toEqual(obj2);
expect(obj1).toStrictEqual(obj2);
expect([1, 2, 3]).toEqual([1, 2, 3]);
expect([1, 2]).not.toEqual([1, 3]);
}
// 3. Object matching and property validation
{
const user = { id: 100, name: 'Alex', profile: { role: 'admin', level: 5 } };
expect(user).toMatchObject({ name: 'Alex', profile: { role: 'admin' } });
expect(user).toHaveProperty('profile.role', 'admin');
expect(user).toHaveProperty('id', 100);
}
// 4. Collection containment and length checks
{
expect(['apple', 'banana', 'orange']).toContain('banana');
expect('javascript string matcher').toContain('string');
expect([{ key: 'a' }, { key: 'b' }]).toContainEqual({ key: 'b' });
expect([10, 20, 30]).toHaveLength(3);
expect('hello').toHaveLength(5);
}
// 5. Numerical comparisons (toBeGreaterThan, toBeLessThan, toBeCloseTo)
{
expect(15).toBeGreaterThan(10);
expect(15).toBeGreaterThanOrEqual(15);
expect(5).toBeLessThan(10);
expect(5).toBeLessThanOrEqual(5);
expect(0.1 + 0.2).toBeCloseTo(0.3, 5);
}
// 6. Type assertions, toBeInstanceOf, and customMatchers (toSatisfy, toBeOneOf)
{
expect('test-string').toBeTypeOf('string');
expect(12345).toBeTypeOf('number');
expect(true).toBeTypeOf('boolean');
expect(Symbol('vitest')).toBeTypeOf('symbol');
expect(new Date()).toBeInstanceOf(Date);
expect(20).toSatisfy(n => n % 5 === 0);
expect('admin@example.com').toSatisfy(s => s.includes('@'));
expect('banana').toBeOneOf(['apple', 'banana', 'orange']);
expect(2).toBeOneOf([1, 2, 3]);
}
// 7. Error handling assertions with toThrow
{
expect(() => {
throw new Error('invalid operation');
}).toThrow('invalid operation');
expect(() => {
throw new TypeError('invalid argument');
}).toThrow(TypeError);
expect(() => {
// normal execution
}).not.toThrow();
}
// 8. Asymmetric matchers via expect properties and constructors
{
expect('sample-test-case').toEqual(expect.stringContaining('test'));
expect('vitest-4.1.11').toEqual(expect.stringMatching(/^vitest-\d+\.\d+\.\d+$/));
expect({ x: 1, y: 2, extra: true }).toEqual(expect.objectContaining({ x: 1, y: 2 }));
expect([1, 2, 3, 4]).toEqual(expect.arrayContaining([2, 4]));
expect('hello').toEqual(expect.any(String));
expect(99).toEqual(expect.any(Number));
expect({ custom: true }).toEqual(expect.anything());
expect(5.119).toEqual(expect.closeTo(5.12, 1));
// Direct asymmetric matcher classes
expect('prefix-val-suffix').toEqual(new StringContaining('val'));
expect('abc-123').toEqual(new StringMatching(/^abc-\d+$/));
expect({ a: 10, b: 20 }).toEqual(new ObjectContaining({ a: 10 }));
expect([10, 20, 30]).toEqual(new ArrayContaining([20]));
expect('str').toEqual(new Any(String));
expect({}).toEqual(new Anything());
}
// 9. Standard Schema integration with schemaMatching
{
const mockStandardSchema = {
'~standard': {
version: 1,
vendor: 'test-vendor',
validate: value => {
if (typeof value === 'string' && value.startsWith('valid-')) {
return { value };
}
return { issues: [{ message: 'Expected prefix valid-' }] };
}
}
};
assert.equal(isStandardSchema(mockStandardSchema), true);
expect('valid-data').toEqual(expect.schemaMatching(mockStandardSchema));
expect('valid-custom').toEqual(new SchemaMatching(mockStandardSchema));
}
// 10. Custom matcher registration with expect.extend
{
expect.extend(expect, {
toBeWithinRange(received, floor, ceiling) {
const pass = received >= floor && received <= ceiling;
return {
pass,
message: () => `expected ${received} ${pass ? 'not ' : ''}to be within range [${floor}, ${ceiling}]`,
};
},
});
expect(50).toBeWithinRange(1, 100);
expect(150).not.toBeWithinRange(1, 100);
}
// 11. State management (getState, setState) and matcher utilities
{
setState({ currentTestName: 'vitest-expect-contract-test', assertionCalls: 15 }, expect);
const state = getState(expect);
assert.equal(state.currentTestName, 'vitest-expect-contract-test');
assert.equal(state.assertionCalls, 15);
assert.equal(equals({ k: 1 }, { k: 1 }), true);
assert.equal(equals({ k: 1 }, { k: 2 }), false);
assert.equal(isA('String', 'hello'), true);
assert.equal(isA('Number', 42), true);
assert.equal(isAsymmetric(new Any(String)), true);
assert.equal(hasAsymmetric({ matcher: new Any(Number) }), true);
}
console.log('All @vitest/expect contract assertions passed successfully.');
Seeder d'origine
anonyme