Problem
When running the test suite (bun run test) on Windows, packages/leadtype/src/source/source.test.ts fails in the OpenAPI overlay test (createDocsSource > overlays generated OpenAPI pages while keeping authored pages live):
AssertionError: expected 'C:/Users/user/AppData/Local/Temp/lead...' to be 'C:\Users\user\AppData\Local\Temp\lead...' // Object.is equality
- Expected: "C:\Users\user\AppData\Local\Temp\leadtype-source-LinCaf\guide.mdx"
+ Received: "C:/Users/user/AppData/Local/Temp/leadtype-source-LinCaf/guide.mdx"
❯ src/source/source.test.ts:454:37
452| throw new Error("Expected authored and generated metadata.");
453| }
454| expect(authoredMeta.filePath).toBe(authoredPath);
455| expect(generatedMeta.filePath).toContain("leadtype-openapi-");
456| expect(generatedMeta.filePath.startsWith(contentDir)).toBe(false);
Root Cause
createDocsSource() returns metadata whose filePath is normalized to POSIX-style paths (using / separators).
- In
source.test.ts, authoredPath and contentDir are constructed using path.join(), which produces platform-native paths containing \ separators on Windows.
- The test performs strict string equality (
.toBe(authoredPath)) and prefix checks (.startsWith(contentDir)), which fail solely because the path separators differ (/ vs \), even though both paths refer to the same filesystem location.
Solution
Normalize authoredPath and contentDir to POSIX-style paths before performing equality and prefix assertions. For example:
const normalizedAuthoredPath = authoredPath.replaceAll("\\", "/");
const normalizedContentDir = contentDir.replaceAll("\\", "/");
expect(authoredMeta.filePath).toBe(normalizedAuthoredPath);
expect(generatedMeta.filePath.startsWith(normalizedContentDir)).toBe(false);
Alternatively, normalize both sides using path.resolve() or another consistent path normalization strategy prior to comparison. This ensures the test behaves consistently across both Windows and POSIX platforms.
Problem
When running the test suite (
bun run test) on Windows,packages/leadtype/src/source/source.test.tsfails in the OpenAPI overlay test (createDocsSource > overlays generated OpenAPI pages while keeping authored pages live):Root Cause
createDocsSource()returns metadata whosefilePathis normalized to POSIX-style paths (using/separators).source.test.ts,authoredPathandcontentDirare constructed usingpath.join(), which produces platform-native paths containing\separators on Windows..toBe(authoredPath)) and prefix checks (.startsWith(contentDir)), which fail solely because the path separators differ (/vs\), even though both paths refer to the same filesystem location.Solution
Normalize
authoredPathandcontentDirto POSIX-style paths before performing equality and prefix assertions. For example:Alternatively, normalize both sides using
path.resolve()or another consistent path normalization strategy prior to comparison. This ensures the test behaves consistently across both Windows and POSIX platforms.