Skip to content

test(package-surface): fix cross-platform path separator normalization failure on Windows #170

Description

@Adityakk9031

Problem

When running the test suite (bun run test) on Windows, packages/leadtype/src/internal/package-surface.test.ts fails during the framework boundary check (does not let framework runtimes leak into core modules):

AssertionError: expected [ ... ] to deeply equal []
+ [
+   { "file": "search\\react.ts", "specifier": "react" },
+   { "file": "search\\svelte.ts", "specifier": "svelte/store" },
+   { "file": "search\\vue.ts", "specifier": "vue" },
+   { "file": "webmcp\\react.ts", "specifier": "react" },
+   { "file": "webmcp\\svelte.ts", "specifier": "svelte" },
+   { "file": "webmcp\\vue.ts", "specifier": "vue" }
+ ]

Root Cause

path.relative() returns platform-native path separators. On Windows, this results in relative paths containing backslashes (e.g. search\react.ts). The exclusion rules in package-surface.test.ts compare these values against hardcoded POSIX-style paths (e.g. search/react.ts, webmcp/react.ts).

Because the path separators differ, the exclusion checks fail to match the intended files, causing legitimate framework adapter modules to be incorrectly reported as framework boundary violations.

Solution

Normalize relative file paths to POSIX format before applying the boundary exclusion rules:

const relativePath = path
  .relative(rootDir, file)
  .replaceAll("\\", "/");

This ensures the boundary checks behave consistently across Windows and POSIX platforms, preventing false-positive framework leak detections during the test suite.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions