The workspace detector utility (src/utils/workspace-detector.ts) inspects the filesystem to determine workspace type (npm, pnpm, yarn, lerna, nx, rush, gradle, maven, vscode, etc.) and enumerate child projects. This logic has no dedicated test file. Since it reads the filesystem, tests should create small temporary directory trees with the relevant marker files (package.json with workspaces, pnpm-workspace.yaml, .code-workspace, etc.) and verify detection results.
Relevant files:
src/utils/workspace-detector.ts — the module to test
src/types.ts — WorkspaceInfo, WorkspaceType types
test/ — place the new test file here as workspace-detector.test.ts
Suggested test cases:
- Detects npm workspace (package.json with
workspaces field)
- Detects pnpm workspace (pnpm-workspace.yaml exists)
- Detects single repo (has .git but no workspace markers)
- Returns null or appropriate result for empty directory
- Correctly enumerates child project paths from workspace config
Acceptance criteria:
- New file
test/workspace-detector.test.ts with at least 6 tests
- Tests create and clean up temporary directories
- All tests pass with
npm test
The workspace detector utility (
src/utils/workspace-detector.ts) inspects the filesystem to determine workspace type (npm, pnpm, yarn, lerna, nx, rush, gradle, maven, vscode, etc.) and enumerate child projects. This logic has no dedicated test file. Since it reads the filesystem, tests should create small temporary directory trees with the relevant marker files (package.json with workspaces, pnpm-workspace.yaml, .code-workspace, etc.) and verify detection results.Relevant files:
src/utils/workspace-detector.ts— the module to testsrc/types.ts—WorkspaceInfo,WorkspaceTypetypestest/— place the new test file here asworkspace-detector.test.tsSuggested test cases:
workspacesfield)Acceptance criteria:
test/workspace-detector.test.tswith at least 6 testsnpm test