MCPcopy
hub / github.com/jestjs/jest / _getCache

Method _getCache

packages/jest-test-sequencer/src/index.ts:67–88  ·  view source on GitHub ↗
(test: Test)

Source from the content-addressed store, hash-verified

65 }
66
67 _getCache(test: Test): Cache {
68 const {context} = test;
69 if (!this._cache.has(context) && context.config.cache) {
70 const cachePath = this._getCachePath(context);
71 if (fs.existsSync(cachePath)) {
72 try {
73 this._cache.set(
74 context,
75 JSON.parse(fs.readFileSync(cachePath, 'utf8')) as Cache,
76 );
77 } catch {}
78 }
79 }
80
81 let cache = this._cache.get(context);
82 if (!cache) {
83 cache = {};
84 this._cache.set(context, cache);
85 }
86
87 return cache;
88 }
89
90 private _shardPosition(options: ShardPositionOptions): number {
91 const shardRest = options.suiteLength % options.shardCount;

Callers 3

cacheResultsMethod · 0.95
hasFailedMethod · 0.95
timeMethod · 0.95

Calls 3

_getCachePathMethod · 0.95
setMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected