MCPcopy Create free account
hub / github.com/deepnote/vscode-deepnote / generateScreenShotFileName

Function generateScreenShotFileName

src/test/common.ts:275–287  ·  view source on GitHub ↗
(contextOrFileName: string | Mocha.Context)

Source from the content-addressed store, hash-verified

273
274const screenShotCount = new Map<string, number>();
275export async function generateScreenShotFileName(contextOrFileName: string | Mocha.Context) {
276 const fullTestNameHash =
277 typeof contextOrFileName === 'string'
278 ? ''
279 : (await computeHash(contextOrFileName.currentTest?.fullTitle() || '', 'SHA-256')).substring(0, 10); // Ensure file names are short enough for windows.
280 const testTitle = typeof contextOrFileName === 'string' ? '' : contextOrFileName.currentTest?.title || '';
281 const counter = (screenShotCount.get(fullTestNameHash) || 0) + 1;
282 screenShotCount.set(fullTestNameHash, counter);
283 const fileNamePrefix =
284 typeof contextOrFileName === 'string' ? contextOrFileName : `${testTitle}_${fullTestNameHash}`;
285 const name = `${fileNamePrefix}_${counter}`.replace(/[\W]+/g, '_');
286 return `${name}-screenshot.png`;
287}

Callers 2

captureScreenShotFunction · 0.90
captureScreenShotFunction · 0.90

Calls 4

computeHashFunction · 0.90
getMethod · 0.65
setMethod · 0.65
replaceMethod · 0.45

Tested by

no test coverage detected