MCPcopy Create free account
hub / github.com/Effect-TS/effect / collectorModule

Function collectorModule

packages/tools/doctest/src/Plugin.ts:13–25  ·  view source on GitHub ↗
(
  file: string,
  snippets: ReadonlyArray<Source.Snippet>,
  version?: string | undefined
)

Source from the content-addressed store, hash-verified

11const runner = "@effect/doctest/Runner"
12
13const collectorModule = (
14 file: string,
15 snippets: ReadonlyArray<Source.Snippet>,
16 version?: string | undefined
17): string => {
18 const tests = snippets.map((snippet, index) => {
19 const id = JSON.stringify(Protocol.snippetId(file, index, version))
20 const label = JSON.stringify(snippet.name ?? `line ${snippet.line}`)
21 return `test(${label}, () => import(${id}))`
22 })
23
24 return `import { test } from "@effect/doctest/Runtime"\n\n${tests.join("\n\n")}\n`
25}
26
27/**
28 * Creates a Vite plugin that transforms marked documentation snippets into Vitest tests.

Callers 1

loadFunction · 0.85

Calls 2

joinMethod · 0.80
mapMethod · 0.45

Tested by

no test coverage detected