Beispiel
@jest/pattern 30.4.0: TestPathPatterns, TestPathPatternsExecutor
Verifiziertes Beispiel für npm @jest/pattern 30.4.0: TestPathPatterns, TestPathPatternsExecutor. Der Vertrag lief auf node 22 · linux alpine/x64 · docker und…
sha256:1a693cfc489ce28680d3206a91df234ac7daf2698d7b1ddb579b963206196ee9
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 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-27 |
Fall
HOW- Ziel
- verify pkg:npm/%40jest/pattern@30.4.0
- Pakete
- Symbole
-
- TestPathPatterns
- TestPathPatternsExecutor
- Umgebung
- node 22.23.2
- Erstellt
- 2026-08-27T22:47:39Z
Contract
- TestPathPatterns can be constructed with pattern strings and correctly reports isSet, isValid, toPretty, and toJSON
- TestPathPatterns reports isValid as false when given an invalid regex pattern
- TestPathPatternsExecutor created from empty patterns matches any absolute path within or outside rootDir
- TestPathPatternsExecutor matches paths against relative pattern strings against rootDir
- TestPathPatternsExecutor correctly handles patterns with leading dot-slash prefix matching relative to rootDir
Dateien
- PROMPT.md
- csx.json
- package-lock.json
- package.json
- spec.json
- src/index.js
- test/contract.js
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 pkg:npm/%40jest/pattern@30.4.0
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:npm/%40jest/pattern@30.4.0
Demonstrate these symbols/APIs:
- TestPathPatterns
- TestPathPatternsExecutor
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:abc0a642a03fd9c653ea24dcbb88f3b48fea1d8eee147fbc416e0e3e4ff97de0","contract":["TestPathPatterns can be constructed with pattern strings and correctly reports isSet, isValid, toPretty, and toJSON","TestPathPatterns reports isValid as false when given an invalid regex pattern","TestPathPatternsExecutor created from empty patterns matches any absolute path within or outside rootDir","TestPathPatternsExecutor matches paths against relative pattern strings against rootDir","TestPathPatternsExecutor correctly handles patterns with leading dot-slash prefix matching relative to rootDir"],"goal":"verify pkg:npm/%40jest/pattern@30.4.0","kind":"HOW","packages":["pkg:npm/%40jest/pattern@30.4.0"],"schemaVersion":1,"symbols":["TestPathPatterns","TestPathPatternsExecutor"]},"contractCommand":["node","test/contract.js"],"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/%40jest/pattern@30.4.0"],"schemaVersion":1,"subject":"pkg:npm/%40jest/pattern@30.4.0","symbols":["TestPathPatterns","TestPathPatternsExecutor"],"verifierAdapter":"node-typescript@1"}
{
"name": "sample-jest-pattern",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "sample-jest-pattern",
"version": "1.0.0",
"license": "MIT-0",
"dependencies": {
"@jest/pattern": "30.4.0"
}
},
"node_modules/@jest/pattern": {
"version": "30.4.0",
"resolved": "https://registry.npmjs.org/@jest/pattern/-/pattern-30.4.0.tgz",
"integrity": "sha512-RAWn3+f9u8BsHijKJ71uHcFp6vmyEt6VvoWXkl6hKF3qVIuWNmudVjg12DlBPGup/frIl5UcUlH5HfEuvHpEXg==",
"license": "MIT",
"dependencies": {
"@types/node": "*",
"jest-regex-util": "30.4.0"
},
"engines": {
"node": "^18.14.0 || ^20.0.0 || ^22.0.0 || >=24.0.0"
}
},
"node_modules/@types/node": {
"version": "26.4.0",
"resolved": "https://registry.npmjs.org/@types/node/-/node-26.4.0.tgz",
"integrity": "sha512-faiGnoIrLH/V8cibOMEAZ8pMw6oXqSukl29ra4mN8GdaB2ZewzeaLj+INpV5N+Z1eKWzY+IzaIZH2EIR6YZRNQ==",
"license": "MIT",
"dependencies": {
"undici-types": "~8.3.0"
}
},
"node_modules/jest-regex-util": {
"version": "30.4.0",
"resolved": "https://registry.npmjs.org/jest-regex-util/-/jest-regex-util-30.4.0.tgz",
"integrity": "sha512-mWlvLviKIgIQ8VCuM1xRdD0TWp3zlzionlmDBjuXVBs+VkmXq6FgW9T4Emr7oGz/Rk6feDCGyiugolcQEyp3mg==",
"license": "MIT",
"engines": {
"node": "^18.14.0 || ^20.0.0 || ^22.0.0 || >=24.0.0"
}
},
"node_modules/undici-types": {
"version": "8.3.0",
"resolved": "https://registry.npmjs.org/undici-types/-/undici-types-8.3.0.tgz",
"integrity": "sha512-j375ScV60dom+YkPFIfTLcOiPxkN/buHz5GobjLhixFuANaNs3C9l4GmrWqejgXWJ7BbJcFYpTEUkS1Ge8bpZQ==",
"license": "MIT"
}
}
}
{
"name": "sample-jest-pattern",
"version": "1.0.0",
"private": true,
"description": "Clean-room verification for @jest/pattern TestPathPatterns and TestPathPatternsExecutor",
"main": "src/index.js",
"scripts": {
"test": "node test/contract.js"
},
"dependencies": {
"@jest/pattern": "30.4.0"
},
"license": "MIT-0"
}
{
"schemaVersion": 1,
"goal": "verify pkg:npm/%40jest/pattern@30.4.0",
"kind": "HOW",
"packages": [
"pkg:npm/%40jest/pattern@30.4.0"
],
"symbols": [
"TestPathPatterns",
"TestPathPatternsExecutor"
]
}
const { TestPathPatterns, TestPathPatternsExecutor } = require('@jest/pattern');
/**
* Creates a TestPathPatterns instance from an array of pattern strings.
* @param {string[]} patterns
* @returns {TestPathPatterns}
*/
function createPathPatterns(patterns = []) {
return new TestPathPatterns(patterns);
}
/**
* Creates a TestPathPatternsExecutor instance for the given patterns and root directory.
* @param {string[]} patterns
* @param {string} rootDir
* @returns {TestPathPatternsExecutor}
*/
function createPathMatcher(patterns, rootDir) {
const testPatterns = createPathPatterns(patterns);
return testPatterns.toExecutor({ rootDir });
}
/**
* Tests whether an absolute path matches given patterns relative to rootDir.
* @param {string[]} patterns
* @param {string} rootDir
* @param {string} absPath
* @returns {boolean}
*/
function matchesPattern(patterns, rootDir, absPath) {
const executor = createPathMatcher(patterns, rootDir);
return executor.isMatch(absPath);
}
/**
* Returns a human-friendly representation of the patterns.
* @param {string[]} patterns
* @returns {string}
*/
function formatPatterns(patterns) {
const testPatterns = createPathPatterns(patterns);
return testPatterns.toPretty();
}
/**
* Checks if all patterns in the array are valid regular expressions.
* @param {string[]} patterns
* @returns {boolean}
*/
function validatePatterns(patterns) {
const testPatterns = createPathPatterns(patterns);
return testPatterns.isValid();
}
module.exports = {
TestPathPatterns,
TestPathPatternsExecutor,
createPathPatterns,
createPathMatcher,
matchesPattern,
formatPatterns,
validatePatterns,
};
const assert = require('node:assert');
const {
TestPathPatterns,
TestPathPatternsExecutor,
createPathPatterns,
createPathMatcher,
matchesPattern,
formatPatterns,
validatePatterns,
} = require('../src/index.js');
// 1. TestPathPatterns can be constructed with pattern strings and correctly reports isSet, isValid, toPretty, and toJSON
const emptyPatterns = createPathPatterns([]);
assert.strictEqual(emptyPatterns.isSet(), false);
assert.strictEqual(emptyPatterns.isValid(), true);
assert.strictEqual(emptyPatterns.toPretty(), '');
assert.deepStrictEqual(emptyPatterns.toJSON(), {
patterns: [],
type: 'TestPathPatterns',
});
const samplePatterns = createPathPatterns(['test/.*\\.spec\\.js', 'src/components/.*']);
assert.strictEqual(samplePatterns.isSet(), true);
assert.strictEqual(samplePatterns.isValid(), true);
assert.strictEqual(samplePatterns.toPretty(), 'test/.*\\.spec\\.js|src/components/.*');
assert.strictEqual(formatPatterns(['test/.*\\.spec\\.js', 'src/components/.*']), 'test/.*\\.spec\\.js|src/components/.*');
assert.deepStrictEqual(samplePatterns.toJSON(), {
patterns: ['test/.*\\.spec\\.js', 'src/components/.*'],
type: 'TestPathPatterns',
});
// 2. TestPathPatterns reports isValid as false when given an invalid regex pattern
const invalidPatterns = createPathPatterns(['[invalid-regex(']);
assert.strictEqual(invalidPatterns.isSet(), true);
assert.strictEqual(invalidPatterns.isValid(), false);
assert.strictEqual(validatePatterns(['[invalid-regex(']), false);
assert.strictEqual(validatePatterns(['valid/path']), true);
// 3. TestPathPatternsExecutor created from empty patterns matches any absolute path within or outside rootDir
const rootDir = '/workspace/project';
const emptyExecutor = emptyPatterns.toExecutor({ rootDir });
assert.strictEqual(emptyExecutor.isSet(), false);
assert.strictEqual(emptyExecutor.isValid(), true);
assert.strictEqual(emptyExecutor.isMatch('/workspace/project/src/index.js'), true);
assert.strictEqual(emptyExecutor.isMatch('/workspace/project/test/unit.test.js'), true);
assert.strictEqual(emptyExecutor.isMatch('/outside/other.js'), true);
assert.strictEqual(matchesPattern([], rootDir, '/workspace/project/src/index.js'), true);
// 4. TestPathPatternsExecutor matches paths against relative pattern strings against rootDir
const executor = samplePatterns.toExecutor({ rootDir });
assert.strictEqual(executor.isSet(), true);
assert.strictEqual(executor.isValid(), true);
assert.strictEqual(executor.toPretty(), 'test/.*\\.spec\\.js|src/components/.*');
assert.strictEqual(executor.isMatch('/workspace/project/src/components/Button.tsx'), true);
assert.strictEqual(executor.isMatch('/workspace/project/test/Button.spec.js'), true);
assert.strictEqual(executor.isMatch('/workspace/project/docs/readme.md'), false);
assert.strictEqual(executor.isMatch('/workspace/project/src/utils/math.ts'), false);
assert.strictEqual(matchesPattern(['test/.*\\.spec\\.js', 'src/components/.*'], rootDir, '/workspace/project/src/components/Button.tsx'), true);
assert.strictEqual(matchesPattern(['test/.*\\.spec\\.js', 'src/components/.*'], rootDir, '/workspace/project/docs/readme.md'), false);
// 5. TestPathPatternsExecutor correctly handles patterns with leading dot-slash prefix matching relative to rootDir
const dotSlashPatterns = createPathPatterns(['./test/unit']);
const dotSlashExecutor = dotSlashPatterns.toExecutor({ rootDir });
assert.strictEqual(dotSlashExecutor.isMatch('/workspace/project/test/unit/app.test.js'), true);
assert.strictEqual(dotSlashExecutor.isMatch('/workspace/project/other/test/unit/app.test.js'), false);
assert.strictEqual(matchesPattern(['./test/unit'], rootDir, '/workspace/project/test/unit/app.test.js'), true);
assert.strictEqual(matchesPattern(['./test/unit'], rootDir, '/workspace/project/other/test/unit/app.test.js'), false);
console.log('All contract assertions passed successfully.');
Ursprungs-Seeder
anonym