Sample
@vitest/expect 2.1.9: getObjectSubset
Verified sample for npm @vitest/expect 2.1.9: getObjectSubset. The contract ran on node 22 · linux debian/x64 · docker and passed.
sha256:7fb78cc6d8efed23fba574ba39fa193c5258c15b2801f1abc1f8bdf82de7eb31
This network offers one thing: a sample that builds. It ran the sample in a sandbox and kept the signed receipt. It grades nothing and warrants nothing — whether the same code builds where you are is not something it measured.
How many distinct signing keys filed a passing contract receipt. One is the author alone; more than one means somebody else built it too. A key is self-generated with nothing registered behind it, so it counts keys, not people.
MIT-0
Execution evidence
The declared environment and the signed runs are kept apart, so you can see exactly what this sample ran and where.
- Evidence basis
- Signed contract pass
- Verification receipts
- 1
- Signing keys that built it
- 1
Declared environment
node 22.23 linux 24 · ubuntu · glibc 2.39 x64 node 22.23 javascript npm 10
Verification-run environments
| Environment | Contract | Stages | Run |
|---|---|---|---|
| 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 |
Case
HOW- Goal
- verify @vitest/expect.getObjectSubset in pkg:npm/%40vitest/expect@2.1.9
- Packages
- Symbols
-
- @vitest/expect.getObjectSubset
- Environment
- node 22.23.2
- Created
- 2026-09-06T17:42:13Z
Contract
- assert getObjectSubset returns matching subset with zero stripped count when object structurally satisfies subset
- assert getObjectSubset filters matching keys and counts stripped properties on mismatched objects
- assert getObjectSubset recursively trims nested objects and tallies stripped nested properties
- assert getObjectSubset handles arrays of equal length and returns original array on length mismatch
- assert getObjectSubset preserves special object types like Date and returns primitive values unchanged
- assert getObjectSubset preserves object constructor and supports enumerable Symbol property keys
- assert getObjectSubset handles circular references safely without infinite recursion
- assert getObjectSubset accepts custom equality testers to evaluate property equivalence
- assert getObjectSubset throws TypeError when customTesters is not iterable
Files
- PROMPT.md
- csx.json
- index.mjs
- package-lock.json
- package.json
- spec.json
- test/contract.mjs
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 @vitest/expect.getObjectSubset in pkg:npm/%40vitest/expect@2.1.9
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:npm/%40vitest/expect@2.1.9
Demonstrate these symbols/APIs:
- @vitest/expect.getObjectSubset
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:7032ee981915855606dfab55d07f0c6e1eb46c72e64b79519f8912c865c69a3e","contract":["assert getObjectSubset returns matching subset with zero stripped count when object structurally satisfies subset","assert getObjectSubset filters matching keys and counts stripped properties on mismatched objects","assert getObjectSubset recursively trims nested objects and tallies stripped nested properties","assert getObjectSubset handles arrays of equal length and returns original array on length mismatch","assert getObjectSubset preserves special object types like Date and returns primitive values unchanged","assert getObjectSubset preserves object constructor and supports enumerable Symbol property keys","assert getObjectSubset handles circular references safely without infinite recursion","assert getObjectSubset accepts custom equality testers to evaluate property equivalence","assert getObjectSubset throws TypeError when customTesters is not iterable"],"goal":"verify @vitest/expect.getObjectSubset in pkg:npm/%40vitest/expect@2.1.9","kind":"HOW","packages":["pkg:npm/%40vitest/expect@2.1.9"],"schemaVersion":1,"symbols":["@vitest/expect.getObjectSubset"]},"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@2.1.9"],"schemaVersion":1,"subject":"pkg:npm/%40vitest/expect@2.1.9","symbols":["@vitest/expect.getObjectSubset"],"verifierAdapter":"node-typescript@1"}
import { getObjectSubset } from '@vitest/expect';
/**
* Extracts a subset of an object matching the shape and keys of a specified subset,
* counting any omitted properties that were stripped from the source object.
*
* @param {unknown} object - Source object or value to extract from.
* @param {unknown} subset - Target structure specifying which keys to include.
* @param {Array<Function>} [customTesters=[]] - Optional equality tester functions.
* @returns {{ subset: unknown, stripped: number }} Result object containing the filtered subset and the count of stripped properties.
*/
export function extractObjectSubset(object, subset, customTesters = []) {
return getObjectSubset(object, subset, customTesters);
}
export { getObjectSubset };
{
"name": "sample-vitest-expect-getobjectsubset",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "sample-vitest-expect-getobjectsubset",
"version": "1.0.0",
"license": "MIT-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-getobjectsubset",
"version": "1.0.0",
"description": "Clean-room verification sample for getObjectSubset in @vitest/expect",
"type": "module",
"main": "index.mjs",
"scripts": {
"test": "node test/contract.mjs"
},
"license": "MIT-0",
"dependencies": {
"@vitest/expect": "2.1.9"
}
}
{
"schemaVersion": 1,
"goal": "verify @vitest/expect.getObjectSubset in pkg:npm/%40vitest/expect@2.1.9",
"kind": "HOW",
"packages": [
"pkg:npm/%40vitest/expect@2.1.9"
],
"symbols": [
"@vitest/expect.getObjectSubset"
]
}
import assert from 'node:assert/strict';
import { getObjectSubset, extractObjectSubset } from '../index.mjs';
async function runContract() {
// 1. assert getObjectSubset returns matching subset with zero stripped count when object structurally satisfies subset
{
const actual = { a: 1, b: 2, c: 3 };
const expected = { a: 1 };
const res = extractObjectSubset(actual, expected, []);
assert.deepStrictEqual(res, { subset: { a: 1 }, stripped: 0 });
const identicalActual = { x: 'test', y: true };
const identicalExpected = { x: 'test', y: true };
const identicalRes = getObjectSubset(identicalActual, identicalExpected, []);
assert.deepStrictEqual(identicalRes, { subset: { x: 'test', y: true }, stripped: 0 });
}
// 2. assert getObjectSubset filters matching keys and counts stripped properties on mismatched objects
{
const actual = { a: 1, b: 2, c: 3 };
const expected = { a: 99 };
const res = getObjectSubset(actual, expected, []);
assert.deepStrictEqual(res, { subset: { a: 1 }, stripped: 2 });
}
// 3. assert getObjectSubset recursively trims nested objects and tallies stripped nested properties
{
const actual = {
nested: { x: 10, y: 20, z: 30 },
topLevelExtra: 'drop-me'
};
const expected = {
nested: { x: 99 }
};
const res = getObjectSubset(actual, expected, []);
assert.deepStrictEqual(res, {
subset: { nested: { x: 10 } },
stripped: 3
});
}
// 4. assert getObjectSubset handles arrays of equal length and returns original array on length mismatch
{
const actualArray = [{ id: 1, secret: 'hidden' }, { id: 2, secret: 'hidden' }];
const expectedArray = [{ id: 99 }, { id: 88 }];
const resArray = getObjectSubset(actualArray, expectedArray, []);
assert.deepStrictEqual(resArray, {
subset: [{ id: 1 }, { id: 2 }],
stripped: 2
});
const lengthMismatchActual = [1, 2, 3];
const lengthMismatchExpected = [1, 2];
const resMismatch = getObjectSubset(lengthMismatchActual, lengthMismatchExpected, []);
assert.deepStrictEqual(resMismatch, {
subset: [1, 2, 3],
stripped: 0
});
}
// 5. assert getObjectSubset preserves special object types like Date and returns primitive values unchanged
{
const testDate = new Date('2026-01-01T00:00:00.000Z');
const resDate = getObjectSubset(testDate, new Date('2026-01-02T00:00:00.000Z'), []);
assert.strictEqual(resDate.subset, testDate);
assert.strictEqual(resDate.stripped, 0);
const resNumber = getObjectSubset(42, 42, []);
assert.deepStrictEqual(resNumber, { subset: 42, stripped: 0 });
const resString = getObjectSubset('hello', 'world', []);
assert.deepStrictEqual(resString, { subset: 'hello', stripped: 0 });
}
// 6. assert getObjectSubset preserves object constructor and supports enumerable Symbol property keys
{
class ConfigModel {
constructor(host, port) {
this.host = host;
this.port = port;
}
}
const config = new ConfigModel('localhost', 8080);
const resConstructor = getObjectSubset(config, { host: 'remotehost' }, []);
assert.strictEqual(resConstructor.subset.constructor, ConfigModel);
assert.strictEqual(resConstructor.subset.host, 'localhost');
assert.strictEqual(resConstructor.stripped, 1);
const symKey = Symbol('symProp');
const objWithSym = { name: 'target', [symKey]: 'symVal', extra: 100 };
const resSym = getObjectSubset(objWithSym, { name: 'diff', [symKey]: 'expectedSym' }, []);
assert.strictEqual(resSym.subset[symKey], 'symVal');
assert.strictEqual(resSym.subset.name, 'target');
assert.strictEqual(resSym.stripped, 1);
}
// 7. assert getObjectSubset handles circular references safely without infinite recursion
{
const cyclicActual = { id: 1, extra: 'remove' };
cyclicActual.self = cyclicActual;
const cyclicExpected = { id: 99, self: null };
cyclicExpected.self = cyclicExpected;
const res = getObjectSubset(cyclicActual, cyclicExpected, []);
assert.strictEqual(res.subset.id, 1);
assert.strictEqual(res.subset.self, res.subset);
assert.strictEqual(res.stripped, 1);
}
// 8. assert getObjectSubset accepts custom equality testers to evaluate property equivalence
{
const caseInsensitiveTester = (a, b) =>
typeof a === 'string' && typeof b === 'string' ? a.toLowerCase() === b.toLowerCase() : undefined;
const actual = { role: 'ADMIN', extra: true };
const expected = { role: 'admin' };
const res = getObjectSubset(actual, expected, [caseInsensitiveTester]);
assert.deepStrictEqual(res, { subset: { role: 'admin' }, stripped: 0 });
}
// 9. assert getObjectSubset throws TypeError when customTesters is not iterable
{
assert.throws(
() => getObjectSubset({ a: 1 }, { a: 1 }),
(err) => err instanceof TypeError && /not iterable/.test(err.message)
);
}
console.log('All @vitest/expect.getObjectSubset contract assertions passed successfully.');
}
runContract().catch((err) => {
console.error('Contract test failed:', err);
process.exit(1);
});
Origin Seeder
anonymous