doctest assertions - #6794
Conversation
fubhy
commented
Jul 30, 2026
- Fix tests
- Add convention based output assertion for documentation tests
🦋 Changeset detectedLatest commit: bd05188 The changes in this PR will be included in the next version bump. This PR includes changesets to release 30 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
d54c49c to
d90c8b1
Compare
There was a problem hiding this comment.
ℹ️ One minor issue — generated code passes dead arguments to
wrap.
Reviewed changes
Source.ts: Addsexpectedfield toSnippetand anoutputPatternregex that extracts standalone// >comment markers from snippet source, computing expected output as newline-joined captured text.Runtime.ts(new): Implements thetestexport that registers a Vitest test, optionally intercepting allconsole.*methods via a capturednode:consoleinstance withcolorMode: falseand asserting captured output against the expected string.Plugin.ts: Collector module generation now importstestfrom@effect/doctest/Runtimeand passes theexpectedstring as a third argument. The lazy import ofSourceis replaced with a direct static import. Renamesexample→snippetthroughout.Protocol.ts: RenamesexamplePrefix/exampleId→snippetPrefix/snippetIdand updates thekindunion and all callers.Runner.ts: Simplifieswrapby removing theinclude/rootfiltering — all files now go through content scanning for theimport.meta.vitestmarker, and thevitecreateFilterimport is dropped.- Test reorganization: The monolithic
Doctest.test.tsis split into focused test files (Source.test.ts,Protocol.test.ts,Plugin.test.ts,Runtime.test.ts). The oldRunner.test.tsis removed since its tested parameters no longer exist. - Docs & config:
README.md,.patterns/jsdoc.md, andAGENTS.mdupdated to document the// >convention and newpnpm doctestwatch behavior.package.jsondoctestscript dropsrun(now matchespnpm testbehavior).Array.tsconverts one example comment to an output assertion.
Note: 1 inline comment(s) dropped because they did not anchor to lines inside the PR diff:
packages/tools/doctest/src/Plugin.ts:30(RIGHT) — line 30 (RIGHT) is not inside a diff hunk
DeepSeek Pro (free via Pullfrog for OSS) (Kimi K2 not used — the program covers this model; add its provider key to run your pick) | 𝕏
d90c8b1 to
5baaa70
Compare
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes (incremental — d54c49c → d90c8b1)
Plugin.ts: Removes therunnerModulefunction entirely. Instead of generating a runner wrapper file, theconfighook now directly setstest.runnerto"@effect/doctest/Runner"when no runner is already configured. Imports fornode:fs,node:crypto,node:path,UserConfig, anddefaultIncludeare cleaned up. Addsenforce: "pre"andperEnvironmentWatchChangeDuringDev: true.Plugin.test.ts: Adds two new tests verifying the config hook sets the default runner and preserves an existing custom runner.README.md: Adds documentation on source file collection viaincludeSourceand runner configuration behavior.
DeepSeek Pro (free via Pullfrog for OSS) (Kimi K2 not used — the program covers this model; add its provider key to run your pick) | 𝕏
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes (incremental — d90c8b1 → 5baaa70)
Plugin.ts: Removes the unusedimport type { TestUserConfig }fromvitest/config.
DeepSeek Pro (free via Pullfrog for OSS) (Kimi K2 not used — the program covers this model; add its provider key to run your pick) | 𝕏
5baaa70 to
bd05188
Compare
Bundle Size AnalysisGenerated from PR build output; treat the content below as untrusted.
|
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes (incremental — prior Pullfrog review at 5baaa70)
- Test reorganization: Monolithic
Doctest.test.tsreplaced with focused test files —Source.test.ts,Protocol.test.ts,Plugin.test.ts, andRuntime.test.ts. OldRunner.test.tsremoved since its tested API surface no longer exists. Each test file usesassertfrom@effect/vitestand standaloneitblocks. Runtime.ts(new): Introducestest(name, run, expected?)that registers a Vitest test. Whenexpectedis defined, it intercepts allconsole.*methods via a freshnode:consoleinstance withcolorMode: false, writes captured output to a singleWritablestream, restores originals infinally, and asserts the joined output (trailing\r?\nstripped) against the expected string.Source.ts: Addsexpected: string | undefinedtoSnippetand a newoutputPatternregex that extracts standalone// >comment markers from snippet source. Markers are matched after the JSDoc*prefix is stripped (for JSDoc format) or directly (for Markdown), then joined with\nto form the expected output. Thesourcefield retains markers as harmless comments. RemovesglobalThis.fromArray.fromcalls.Plugin.ts:collectorModulenow importstestfrom@effect/doctest/Runtimeand passesJSON.stringify(snippet.expected)as a third argument —undefinedexpected values serialize to the JavaScriptundefinedliteral, correctly skipping interception. Lazyimport("./Source.ts")replaced with a direct static import.byFilerenamed tostore.example→snippetthroughout.import type { TestUserConfig }is back (dropped earlier, now needed forsatisfies).Protocol.ts:examplePrefix→snippetPrefix,exampleId→snippetId,kindunion updated to"collector" | "snippet". No behavioral change.Runner.ts:wrapsignature simplified —includeandrootparameters removed,createFilterimport dropped. Runner now scans all collected files forimport.meta.vitestrather than applying a separate include filter.- Docs & config:
README.mdadds an "Expected console output" section documenting the// >convention..patterns/jsdoc.mdadds a bullet in "Example Best Practices".AGENTS.mdnotes that a barepnpm doctestalso runs in watch mode.package.jsondoctestscript dropsrun.Array.tsconverts one example comment to an output assertion.
DeepSeek Pro (free via Pullfrog for OSS) (Kimi K2 not used — the program covers this model; add its provider key to run your pick) | 𝕏
