Skip to content

test: add tests for workspace-detector utility #59

@George-iam

Description

@George-iam

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.tsWorkspaceInfo, 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    good first issueGood for newcomerstestingTest improvements and coverage

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions