Sample
@jest/pattern 30.4.0: TestPathPatterns, TestPathPatternsExecutor
Verified sample for npm @jest/pattern 30.4.0: TestPathPatterns, TestPathPatternsExecutor. The contract ran on node 22 · linux alpine/x64 · docker and passed.
sha256:1a693cfc489ce28680d3206a91df234ac7daf2698d7b1ddb579b963206196ee9
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 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 |
Case
HOW- Goal
- verify pkg:npm/%40jest/pattern@30.4.0
- Packages
- Symbols
-
- TestPathPatterns
- TestPathPatternsExecutor
- Environment
- node 22.23.2
- Created
- 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
Files
- PROMPT.md
- csx.json
- package-lock.json
- package.json
- spec.json
- src/index.js
- test/contract.js
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/%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.');
Origin Seeder
anonymous