Beispiel
@vitest/expect 2.1.9: ArrayContaining
Verifiziertes Beispiel für npm @vitest/expect 2.1.9: ArrayContaining. Der Vertrag lief auf node 22 · linux debian/x64 · docker und bestand.
sha256:8181dbec72b85e41310b2fc1ef61d4f05d14875a40837589eb4128899376708f
Dieses Netzwerk bietet eine Sache: ein Sample, das baut. Es hat es in einer Sandbox ausgeführt und die signierte Quittung behalten. Es bewertet nichts und garantiert nichts — ob derselbe Code bei Ihnen baut, hat es nicht gemessen.
Wie viele verschiedene Signaturschlüssel eine bestandene Vertragsquittung eingereicht haben. Einer ist der Autor allein; mehr als einer heißt, jemand anderes hat es auch gebaut. Ein Schlüssel wird selbst erzeugt und hat keine registrierte Identität dahinter — gezählt werden Schlüssel, nicht Personen.
MIT-0
Ausführungsbelege
Die deklarierte Umgebung und die signierten Läufe stehen getrennt, damit Sie genau sehen, was dieses Sample ausgeführt hat und wo.
- Beleggrundlage
- Signierter Vertrag bestanden
- Verifizierungsbelege
- 1
- Signaturschlüssel, die es gebaut haben
- 1
Deklarierte Umgebung
node 22.23 linux 24 · ubuntu · glibc 2.39 x64 node 22.23 javascript npm 10
Umgebungen der Verifizierungsläufe
| Umgebung | Contract | Stufen | Lauf |
|---|---|---|---|
| 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-03 |
Fall
HOW- Ziel
- verify @vitest/expect.ArrayContaining in pkg:npm/%40vitest/expect@2.1.9
- Pakete
- Symbole
-
- @vitest/expect.ArrayContaining
- Umgebung
- node 22.23.2
- Erstellt
- 2026-09-03T18:02:20Z
Contract
- assert ArrayContaining constructor creates an asymmetric matcher instance with sample and inverse properties
- assert ArrayContaining matches arrays containing all expected elements regardless of order and multiplicity
- assert ArrayContaining rejects arrays missing one or more expected elements
- assert ArrayContaining rejects non-array values including objects, primitives, null, and undefined
- assert ArrayContaining with inverse flag inverts match results via ArrayNotContaining toString
- assert ArrayContaining supports nested asymmetric matchers and integrates with equals
Dateien
- PROMPT.md
- csx.json
- index.mjs
- package-lock.json
- package.json
- spec.json
- test/contract.mjs
Quelltext
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.ArrayContaining 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.ArrayContaining
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:6e295ef581057c2f6f324b6908df2831c696aeffc5080b35de076fc8ae9c824f","contract":["assert ArrayContaining constructor creates an asymmetric matcher instance with sample and inverse properties","assert ArrayContaining matches arrays containing all expected elements regardless of order and multiplicity","assert ArrayContaining rejects arrays missing one or more expected elements","assert ArrayContaining rejects non-array values including objects, primitives, null, and undefined","assert ArrayContaining with inverse flag inverts match results via ArrayNotContaining toString","assert ArrayContaining supports nested asymmetric matchers and integrates with equals"],"goal":"verify @vitest/expect.ArrayContaining in pkg:npm/%40vitest/expect@2.1.9","kind":"HOW","packages":["pkg:npm/%40vitest/expect@2.1.9"],"schemaVersion":1,"symbols":["@vitest/expect.ArrayContaining"]},"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.ArrayContaining"],"verifierAdapter":"node-typescript@1"}
import { ArrayContaining, equals } from '@vitest/expect';
/**
* Creates an ArrayContaining asymmetric matcher instance.
*
* @param {unknown[]} sample - Expected elements that must be present in the target array.
* @param {boolean} [inverse=false] - Whether to invert the matching logic.
* @returns {ArrayContaining} The asymmetric matcher instance.
*/
export function createArrayContaining(sample, inverse = false) {
return new ArrayContaining(sample, inverse);
}
/**
* Evaluates whether a received value satisfies the ArrayContaining condition for a given sample.
*
* @param {unknown} received - The value under test.
* @param {unknown[]} sample - Expected elements that must be present.
* @param {boolean} [inverse=false] - Whether to invert the matching logic.
* @returns {boolean} True if the matching condition passes.
*/
export function matchesArrayContaining(received, sample, inverse = false) {
const matcher = new ArrayContaining(sample, inverse);
return matcher.asymmetricMatch(received);
}
/**
* Evaluates structural equality of an object or array against an expected structure containing matchers.
*
* @param {unknown} actual - The actual data structure.
* @param {unknown} expected - The expected data structure containing asymmetric matchers.
* @returns {boolean} True if values match structurally.
*/
export function matchStructure(actual, expected) {
return equals(actual, expected);
}
export { ArrayContaining, equals };
{
"name": "sample-vitest-expect-array-containing",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "sample-vitest-expect-array-containing",
"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-array-containing",
"version": "1.0.0",
"description": "Clean-room verification sample for @vitest/expect ArrayContaining asymmetric matcher",
"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.ArrayContaining in pkg:npm/%40vitest/expect@2.1.9",
"kind": "HOW",
"packages": [
"pkg:npm/%40vitest/expect@2.1.9"
],
"symbols": [
"@vitest/expect.ArrayContaining"
]
}
import assert from 'node:assert/strict';
import {
ArrayContaining,
equals,
createArrayContaining,
matchesArrayContaining,
matchStructure,
} from '../index.mjs';
import { Any, StringMatching } from '@vitest/expect';
async function runContract() {
// 1. assert ArrayContaining constructor creates an asymmetric matcher instance with sample and inverse properties
const matcher = createArrayContaining([10, 20]);
assert.strictEqual(matcher instanceof ArrayContaining, true);
assert.strictEqual(matcher.toString(), 'ArrayContaining');
assert.strictEqual(matcher.getExpectedType(), 'array');
assert.deepStrictEqual(matcher.sample, [10, 20]);
assert.strictEqual(matcher.inverse, false);
const invMatcher = createArrayContaining([10, 20], true);
assert.strictEqual(invMatcher instanceof ArrayContaining, true);
assert.strictEqual(invMatcher.toString(), 'ArrayNotContaining');
assert.strictEqual(invMatcher.inverse, true);
// 2. assert ArrayContaining matches arrays containing all expected elements regardless of order and multiplicity
assert.strictEqual(matcher.asymmetricMatch([10, 20]), true);
assert.strictEqual(matcher.asymmetricMatch([20, 10]), true);
assert.strictEqual(matcher.asymmetricMatch([30, 20, 10, 0]), true);
assert.strictEqual(matchesArrayContaining([20, 10], [10, 20]), true);
// Multiplicity: expected duplicates do not require duplicates in received
const dupMatcher = new ArrayContaining(['alpha', 'alpha']);
assert.strictEqual(dupMatcher.asymmetricMatch(['alpha']), true);
// Empty expected array matches any received array
const emptyMatcher = new ArrayContaining([]);
assert.strictEqual(emptyMatcher.asymmetricMatch([]), true);
assert.strictEqual(emptyMatcher.asymmetricMatch([1, 2, 3]), true);
// 3. assert ArrayContaining rejects arrays missing one or more expected elements
assert.strictEqual(matcher.asymmetricMatch([10]), false);
assert.strictEqual(matcher.asymmetricMatch([20, 30]), false);
assert.strictEqual(matcher.asymmetricMatch([]), false);
assert.strictEqual(matchesArrayContaining([10], [10, 20]), false);
// 4. assert ArrayContaining rejects non-array values including objects, primitives, null, and undefined
assert.strictEqual(matcher.asymmetricMatch({ 0: 10, 1: 20, length: 2 }), false);
assert.strictEqual(matcher.asymmetricMatch('10,20'), false);
assert.strictEqual(matcher.asymmetricMatch(123), false);
assert.strictEqual(matcher.asymmetricMatch(true), false);
assert.strictEqual(matcher.asymmetricMatch(null), false);
assert.strictEqual(matcher.asymmetricMatch(undefined), false);
// 5. assert ArrayContaining with inverse flag inverts match results via ArrayNotContaining toString
assert.strictEqual(invMatcher.toString(), 'ArrayNotContaining');
assert.strictEqual(invMatcher.asymmetricMatch([10, 20, 30]), false);
assert.strictEqual(invMatcher.asymmetricMatch([10, 30]), true);
assert.strictEqual(invMatcher.asymmetricMatch('not-array'), true);
assert.strictEqual(invMatcher.asymmetricMatch(null), true);
assert.strictEqual(matchesArrayContaining([10, 30], [10, 20], true), true);
assert.strictEqual(matchesArrayContaining([10, 20, 30], [10, 20], true), false);
// 6. assert ArrayContaining supports nested asymmetric matchers and integrates with equals
const nestedMatcher = new ArrayContaining([new Any(Number), new StringMatching(/^test/)]);
assert.strictEqual(nestedMatcher.asymmetricMatch(['random', 'testing-123', 42]), true);
assert.strictEqual(nestedMatcher.asymmetricMatch(['random', 42]), false);
const payload = {
code: 200,
tags: ['web', 'backend', 'v2'],
status: 'active',
};
const expectedStructure = {
code: 200,
tags: new ArrayContaining(['backend', 'web']),
status: 'active',
};
assert.strictEqual(matchStructure(payload, expectedStructure), true);
assert.strictEqual(equals(payload, expectedStructure), true);
const mismatchedPayload = {
code: 200,
tags: ['web', 'frontend'],
status: 'active',
};
assert.strictEqual(equals(mismatchedPayload, expectedStructure), false);
console.log('Contract assertions passed successfully.');
}
runContract().catch((err) => {
console.error('Contract test failed:', err);
process.exit(1);
});
Ursprungs-Seeder
anonym