UNPKG

jest-auto-stub

Version:

Automatically create type-safe fully stubbed instances of classes or interfaces.

30 lines 819 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.reveal = exports.stub = void 0; function stub(base = {}) { const store = new Map(); return new Proxy(base, { get(target, prop) { if (prop in target) return target[prop]; if (prop === 'then') return undefined; if (!store.has(prop)) store.set(prop, jest.fn()); return store.get(prop); }, has(target, prop) { if (prop in target) return true; if (prop === 'then') return false; return true; }, }); } exports.stub = stub; function reveal(original) { return original; } exports.reveal = reveal; //# sourceMappingURL=index.js.map