샘플
@vitest/spy 2.1.9: isMockFunction
검증된 샘플 — npm @vitest/spy 2.1.9: isMockFunction. node 22 · linux debian/x64 · docker에서 contract를 실행해 통과했습니다: @vitest/spy.isMockFunction returns true for mock…
sha256:b89badde09e6300b99d7e0450fa69c76162ed1e58cdf6f833b134a089456c777
이 네트워크가 제공하는 것은 하나입니다. 빌드되는 샘플. 샌드박스에서 돌리고 서명된 영수증을 보관합니다. 등급을 매기지 않고 무엇도 보증하지 않습니다 — 같은 코드가 당신 환경에서 빌드되는지는 측정한 적이 없습니다.
통과한 계약 영수증을 낸 서로 다른 서명 키의 수입니다. 하나면 작성자 혼자이고, 둘 이상이면 다른 사람도 빌드했다는 뜻입니다. 키는 스스로 만드는 것이고 뒤에 등록된 신원이 없으므로, 세는 것은 사람이 아니라 키입니다.
MIT-0
실행 증거
선언된 환경과 서명된 실행을 분리해 두었습니다. 이 샘플이 무엇을 어디서 실행했는지 그대로 볼 수 있습니다.
- 증거 기준
- 서명된 컨트랙트 통과
- 검증 영수증
- 1
- 빌드한 서명 키
- 1
선언된 환경
linux 24 · ubuntu · glibc 2.39 x64 npm
검증 실행 환경
| 환경 | 컨트랙트 | 단계 | 실행일 |
|---|---|---|---|
| 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 |
케이스
HOW- 목표
- verify @vitest/spy.isMockFunction in pkg:npm/%40vitest/spy@2.1.9
- 심벌
-
- @vitest/spy.isMockFunction
- 생성일
- 2026-09-06T18:09:43Z
컨트랙트
- @vitest/spy.isMockFunction returns true for mock functions created with fn()
- @vitest/spy.isMockFunction returns true for spies created on object methods with spyOn()
- @vitest/spy.isMockFunction returns true for getter and setter spies created with spyOn()
- @vitest/spy.isMockFunction returns false for regular unmocked functions and async functions
- @vitest/spy.isMockFunction returns false for non-function values such as null, undefined, objects, numbers, and strings
- @vitest/spy.isMockFunction returns false for ordinary objects that mimic mock properties without being a function
- @vitest/spy.isMockFunction returns false for original methods after spy.mockRestore() is invoked
파일
- PROMPT.md
- csx.json
- index.mjs
- package-lock.json
- package.json
- spec.json
- test/contract.mjs
소스
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/spy.isMockFunction in pkg:npm/%40vitest/spy@2.1.9
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:npm/%40vitest/spy@2.1.9
Demonstrate these symbols/APIs:
- @vitest/spy.isMockFunction
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:1615857ec2170fe17228907df74d3044e3efdaf6851b05fb7b10013326cabc6f","contract":["@vitest/spy.isMockFunction returns true for mock functions created with fn()","@vitest/spy.isMockFunction returns true for spies created on object methods with spyOn()","@vitest/spy.isMockFunction returns true for getter and setter spies created with spyOn()","@vitest/spy.isMockFunction returns false for regular unmocked functions and async functions","@vitest/spy.isMockFunction returns false for non-function values such as null, undefined, objects, numbers, and strings","@vitest/spy.isMockFunction returns false for ordinary objects that mimic mock properties without being a function","@vitest/spy.isMockFunction returns false for original methods after spy.mockRestore() is invoked"],"goal":"verify @vitest/spy.isMockFunction in pkg:npm/%40vitest/spy@2.1.9","kind":"HOW","packages":["pkg:npm/%40vitest/spy@2.1.9"],"schemaVersion":1,"symbols":["@vitest/spy.isMockFunction"]},"contractCommand":["node","test/contract.mjs"],"environment":{"arch":"x64","distro":"ubuntu","ecosystem":"npm","libc":"glibc","libcVersion":"2.39","os":"linux","osVersionBucket":"24","packageManager":"npm","schemaVersion":1},"license":"MIT-0","packages":["pkg:npm/%40vitest/spy@2.1.9"],"schemaVersion":1,"subject":"pkg:npm/%40vitest/spy@2.1.9","symbols":["@vitest/spy.isMockFunction"],"verifierAdapter":"node-typescript@1"}
import { fn, spyOn, isMockFunction } from '@vitest/spy';
export { fn, spyOn, isMockFunction };
export default isMockFunction;
{
"name": "sample-vitest-spy-is-mock-function",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "sample-vitest-spy-is-mock-function",
"version": "1.0.0",
"license": "MIT-0",
"dependencies": {
"@vitest/spy": "2.1.9"
}
},
"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/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-spy-is-mock-function",
"version": "1.0.0",
"type": "module",
"main": "index.mjs",
"license": "MIT-0",
"scripts": {
"test": "node test/contract.mjs"
},
"dependencies": {
"@vitest/spy": "2.1.9"
}
}
{
"schemaVersion": 1,
"goal": "verify @vitest/spy.isMockFunction in pkg:npm/%40vitest/spy@2.1.9",
"kind": "HOW",
"packages": [
"pkg:npm/%40vitest/spy@2.1.9"
],
"symbols": [
"@vitest/spy.isMockFunction"
]
}
import assert from 'node:assert/strict';
import { fn, spyOn, isMockFunction } from '@vitest/spy';
// 1. isMockFunction returns true for mock functions created with fn()
{
const mockFn = fn();
assert.equal(isMockFunction(mockFn), true);
const mockWithImpl = fn((x) => x * 2);
assert.equal(isMockFunction(mockWithImpl), true);
assert.equal(mockWithImpl(5), 10);
}
// 2. isMockFunction returns true for spies created on object methods with spyOn()
{
const calculator = {
add(a, b) {
return a + b;
}
};
const spy = spyOn(calculator, 'add');
assert.equal(isMockFunction(spy), true);
assert.equal(isMockFunction(calculator.add), true);
assert.equal(calculator.add(2, 3), 5);
}
// 3. isMockFunction returns true for getter and setter spies created with spyOn()
{
const person = {
_age: 30,
get age() {
return this._age;
},
set age(val) {
this._age = val;
}
};
const getSpy = spyOn(person, 'age', 'get');
assert.equal(isMockFunction(getSpy), true);
assert.equal(person.age, 30);
const setSpy = spyOn(person, 'age', 'set');
assert.equal(isMockFunction(setSpy), true);
person.age = 35;
assert.equal(person._age, 35);
}
// 4. isMockFunction returns false for regular unmocked functions and async functions
{
function standardFunction() {}
const arrowFunction = () => {};
async function asyncFunction() {}
const generatorFunction = function* () {};
assert.equal(isMockFunction(standardFunction), false);
assert.equal(isMockFunction(arrowFunction), false);
assert.equal(isMockFunction(asyncFunction), false);
assert.equal(isMockFunction(generatorFunction), false);
}
// 5. isMockFunction returns false for non-function values such as null, undefined, objects, numbers, and strings
{
assert.equal(isMockFunction(null), false);
assert.equal(isMockFunction(undefined), false);
assert.equal(isMockFunction(0), false);
assert.equal(isMockFunction(123), false);
assert.equal(isMockFunction(''), false);
assert.equal(isMockFunction('mock'), false);
assert.equal(isMockFunction(true), false);
assert.equal(isMockFunction(Symbol('mock')), false);
assert.equal(isMockFunction({}), false);
assert.equal(isMockFunction([]), false);
}
// 6. isMockFunction returns false for ordinary objects that mimic mock properties without being a function
{
const fakeObj = { _isMockFunction: true };
assert.equal(isMockFunction(fakeObj), false);
const nonMockWithFalse = () => {};
nonMockWithFalse._isMockFunction = false;
assert.equal(isMockFunction(nonMockWithFalse), false);
}
// 7. isMockFunction returns false for original methods after spy.mockRestore() is invoked
{
const target = {
greet(name) {
return `Hello, ${name}!`;
}
};
const spy = spyOn(target, 'greet');
assert.equal(isMockFunction(target.greet), true);
spy.mockRestore();
assert.equal(isMockFunction(target.greet), false);
assert.equal(target.greet('world'), 'Hello, world!');
}
console.log('All @vitest/spy.isMockFunction contract assertions passed.');
오리진 시더
익명