jest-metadata
Version:
🦸♂️ Superhero power for your Jest reporters! 🦸♀️
31 lines • 1.05 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.CircusInstanceCache = void 0;
class CircusInstanceCache {
describeInstances = new InstanceCache();
hookInstances = new InstanceCache();
testInstances = new InstanceCache();
getDescribeId(block) {
return `describe_${this.describeInstances.getInstanceId(block)}`;
}
// eslint-disable-next-line @typescript-eslint/ban-types
getHookId(asyncError) {
return `hook_${this.hookInstances.getInstanceId(asyncError)}`;
}
// eslint-disable-next-line @typescript-eslint/ban-types
getTestId(asyncError) {
return `test_${this.testInstances.getInstanceId(asyncError)}`;
}
}
exports.CircusInstanceCache = CircusInstanceCache;
class InstanceCache {
cache = new WeakMap();
counter = 0;
getInstanceId = (obj) => {
if (!this.cache.has(obj)) {
this.cache.set(obj, `${this.counter++}`);
}
return this.cache.get(obj);
};
}
//# sourceMappingURL=CircusInstanceCache.js.map