UNPKG

histoire

Version:

A fast story book powered by Vite

3 lines • 2.63 kB
/** Public Vitest exports outside collection, including explicit unsupported APIs. */ export declare const STORY_COMPATIBILITY_CODE = "\n/** Fails explicitly when an API requires a real Vitest worker. */\nfunction unsupportedRuntimeFeature(feature) {\n throw new Error(`${feature} is not supported inside Histoire story runtime.`)\n}\n\n/** Provides a chainable runtime no-op for compile-time type assertions. */\nfunction createTypeExpect() {\n return new Proxy(() => undefined, {\n get: (_target, property) => property === 'then' ? undefined : createTypeExpect(),\n apply: () => createTypeExpect(),\n })\n}\n\nexport const vitest = vi\nexport { expect }\nexport { chai }\nexport const assert = chai.assert\nexport const should = chai.should\nexport const expectTypeOf = createTypeExpect\n/** Leaves compile-time type checking to TypeScript. */\nexport function assertType() {}\n/** Reads context provided by the active Vitest worker. */\nexport function inject(key) {\n return globalThis.__vitest_worker__?.providedContext?.[key]\n}\nexport const mocker = globalThis.__vitest_mocker__\n/** Skips benchmark registration in the story preview. */\nconst ignoreBenchmark = () => {}\nexport const bench = Object.assign(ignoreBenchmark, {\n only: ignoreBenchmark,\n skip: ignoreBenchmark,\n todo: ignoreBenchmark,\n})\n/** Common failure path for runner classes unavailable in story iframes. */\nclass UnsupportedVitestRuntime {\n /** Rejects instantiation outside the real Vitest runner. */\n constructor() {\n unsupportedRuntimeFeature('Vitest runner classes')\n }\n}\n/** Compatibility export for imports of Vitest's benchmark runner. */\nexport class BenchmarkRunner extends UnsupportedVitestRuntime {}\n/** Compatibility export for imports of Vitest's module evaluator. */\nexport class EvaluatedModules extends UnsupportedVitestRuntime {}\n/** Compatibility export for imports of Vitest's test runner. */\nexport class TestRunner extends UnsupportedVitestRuntime {}\n/** Reports unsupported snapshots through the matcher result contract. */\nconst unsupportedSnapshotResult = () => ({\n pass: false,\n message: () => 'Snapshot assertions are not supported inside Histoire story runtime.',\n})\nexport const Snapshots = Object.freeze({\n toMatchSnapshot: unsupportedSnapshotResult,\n toMatchInlineSnapshot: unsupportedSnapshotResult,\n toMatchFileSnapshot: unsupportedSnapshotResult,\n})\n/** Rejects artifacts because no artifact recorder exists in this runtime. */\nexport function recordArtifact() {\n unsupportedRuntimeFeature('recordArtifact')\n}\n"; //# sourceMappingURL=compatibility.d.ts.map