Lines 1-31javascript
2import * as fs from "fs";
3import * as path from "path";
4import { createHash } from "crypto";
5import { createRequire } from "module";
6import { tryGetActiveOtelContext, resolveTraceUrl, buildHtmlDocEntry } from "executable-stories-formatters";
7var storyRegistry = globalThis.__jestExecutableStoriesRegistry ??= /* @__PURE__ */ new Map();
8var attachmentRegistry = /* @__PURE__ */ new Map();
9var otelSpansRegistry = /* @__PURE__ */ new Map();
10var exitHandlerRegistered = globalThis.__jestExecutableStoriesExitHandler ?? false;
11function getOutputDir() {
12 const baseDir = process.env.JEST_STORY_DOCS_DIR ?? ".jest-executable-stories";
13 return path.resolve(process.cwd(), baseDir);
14}
LowWeak Crypto
Package source references weak cryptographic algorithms.
dist/index.jsView on unpkg · L11 15function flushStories() {
16 if (storyRegistry.size === 0) return;
17 const workerId = process.env.JEST_WORKER_ID ?? "0";
18 const outputDir = path.join(getOutputDir(), `worker-${workerId}`);
19 fs.mkdirSync(outputDir, { recursive: true });
20 for (const [testFilePath, scenarios] of storyRegistry) {
21 if (!scenarios.length) continue;
22 const hash = createHash("sha1").update(testFilePath).digest("hex").slice(0, 12);
23 const baseName = testFilePath === "unknown" ? "unknown" : path.basename(testFilePath);
24 const outFile = path.join(outputDir, `${baseName}.${hash}.json`);
25 const fileAttachments = attachmentRegistry.get(testFilePath);
26 const fileOtelSpans = otelSpansRegistry.get(testFilePath);
27 const scenariosWithAttachments = scenarios.map((s, i) => ({
29 _attachments: fileAttachments?.get(i) ?? [],
30 ...fileOtelSpans?.get(i) ? { _otelSpans: fileOtelSpans.get(i) } : {}