This document captures gaps in unit test coverage and provides pre/post implementation guidance to address them. It is intended as a living checklist for reliability work on the Barrel Roll VS Code extension.
The focus is on unit and integration coverage for edge cases in extension behavior, file system filtering, barrel generation, content sanitization, export parsing, and lint rule enforcement. It also includes structural refactoring guidance to reduce coupling and improve testability, plus a monorepo plan (Turbo) to enforce boundaries between the extension and core functionality.
These items improve implementation clarity, reduce ambiguity, and increase deliverable quality.
- Acceptance criteria for each step must be explicit, measurable, and testable.
- Each step must state which tests are added or updated and which behaviors are verified.
- Each step must record whether it changes observable behavior or is refactor-only.
- Record key decisions with date, choice, and rationale.
- Keep the log short and scoped to architectural or workflow decisions.
- Files touched.
- Behavior changes expected.
- Risk level (low/medium/high).
- Rollback strategy if behavior regresses.
packages/coremust not importvscode.- Barrel generation remains idempotent (running twice yields same output).
- The extension layer only composes and delegates (no core business logic).
- Split into two phases: extraction first, behavior second.
- Avoid mixing refactors with behavior changes in the same step.
- Each step must include a minimal test plan (what will fail if wrong).
- Tests should assert both success and failure modes when applicable.
- Each high-risk step must include a rollback note before implementation.
- Before starting a step, write clear success criteria that define completion.
- Criteria must be observable and verifiable (tests, logs, or outputs).
- Include at least one positive and one negative case when behavior changes.
src/extension.tscombines activation, logging setup, UI interactions, command registration, queueing, error handling, and progress handling.src/core/barrel/barrel-file.generator.tsmixes traversal strategy, export discovery, content building, sanitization, and IO.
src/extension.tsdirectly binds tovscodeAPIs and concrete implementations, forcing heavy module mocking.BarrelFileGeneratorconstructs or owns most dependencies internally, limiting substitution in tests.- File system ignore policy is embedded inside
FileSystemServicerather than a dedicated policy.
- Prefer composition over inheritance: small, focused services with injected dependencies.
- Keep core logic pure and immutable where possible (return new values instead of mutating shared state).
- Isolate
vscodedependencies in the extension package boundary.
- Add tests for command queue serialization across back-to-back invocations.
- Add tests that a failed command does not block subsequent queued operations.
- Add tests for
withProgresserror propagation when the task throws. - Add tests for
showOpenDialogthrowing errors (not just returningundefined). - Add tests for
ensureDirectoryUriwhenFileType.Unknownor unexpected types are returned.
- Add tests for expanded ignored directories (e.g.,
dist,build,out,coverage,__mocks__,.vscode,.idea). - Add tests for case-insensitive matching (e.g.,
Node_Modules,DIST). - Add tests for case-insensitive TypeScript and test file suffixes (e.g.,
FILE.TEST.TS).
- Add tests for recursion depth behavior (max depth = 20) and safe termination.
- Add tests for partial failures when one file fails parsing and the rest continue.
- Add tests for export extension detection when existing barrels have no export lines.
- Add tests for errors when reading subdirectory barrel existence (stat/read errors).
- Add tests for malformed multiline exports that never terminate.
- Add tests for Windows
\r\nline endings and trailing whitespace around export lines.
- Add tests for double-quoted exports:
export { x } from "./foo";. - Add tests for
export * as ns from '...';andexport type * from '...';lines.
- Add tests for
export * as ns from '...';and type-only re-exports with module specifiers. - Add tests for
export =(CJS style) to validate expected behavior. - Add tests for
.jsx,.mjs,.cjsscript kind selection. - Add tests for binding pattern exports (e.g.,
export const { a } = obj;).
- Restore RuleTester-based tests for
no-instanceof-error-autofixonce the new fix API is addressed. - Add regression tests to assert expected fixes are applied correctly.
- Run
npm testto establish a baseline for current failures and timings. - Record current test counts and coverage metrics if available (even informal).
- Address high-risk and high-impact behaviors first:
- Command queue serialization and failure isolation.
- File system ignore list and case-insensitive behavior.
- Barrel generation depth and partial failure handling.
- Prefer unit tests for deterministic behavior.
- Use targeted integration tests only for parsing or disk I/O edge cases that require real files.
- Avoid new dependencies unless necessary.
- Add fixtures under
src/test/fixturesif needed instead of embedding large blobs in tests. - Keep fixtures minimal and domain-focused.
- The extension should be a thin composition layer. Business logic should move to core modules with minimal or no
vscodedependency. - Generator orchestration should be split into smaller services that can be tested independently.
- Policies (like ignore lists) should be separated from IO services.
CommandHandler(new): orchestration for command execution, queueing, progress, and errors.DirectoryScanner(new): returns{ tsFiles, subdirectories }for a given directory path.EntryCollector(new): transforms files + subdirectories intoMap<string, BarrelEntry>.BarrelWriter(new): determines extension, sanitizes existing content, and writes output.IgnorePolicy(new): pure predicate for traversable directories.
- Ensure each step returns new objects (e.g., new
MaporSet) and does not mutate shared state. - Keep IO at the edges, with pure transformations in the center.
- Extract
IgnorePolicyfromFileSystemServiceand update tests. - Extract
DirectoryScannerandEntryCollectorfromBarrelFileGenerator. - Extract
BarrelWriterfromBarrelFileGenerator. - Replace
BarrelFileGeneratorwith a coordinator that wires these services. - Move command pipeline logic into
CommandHandlerand slimsrc/extension.ts. - Update unit tests to target new services directly, and reduce
vscodemocking.
- Extension command queue tests.
- FileSystemService ignore list and case-insensitivity tests.
- Barrel generation recursion depth and partial failure tests.
- Content sanitizer and export pattern edge cases.
- Export parser special forms.
- ESLint rule fix tests once the rule is updated.
- Keep test titles starting with
shouldto satisfy the ESLint rule. - Use
src/test/testTypes.tshelpers for mocks and fake URIs. - For module mocks, rely on
--experimental-test-module-mocks(already enabled inscripts/run-tests.cjs).
Create strict boundaries between the VS Code extension surface and the core barrel logic, improving testability, reuse, and release discipline.
packages/core- Pure logic: parsing, barrel generation, content sanitization, ignore policies, logging interfaces.
packages/extension- VS Code entrypoint and composition only.
packages/shared(optional)- Shared types or utilities, if needed.
packages/coremust not importvscode.packages/extensiondepends onpackages/core.- Cross-package communication through explicit interfaces and composition.
- Turbo for task orchestration (
build,lint,test,package). - Workspace manager (recommend
npmworkspaces to reduce churn).
- Add workspace root configuration (workspaces + Turbo config).
- Create
packages/coreand move core modules:src/core,src/utils,src/types,src/logging(or subset if logging remains extension-only).
- Create
packages/extensionand move:src/extension.ts,src/test/unit/extension.test.ts, VS Code packaging files.
- Update import paths and build output:
- Extension depends on
@barrel-roll/core(workspace alias).
- Extension depends on
- Update
scripts/and test runners to run per-package tasks. - Update CI to run Turbo tasks and cache where appropriate.
- Validate VSIX packaging from
packages/extension.
- Ensure tests pass in current layout.
- Ensure build pipeline is stable and deterministic.
- Decide on workspace manager and lockfile strategy.
- Confirm no
vscodeimports inpackages/core. - Confirm
packages/coreunit tests run without VS Code. - Confirm extension activation still works and packaging is correct.
- Confirm Turbo cache and task graph are correct.
- Re-run
npm testand confirm stability. - If any failures are flaky, quarantine and triage with isolation.
- Confirm no regressions in existing test expectations.
- New tests cover at least one previously untested edge case.
- All new tests have
should ...titles. - Assertions are specific and error messages are clear.
- No new lint warnings introduced.
- Keep this document updated as tests are added or behavior changes.
- Move resolved items to a separate
Resolvedsection if the list grows.
- Extract
IgnorePolicyfromFileSystemServiceand add case-insensitive tests. - Split
BarrelFileGeneratorintoDirectoryScanner,EntryCollector,BarrelWriter. - Extract
CommandHandlerand slimsrc/extension.tsto pure composition. - Add missing edge-case tests:
- Command queue serialization and failure isolation.
- Recursion depth max guard behavior.
- Export pattern cases (double quotes,
export * as).